summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebCore/platform/network/ResourceHandleInternal.h6
-rw-r--r--WebCore/platform/network/android/ResourceHandleAndroid.cpp24
-rw-r--r--WebCore/platform/network/android/ResourceLoaderAndroid.h53
-rw-r--r--WebKit/Android.mk1
-rw-r--r--WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp3
-rw-r--r--WebKit/android/WebCoreSupport/ResourceLoaderAndroid.cpp50
-rw-r--r--WebKit/android/benchmark/Intercept.cpp41
-rw-r--r--WebKit/android/benchmark/Intercept.h11
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.cpp6
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.h5
-rw-r--r--WebKit/android/jni/WebCoreResourceLoader.cpp5
-rw-r--r--WebKit/android/jni/WebCoreResourceLoader.h15
12 files changed, 166 insertions, 54 deletions
diff --git a/WebCore/platform/network/ResourceHandleInternal.h b/WebCore/platform/network/ResourceHandleInternal.h
index 31d740a..fa939db 100644
--- a/WebCore/platform/network/ResourceHandleInternal.h
+++ b/WebCore/platform/network/ResourceHandleInternal.h
@@ -69,9 +69,7 @@ class NSURLConnection;
#endif
#if PLATFORM(ANDROID)
-namespace android {
- class WebCoreResourceLoader;
-}
+#include "ResourceLoaderAndroid.h"
#endif
// The allocations and releases in ResourceHandleInternal are
@@ -229,7 +227,7 @@ namespace WebCore {
CFURLAuthChallengeRef m_currentCFChallenge;
#endif
#if PLATFORM(ANDROID)
- android::WebCoreResourceLoader* m_loader;
+ RefPtr<ResourceLoaderAndroid> m_loader;
#endif
AuthenticationChallenge m_currentWebChallenge;
diff --git a/WebCore/platform/network/android/ResourceHandleAndroid.cpp b/WebCore/platform/network/android/ResourceHandleAndroid.cpp
index 639582c..d5d5e5c 100644
--- a/WebCore/platform/network/android/ResourceHandleAndroid.cpp
+++ b/WebCore/platform/network/android/ResourceHandleAndroid.cpp
@@ -26,27 +26,23 @@
#define LOG_TAG "WebCore"
#include "config.h"
+
#include "ResourceHandle.h"
+#include "CString.h"
#include "DocLoader.h"
#include "DocumentLoader.h"
#include "Frame.h"
#include "FrameLoader.h"
-#include "FrameLoaderClientAndroid.h"
#include "NotImplemented.h"
#include "ResourceHandleClient.h"
#include "ResourceHandleInternal.h"
-#include "WebCoreFrameBridge.h"
-#include "WebCoreResourceLoader.h"
-#include "CString.h"
-
-using namespace android;
+#include "ResourceLoaderAndroid.h"
namespace WebCore {
ResourceHandleInternal::~ResourceHandleInternal()
{
- Release(m_loader);
}
ResourceHandle::~ResourceHandle()
@@ -58,16 +54,15 @@ bool ResourceHandle::start(Frame* frame)
DocumentLoader* adl = frame->loader()->activeDocumentLoader();
bool isMainResource =
((void*) client()) == ((void*) adl->mainResourceLoader());
- WebCoreResourceLoader* loader;
- FrameLoaderClientAndroid* client = static_cast<FrameLoaderClientAndroid*> (frame->loader()->client());
- loader = client->webFrame()->startLoadingResource(this, d->m_request, isMainResource, false);
+
+ PassRefPtr<ResourceLoaderAndroid> loader = ResourceLoaderAndroid::start(this, d->m_request, frame->loader()->client(), isMainResource, false);
if (loader) {
- Release(d->m_loader);
d->m_loader = loader;
+ return true;
}
- return loader != NULL;
+ return false;
}
void ResourceHandle::cancel()
@@ -104,7 +99,7 @@ bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame*)
// network/mac/ResourceHandleMac.mm
request.setCachePolicy(ReturnCacheDataDontLoad);
FormData* formData = request.httpBody();
- return WebCoreResourceLoader::willLoadFromCache(request.url(), formData ? formData->identifier() : 0);
+ return ResourceLoaderAndroid::willLoadFromCache(request.url(), formData ? formData->identifier() : 0);
}
bool ResourceHandle::loadsBlocked()
@@ -150,8 +145,7 @@ void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request,
SyncLoader s(error, response, data);
ResourceHandle h(request, &s, false, false, false);
// This blocks until the load is finished.
- FrameLoaderClientAndroid* client = static_cast<FrameLoaderClientAndroid*> (frame->loader()->client());
- client->webFrame()->startLoadingResource(&h, request, false, true);
+ ResourceLoaderAndroid::start(&h, request, frame->loader()->client(), false, true);
}
} // namespace WebCore
diff --git a/WebCore/platform/network/android/ResourceLoaderAndroid.h b/WebCore/platform/network/android/ResourceLoaderAndroid.h
new file mode 100644
index 0000000..004675e
--- /dev/null
+++ b/WebCore/platform/network/android/ResourceLoaderAndroid.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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 ResourceLoaderAndroid_h
+#define ResourceLoaderAndroid_h
+
+#include <ResourceRequest.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class FrameLoaderClient;
+class ResourceHandle;
+
+class ResourceLoaderAndroid : public RefCounted<ResourceLoaderAndroid> {
+public:
+ static PassRefPtr<ResourceLoaderAndroid> start(ResourceHandle*, const ResourceRequest&, FrameLoaderClient*, bool isMainResource, bool isSync);
+ virtual ~ResourceLoaderAndroid() { }
+
+ virtual void cancel() = 0;
+ virtual void downloadFile() = 0;
+
+ // Call to java to find out if this URL is in the cache
+ static bool willLoadFromCache(const WebCore::KURL&, int64_t identifier);
+protected:
+ ResourceLoaderAndroid() { }
+};
+
+}
+#endif // ResourceLoaderAndroid
diff --git a/WebKit/Android.mk b/WebKit/Android.mk
index 814c503..f6186ca 100644
--- a/WebKit/Android.mk
+++ b/WebKit/Android.mk
@@ -25,6 +25,7 @@ LOCAL_SRC_FILES := \
android/WebCoreSupport/GeolocationPermissions.cpp \
android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp \
android/WebCoreSupport/PlatformBridge.cpp \
+ android/WebCoreSupport/ResourceLoaderAndroid.cpp \
\
android/RenderSkinAndroid.cpp \
android/RenderSkinButton.cpp \
diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
index 265dfb4..ae3d582 100644
--- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
@@ -870,8 +870,7 @@ bool FrameLoaderClientAndroid::canCachePage() const {
void FrameLoaderClientAndroid::download(ResourceHandle* handle, const ResourceRequest&,
const ResourceRequest&, const ResourceResponse&) {
// Get the C++ side of the load listener and tell it to handle the download
- WebCoreResourceLoader* loader = handle->getInternal()->m_loader;
- loader->downloadFile();
+ handle->getInternal()->m_loader->downloadFile();
}
WTF::PassRefPtr<WebCore::Frame> FrameLoaderClientAndroid::createFrame(const KURL& url, const String& name,
diff --git a/WebKit/android/WebCoreSupport/ResourceLoaderAndroid.cpp b/WebKit/android/WebCoreSupport/ResourceLoaderAndroid.cpp
new file mode 100644
index 0000000..2b2ad95
--- /dev/null
+++ b/WebKit/android/WebCoreSupport/ResourceLoaderAndroid.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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.
+ */
+
+#include <config.h>
+
+#include <ResourceLoaderAndroid.h>
+
+#include "FrameLoaderClientAndroid.h"
+#include "WebCoreFrameBridge.h"
+#include "WebCoreResourceLoader.h"
+
+using namespace android;
+
+namespace WebCore {
+
+PassRefPtr<ResourceLoaderAndroid> ResourceLoaderAndroid::start(
+ ResourceHandle* handle, const ResourceRequest& request, FrameLoaderClient* client, bool isMainResource, bool isSync)
+{
+ FrameLoaderClientAndroid* clientAndroid = static_cast<FrameLoaderClientAndroid*> (client);
+ return clientAndroid->webFrame()->startLoadingResource(handle, request, isMainResource, isSync);
+}
+
+bool ResourceLoaderAndroid::willLoadFromCache(const WebCore::KURL& url, int64_t identifier)
+{
+ return WebCoreResourceLoader::willLoadFromCache(url, identifier);
+}
+
+}
diff --git a/WebKit/android/benchmark/Intercept.cpp b/WebKit/android/benchmark/Intercept.cpp
index 90cf1e1..d657353 100644
--- a/WebKit/android/benchmark/Intercept.cpp
+++ b/WebKit/android/benchmark/Intercept.cpp
@@ -39,14 +39,21 @@
#include <utils/Log.h>
#include <wtf/HashMap.h>
-void MyResourceLoader::handleRequest() {
+PassRefPtr<MyResourceLoader> MyResourceLoader::create(ResourceHandle* handle, String url)
+{
+ return adoptRef(new MyResourceLoader(handle, url));
+}
+
+void MyResourceLoader::handleRequest()
+{
if (protocolIs(m_url, "data"))
loadData(m_url.substring(5)); // 5 for data:
else if (protocolIs(m_url, "file"))
loadFile(m_url.substring(7)); // 7 for file://
}
-void MyResourceLoader::loadData(const String& data) {
+void MyResourceLoader::loadData(const String& data)
+{
LOGD("Loading data (%s) ...", data.latin1().data());
ResourceHandleClient* client = m_handle->client();
int index = data.find(',');
@@ -105,7 +112,8 @@ void MyResourceLoader::loadData(const String& data) {
}
client->didFinishLoading(m_handle);
}
-static String mimeTypeForExtension(const String& file) {
+static String mimeTypeForExtension(const String& file)
+{
static HashMap<String, String, CaseFoldingHash> extensionToMime;
if (extensionToMime.isEmpty()) {
extensionToMime.set("txt", "text/plain");
@@ -128,7 +136,8 @@ static String mimeTypeForExtension(const String& file) {
return mime;
}
-void MyResourceLoader::loadFile(const String& file) {
+void MyResourceLoader::loadFile(const String& file)
+{
LOGD("Loading file (%s) ...", file.latin1().data());
FILE* f = fopen(file.latin1().data(), "r");
ResourceHandleClient* client = m_handle->client();
@@ -152,25 +161,25 @@ void MyResourceLoader::loadFile(const String& file) {
}
}
-WebCoreResourceLoader* MyWebFrame::startLoadingResource(ResourceHandle* handle,
- const ResourceRequest& req, bool ignore) {
- MyResourceLoader* loader = new MyResourceLoader(handle, req.url().string());
- Retain(loader);
+PassRefPtr<MyResourceLoader> MyWebFrame::startLoadingResource(ResourceHandle* handle,
+ const ResourceRequest& req, bool ignore)
+{
+ RefPtr<MyResourceLoader> loader = MyResourceLoader::create(handle, req.url().string());
m_requests.append(loader);
if (!m_timer.isActive())
m_timer.startOneShot(0);
- return loader;
+ return loader.release();
}
-void MyWebFrame::timerFired(Timer<MyWebFrame>*) {
+void MyWebFrame::timerFired(Timer<MyWebFrame>*)
+{
LOGD("Handling requests...");
- Vector<MyResourceLoader*> reqs;
+ Vector<RefPtr<MyResourceLoader> > reqs;
reqs.swap(m_requests);
- Vector<MyResourceLoader*>::iterator i = reqs.begin();
- Vector<MyResourceLoader*>::iterator end = reqs.end();
- for (; i != end; i++) {
+ Vector<RefPtr<MyResourceLoader> >::iterator i = reqs.begin();
+ Vector<RefPtr<MyResourceLoader> >::iterator end = reqs.end();
+ for (; i != end; i++)
(*i)->handleRequest();
- Release(*i);
- }
+
LOGD("...done");
}
diff --git a/WebKit/android/benchmark/Intercept.h b/WebKit/android/benchmark/Intercept.h
index 2ae7f7b..6981e51 100644
--- a/WebKit/android/benchmark/Intercept.h
+++ b/WebKit/android/benchmark/Intercept.h
@@ -46,14 +46,15 @@ using namespace WTF;
class MyResourceLoader : public WebCoreResourceLoader {
public:
+ static PassRefPtr<MyResourceLoader> create(ResourceHandle* handle, String url);
+ void handleRequest();
+
+private:
MyResourceLoader(ResourceHandle* handle, String url)
: WebCoreResourceLoader(JSC::Bindings::getJNIEnv(), MY_JOBJECT)
, m_handle(handle)
, m_url(url) {}
- void handleRequest();
-
-private:
void loadData(const String&);
void loadFile(const String&);
ResourceHandle* m_handle;
@@ -66,14 +67,14 @@ public:
: WebFrame(JSC::Bindings::getJNIEnv(), MY_JOBJECT, MY_JOBJECT, page)
, m_timer(this, &MyWebFrame::timerFired) {}
- virtual WebCoreResourceLoader* startLoadingResource(ResourceHandle* handle,
+ virtual PassRefPtr<MyResourceLoader> startLoadingResource(ResourceHandle* handle,
const ResourceRequest& req, bool);
virtual bool canHandleRequest(const ResourceRequest&) { return true; }
private:
void timerFired(Timer<MyWebFrame>*);
- Vector<MyResourceLoader*> m_requests;
+ Vector<RefPtr<MyResourceLoader> > m_requests;
Timer<MyWebFrame> m_timer;
};
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp
index 646c5b8..f25e4a6 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -320,7 +320,7 @@ private:
int m_size;
};
-WebCoreResourceLoader*
+PassRefPtr<WebCore::ResourceLoaderAndroid>
WebFrame::startLoadingResource(WebCore::ResourceHandle* loader,
const WebCore::ResourceRequest& request,
bool mainResource,
@@ -454,9 +454,9 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader,
if (checkException(env))
return NULL;
- WebCoreResourceLoader* h = NULL;
+ PassRefPtr<WebCore::ResourceLoaderAndroid> h;
if (jLoadListener)
- h = new WebCoreResourceLoader(env, jLoadListener);
+ h = WebCoreResourceLoader::create(env, jLoadListener);
env->DeleteLocalRef(jLoadListener);
return h;
}
diff --git a/WebKit/android/jni/WebCoreFrameBridge.h b/WebKit/android/jni/WebCoreFrameBridge.h
index 1fdf140..7d18c40 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.h
+++ b/WebKit/android/jni/WebCoreFrameBridge.h
@@ -32,6 +32,7 @@
#include "PlatformString.h"
#include "WebCoreRefObject.h"
#include <jni.h>
+#include <wtf/RefCounted.h>
namespace WebCore {
class HistoryItem;
@@ -39,12 +40,12 @@ namespace WebCore {
class Page;
class RenderPart;
class ResourceHandle;
+ class ResourceLoaderAndroid;
class ResourceRequest;
}
namespace android {
-class WebCoreResourceLoader;
class WebViewCore;
// one instance of WebFrame per Page for calling into Java's BrowserFrame
@@ -62,7 +63,7 @@ class WebFrame : public WebCoreRefObject {
// helper function
static WebFrame* getWebFrame(const WebCore::Frame* frame);
- virtual WebCoreResourceLoader* startLoadingResource(WebCore::ResourceHandle*,
+ virtual PassRefPtr<WebCore::ResourceLoaderAndroid> startLoadingResource(WebCore::ResourceHandle*,
const WebCore::ResourceRequest& request, bool mainResource,
bool synchronous);
diff --git a/WebKit/android/jni/WebCoreResourceLoader.cpp b/WebKit/android/jni/WebCoreResourceLoader.cpp
index fa8040a..55af52d 100644
--- a/WebKit/android/jni/WebCoreResourceLoader.cpp
+++ b/WebKit/android/jni/WebCoreResourceLoader.cpp
@@ -68,6 +68,11 @@ static struct resourceloader_t {
//-----------------------------------------------------------------------------
// ResourceLoadHandler
+PassRefPtr<WebCore::ResourceLoaderAndroid> WebCoreResourceLoader::create(JNIEnv *env, jobject jLoadListener)
+{
+ return adoptRef<WebCore::ResourceLoaderAndroid>(new WebCoreResourceLoader(env, jLoadListener));
+}
+
WebCoreResourceLoader::WebCoreResourceLoader(JNIEnv *env, jobject jLoadListener)
{
mJLoader = env->NewGlobalRef(jLoadListener);
diff --git a/WebKit/android/jni/WebCoreResourceLoader.h b/WebKit/android/jni/WebCoreResourceLoader.h
index 8a4d8d8..d24a43e 100644
--- a/WebKit/android/jni/WebCoreResourceLoader.h
+++ b/WebKit/android/jni/WebCoreResourceLoader.h
@@ -26,29 +26,28 @@
#ifndef ANDROID_WEBKIT_RESOURCELOADLISTENER_H
#define ANDROID_WEBKIT_RESOURCELOADLISTENER_H
-#include "KURL.h"
-
-#include "WebCoreRefObject.h"
+#include <KURL.h>
+#include <ResourceLoaderAndroid.h>
#include <jni.h>
namespace android {
-class WebCoreResourceLoader : public WebCoreRefObject
+class WebCoreResourceLoader : public WebCore::ResourceLoaderAndroid
{
public:
- WebCoreResourceLoader(JNIEnv *env, jobject jLoadListener);
+ static PassRefPtr<WebCore::ResourceLoaderAndroid> create(JNIEnv *env, jobject jLoadListener);
virtual ~WebCoreResourceLoader();
/**
* Call to java to cancel the current load.
*/
- void cancel();
+ virtual void cancel();
/**
* Call to java to download the current load rather than feed it
* back to WebCore
*/
- void downloadFile();
+ virtual void downloadFile();
/**
* Call to java to find out if this URL is in the cache
@@ -65,6 +64,8 @@ public:
static jstring RedirectedToUrl(JNIEnv*, jobject, jstring, jstring, jint);
static void Error(JNIEnv*, jobject, jint, jstring, jstring);
+protected:
+ WebCoreResourceLoader(JNIEnv *env, jobject jLoadListener);
private:
jobject mJLoader;
};