summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-03-12 20:46:03 +0000
committerBen Murdoch <benm@google.com>2010-03-22 20:50:51 +0000
commita923424180b9d2cbe3a3951caed13039eef1edf6 (patch)
tree94c79707c7425deaee1f53e35512bd3760e6c8e9
parent343ec940062f940a47d74fc359b661de8be2f3b8 (diff)
downloadexternal_webkit-a923424180b9d2cbe3a3951caed13039eef1edf6.zip
external_webkit-a923424180b9d2cbe3a3951caed13039eef1edf6.tar.gz
external_webkit-a923424180b9d2cbe3a3951caed13039eef1edf6.tar.bz2
Add a new API on the resource loader to pause the current load. We use this when the plugin cannot accept any more data to prevent WebKit
buffering the data that the plugin can't take. This can result in a crash if the buffer gets too big (when watching an HD movie clip in flash, for example). Requires a frameworks/base change. Change-Id: Ibb63d38df1014ff70fa4d65275613cbf3a217c1a
-rw-r--r--WebCore/loader/ResourceLoader.cpp9
-rw-r--r--WebCore/loader/ResourceLoader.h4
-rw-r--r--WebCore/platform/network/ResourceHandle.h6
-rw-r--r--WebCore/platform/network/android/ResourceHandleAndroid.cpp9
-rw-r--r--WebCore/platform/network/android/ResourceLoaderAndroid.h3
-rw-r--r--WebCore/plugins/PluginStream.cpp10
-rw-r--r--WebKit/android/jni/WebCoreResourceLoader.cpp18
-rw-r--r--WebKit/android/jni/WebCoreResourceLoader.h3
8 files changed, 61 insertions, 1 deletions
diff --git a/WebCore/loader/ResourceLoader.cpp b/WebCore/loader/ResourceLoader.cpp
index 95ce209..d14afc8 100644
--- a/WebCore/loader/ResourceLoader.cpp
+++ b/WebCore/loader/ResourceLoader.cpp
@@ -149,6 +149,15 @@ void ResourceLoader::setDefersLoading(bool defers)
}
}
+#if PLATFORM(ANDROID)
+// TODO: This needs upstreaming to WebKit.
+void ResourceLoader::pauseLoad(bool pause)
+{
+ if (m_handle)
+ m_handle->pauseLoad(pause);
+}
+#endif
+
FrameLoader* ResourceLoader::frameLoader() const
{
if (!m_frame)
diff --git a/WebCore/loader/ResourceLoader.h b/WebCore/loader/ResourceLoader.h
index 5239289..3178eb4 100644
--- a/WebCore/loader/ResourceLoader.h
+++ b/WebCore/loader/ResourceLoader.h
@@ -64,6 +64,10 @@ namespace WebCore {
ResourceError cannotShowURLError();
virtual void setDefersLoading(bool);
+#if PLATFORM(ANDROID)
+// TODO: This needs upstreaming to WebKit.
+ virtual void pauseLoad(bool);
+#endif
void setIdentifier(unsigned long identifier) { m_identifier = identifier; }
unsigned long identifier() const { return m_identifier; }
diff --git a/WebCore/platform/network/ResourceHandle.h b/WebCore/platform/network/ResourceHandle.h
index b764add..e340aca 100644
--- a/WebCore/platform/network/ResourceHandle.h
+++ b/WebCore/platform/network/ResourceHandle.h
@@ -189,7 +189,11 @@ public:
void setClient(ResourceHandleClient*);
void setDefersLoading(bool);
-
+#if PLATFORM(ANDROID)
+// TODO: this needs upstreaming.
+ void pauseLoad(bool);
+#endif
+
const ResourceRequest& request() const;
void fireFailure(Timer<ResourceHandle>*);
diff --git a/WebCore/platform/network/android/ResourceHandleAndroid.cpp b/WebCore/platform/network/android/ResourceHandleAndroid.cpp
index 1154b47..6759852 100644
--- a/WebCore/platform/network/android/ResourceHandleAndroid.cpp
+++ b/WebCore/platform/network/android/ResourceHandleAndroid.cpp
@@ -84,6 +84,15 @@ bool ResourceHandle::supportsBufferedData()
return false;
}
+#if PLATFORM(ANDROID)
+// TODO: this needs upstreaming.
+void ResourceHandle::pauseLoad(bool pause)
+{
+ if (d->m_loader)
+ d->m_loader->pauseLoad(pause);
+}
+#endif
+
void ResourceHandle::setDefersLoading(bool defers)
{
notImplemented();
diff --git a/WebCore/platform/network/android/ResourceLoaderAndroid.h b/WebCore/platform/network/android/ResourceLoaderAndroid.h
index 004675e..f627d62 100644
--- a/WebCore/platform/network/android/ResourceLoaderAndroid.h
+++ b/WebCore/platform/network/android/ResourceLoaderAndroid.h
@@ -42,6 +42,9 @@ public:
virtual void cancel() = 0;
virtual void downloadFile() = 0;
+ // ANDROID TODO: This needs to be upstreamed.
+ virtual void pauseLoad(bool) = 0;
+ // END ANDROID TODO
// Call to java to find out if this URL is in the cache
static bool willLoadFromCache(const WebCore::KURL&, int64_t identifier);
diff --git a/WebCore/plugins/PluginStream.cpp b/WebCore/plugins/PluginStream.cpp
index bf35ba4..1e91c51 100644
--- a/WebCore/plugins/PluginStream.cpp
+++ b/WebCore/plugins/PluginStream.cpp
@@ -345,6 +345,11 @@ void PluginStream::deliverData()
int32 deliveryBytes = m_pluginFuncs->writeready(m_instance, &m_stream);
if (deliveryBytes <= 0) {
+#if PLATFORM(ANDROID)
+// TODO: This needs to be upstreamed.
+ if (m_loader)
+ m_loader->pauseLoad(true);
+#endif
m_delayDeliveryTimer.startOneShot(0);
break;
} else {
@@ -373,6 +378,11 @@ void PluginStream::deliverData()
memmove(m_deliveryData->data(), m_deliveryData->data() + totalBytesDelivered, remainingBytes);
m_deliveryData->resize(remainingBytes);
} else {
+#if PLATFORM(ANDROID)
+//TODO: This needs to be upstreamed to WebKit.
+ if (m_loader)
+ m_loader->pauseLoad(false);
+#endif
m_deliveryData->resize(0);
if (m_reason != WebReasonNone)
destroyStream();
diff --git a/WebKit/android/jni/WebCoreResourceLoader.cpp b/WebKit/android/jni/WebCoreResourceLoader.cpp
index b17c9a7..cf32c09 100644
--- a/WebKit/android/jni/WebCoreResourceLoader.cpp
+++ b/WebKit/android/jni/WebCoreResourceLoader.cpp
@@ -56,6 +56,7 @@ static struct resourceloader_t {
jmethodID mCancelMethodID;
jmethodID mDownloadFileMethodID;
jmethodID mWillLoadFromCacheMethodID;
+ jmethodID mPauseLoadMethodID;
} gResourceLoader;
// ----------------------------------------------------------------------------
@@ -72,6 +73,7 @@ PassRefPtr<WebCore::ResourceLoaderAndroid> WebCoreResourceLoader::create(JNIEnv
}
WebCoreResourceLoader::WebCoreResourceLoader(JNIEnv *env, jobject jLoadListener)
+ : mPausedLoad(false)
{
mJLoader = env->NewGlobalRef(jLoadListener);
}
@@ -98,6 +100,17 @@ void WebCoreResourceLoader::downloadFile()
checkException(env);
}
+void WebCoreResourceLoader::pauseLoad(bool pause)
+{
+ if (mPausedLoad == pause)
+ return;
+
+ mPausedLoad = pause;
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ env->CallVoidMethod(mJLoader, gResourceLoader.mPauseLoadMethodID, pause);
+ checkException(env);
+}
+
/*
* This static method is called to check to see if a POST response is in
* the cache. This may be slow, but is only used during a navigation to
@@ -320,6 +333,11 @@ int register_resource_loader(JNIEnv* env)
LOG_FATAL_IF(gResourceLoader.mDownloadFileMethodID == NULL,
"Could not find method downloadFile on LoadListener");
+ gResourceLoader.mPauseLoadMethodID =
+ env->GetMethodID(resourceLoader, "pauseLoad", "(Z)V");
+ LOG_FATAL_IF(gResourceLoader.mPauseLoadMethodID == NULL,
+ "Could not find method pauseLoad on LoadListener");
+
gResourceLoader.mWillLoadFromCacheMethodID =
env->GetStaticMethodID(resourceLoader, "willLoadFromCache", "(Ljava/lang/String;J)Z");
LOG_FATAL_IF(gResourceLoader.mWillLoadFromCacheMethodID == NULL,
diff --git a/WebKit/android/jni/WebCoreResourceLoader.h b/WebKit/android/jni/WebCoreResourceLoader.h
index d24a43e..c60b3f5 100644
--- a/WebKit/android/jni/WebCoreResourceLoader.h
+++ b/WebKit/android/jni/WebCoreResourceLoader.h
@@ -49,6 +49,8 @@ public:
*/
virtual void downloadFile();
+ virtual void pauseLoad(bool);
+
/**
* Call to java to find out if this URL is in the cache
*/
@@ -68,6 +70,7 @@ protected:
WebCoreResourceLoader(JNIEnv *env, jobject jLoadListener);
private:
jobject mJLoader;
+ bool mPausedLoad;
};
} // end namespace android