summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/network/android
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
commit9364f22aed35e1a1e9d07c121510f80be3ab0502 (patch)
treed49911209b132da58d838efa852daf28d516df21 /WebCore/platform/network/android
parent87eb0cb35bad8784770ebc807e6c982432e47107 (diff)
downloadexternal_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.zip
external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.gz
external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.bz2
Initial Contribution
Diffstat (limited to 'WebCore/platform/network/android')
-rw-r--r--WebCore/platform/network/android/ResourceHandleAndroid.cpp144
-rw-r--r--WebCore/platform/network/android/ResourceRequest.h93
-rw-r--r--WebCore/platform/network/android/ResourceResponse.h60
3 files changed, 297 insertions, 0 deletions
diff --git a/WebCore/platform/network/android/ResourceHandleAndroid.cpp b/WebCore/platform/network/android/ResourceHandleAndroid.cpp
new file mode 100644
index 0000000..35b3c5b
--- /dev/null
+++ b/WebCore/platform/network/android/ResourceHandleAndroid.cpp
@@ -0,0 +1,144 @@
+/*
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include "config.h"
+#include "ResourceHandle.h"
+
+#include "DocLoader.h"
+#include "FrameAndroid.h"
+#include "ResourceHandleClient.h"
+#include "ResourceHandleInternal.h"
+#include "WebCoreFrameBridge.h"
+#include "WebCoreResourceLoader.h"
+
+// #define notImplemented() do { fprintf(stderr, "FIXME: UNIMPLEMENTED %s %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); } while(0)
+
+namespace WebCore {
+
+ResourceHandleInternal::~ResourceHandleInternal()
+{
+ Release(m_loader);
+}
+
+ResourceHandle::~ResourceHandle()
+{
+}
+
+bool ResourceHandle::start(Frame* frame)
+{
+ FrameAndroid* f = Android(frame);
+ android::WebCoreResourceLoader* loader;
+ bool highPriority = true;
+ CachedResource* r = d->m_request.getCachedResource();
+ if (r) {
+ CachedResource::Type t = r->type();
+ highPriority = !(t == CachedResource::ImageResource ||
+ t == CachedResource::FontResource);
+ }
+ loader = f->bridge()->startLoadingResource(this, d->m_request, highPriority, false);
+
+ if (loader) {
+ Release(d->m_loader);
+ d->m_loader = loader;
+ }
+
+ return loader != NULL;
+}
+
+void ResourceHandle::cancel()
+{
+ if (d->m_loader)
+ d->m_loader->cancel();
+}
+
+PassRefPtr<SharedBuffer> ResourceHandle::bufferedData()
+{
+ return 0;
+}
+
+bool ResourceHandle::supportsBufferedData()
+{
+ // We don't support buffering data on the native side.
+ return false;
+}
+
+void ResourceHandle::setDefersLoading(bool defers)
+{
+ notImplemented();
+}
+
+/*
+* This static method is called to check to see if a POST response is in
+* the cache. The JNI call through to the HTTP cache stored on the Java
+* side may be slow, but is only used during a navigation to
+* a POST response.
+*/
+bool ResourceHandle::willLoadFromCache(ResourceRequest& request)
+{
+ // set the cache policy correctly, copied from
+ // network/mac/ResourceHandleMac.mm
+ request.setCachePolicy(ReturnCacheDataDontLoad);
+ return android::WebCoreResourceLoader::willLoadFromCache(request.url());
+}
+
+bool ResourceHandle::loadsBlocked()
+{
+ // FIXME, need to check whether connection pipe is blocked.
+ // return false for now
+ return false;
+}
+
+// Class to handle synchronized loading of resources.
+class SyncLoader : public ResourceHandleClient {
+public:
+ SyncLoader(ResourceError& error, ResourceResponse& response, Vector<char>& data) {
+ m_error = &error;
+ m_response = &response;
+ m_data = &data;
+ }
+ ~SyncLoader() {}
+
+ virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse& response) {
+ *m_response = response;
+ }
+
+ virtual void didReceiveData(ResourceHandle*, const char* data, int len, int lengthReceived) {
+ m_data->append(data, len);
+ }
+
+ virtual void didFail(ResourceHandle*, const ResourceError& error) {
+ *m_error = error;
+ }
+
+private:
+ ResourceError* m_error;
+ ResourceResponse* m_response;
+ Vector<char>* m_data;
+};
+
+void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request,
+ ResourceError& error, ResourceResponse& response, Vector<char>& data,
+ Frame* frame)
+{
+ FrameAndroid* f = Android(frame);
+ SyncLoader s(error, response, data);
+ ResourceHandle h(request, &s, false, false, false);
+ // This blocks until the load is finished.
+ f->bridge()->startLoadingResource(&h, request, true, true);
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/network/android/ResourceRequest.h b/WebCore/platform/network/android/ResourceRequest.h
new file mode 100644
index 0000000..33676ae
--- /dev/null
+++ b/WebCore/platform/network/android/ResourceRequest.h
@@ -0,0 +1,93 @@
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ResourceRequest_h
+#define ResourceRequest_h
+
+#include "CachedResource.h"
+#include "ResourceRequestBase.h"
+
+namespace WebCore {
+
+ struct ResourceRequest : ResourceRequestBase {
+
+ ResourceRequest(const String& url)
+ : ResourceRequestBase(KURL(url.deprecatedString()), UseProtocolCachePolicy)
+ , m_cachedResource(0)
+#ifdef ANDROID_USER_GESTURE
+ , m_wasUserGesture(false)
+#endif
+ {
+ }
+
+ ResourceRequest(const KURL& url)
+ : ResourceRequestBase(url, UseProtocolCachePolicy)
+ , m_cachedResource(0)
+#ifdef ANDROID_USER_GESTURE
+ , m_wasUserGesture(false)
+#endif
+ {
+ }
+
+ ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
+ : ResourceRequestBase(url, policy)
+ , m_cachedResource(0)
+#ifdef ANDROID_USER_GESTURE
+ , m_wasUserGesture(false)
+#endif
+ {
+ setHTTPReferrer(referrer);
+ }
+
+ ResourceRequest()
+ : ResourceRequestBase(KURL(), UseProtocolCachePolicy)
+ , m_cachedResource(0)
+#ifdef ANDROID_USER_GESTURE
+ , m_wasUserGesture(false)
+#endif
+ {
+ }
+
+ void doUpdatePlatformRequest() {}
+ void doUpdateResourceRequest() {}
+ void setCachedResource(CachedResource* r) { m_cachedResource = r; }
+ CachedResource* getCachedResource() const { return m_cachedResource; }
+#ifdef ANDROID_USER_GESTURE
+ void setUserGesture(bool userGesture) { m_wasUserGesture = userGesture; }
+ bool userGesture() const { return m_wasUserGesture; }
+#endif
+ private:
+ friend class ResourceRequestBase;
+ CachedResource* m_cachedResource;
+#ifdef ANDROID_USER_GESTURE
+ bool m_wasUserGesture;
+#endif
+ };
+
+} // namespace WebCore
+
+#endif // ResourceRequest_h
diff --git a/WebCore/platform/network/android/ResourceResponse.h b/WebCore/platform/network/android/ResourceResponse.h
new file mode 100644
index 0000000..94c93f5
--- /dev/null
+++ b/WebCore/platform/network/android/ResourceResponse.h
@@ -0,0 +1,60 @@
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ResourceResponse_h
+#define ResourceResponse_h
+
+#include "ResourceResponseBase.h"
+
+#include "NotImplemented.h"
+
+namespace WebCore {
+
+class ResourceResponse : public ResourceResponseBase {
+public:
+ ResourceResponse()
+ : ResourceResponseBase()
+ {
+ }
+
+ ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
+ : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename)
+ {
+ }
+
+private:
+ friend class ResourceResponseBase;
+
+ void doUpdateResourceResponse()
+ {
+ notImplemented();
+ }
+
+};
+
+} // namespace WebCore
+
+#endif // ResourceResponse_h