diff options
author | Kristian Monsen <kristianm@google.com> | 2011-01-31 11:54:24 +0000 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-01-31 12:00:31 +0000 |
commit | b8b26c5e77b4fbb26af6b3d674df18d06c985c20 (patch) | |
tree | adf78ffefee01ac9eb0141265cb50888101a30f7 /WebKit | |
parent | c36054aacf610538d595ecc02cfbef4e6678eaa7 (diff) | |
download | external_webkit-b8b26c5e77b4fbb26af6b3d674df18d06c985c20.zip external_webkit-b8b26c5e77b4fbb26af6b3d674df18d06c985c20.tar.gz external_webkit-b8b26c5e77b4fbb26af6b3d674df18d06c985c20.tar.bz2 |
Fix for bug 2864795, pausing plugin network traffic.
Change-Id: I1f9239af23d6c88883b620ba0cfdc1c66dddf03d
Diffstat (limited to 'WebKit')
-rw-r--r-- | WebKit/android/WebCoreSupport/WebRequest.cpp | 27 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/WebRequest.h | 3 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp | 6 |
3 files changed, 35 insertions, 1 deletions
diff --git a/WebKit/android/WebCoreSupport/WebRequest.cpp b/WebKit/android/WebCoreSupport/WebRequest.cpp index 3dc986d..9d7a88e 100644 --- a/WebKit/android/WebCoreSupport/WebRequest.cpp +++ b/WebKit/android/WebCoreSupport/WebRequest.cpp @@ -69,6 +69,8 @@ WebRequest::WebRequest(WebUrlLoaderClient* loader, const WebResourceRequest& web , m_authRequestCount(0) , m_cacheMode(0) , m_runnableFactory(this) + , m_wantToPause(false) + , m_isPaused(false) { GURL gurl(m_url); @@ -92,7 +94,8 @@ WebRequest::WebRequest(WebUrlLoaderClient* loader, const WebResourceRequest& web , m_authRequestCount(0) , m_cacheMode(0) , m_runnableFactory(this) - + , m_wantToPause(false) + , m_isPaused(false) { } @@ -220,6 +223,21 @@ void WebRequest::cancel() finish(true); } +void WebRequest::pauseLoad(bool pause) +{ + ASSERT(m_loadState >= GotData, "PauseLoad in state other than RESPONSE and GOTDATA"); + if (pause) { + if (!m_isPaused) + m_wantToPause = true; + } else { + m_wantToPause = false; + if (m_isPaused) { + m_isPaused = false; + MessageLoop::current()->PostTask(FROM_HERE, m_runnableFactory.NewRunnableMethod(&WebRequest::startReading)); + } + } +} + void WebRequest::handleInterceptedURL() { m_loadState = Response; @@ -417,10 +435,17 @@ void WebRequest::cancelSslCertError(int cert_error) void WebRequest::startReading() { + ASSERT(m_networkBuffer == 0, "startReading called with a nonzero buffer"); + ASSERT(m_isPaused == 0, "startReading called in paused state"); ASSERT(m_loadState == Response || m_loadState == GotData, "StartReading in state other than RESPONSE and GOTDATA"); if (m_loadState > GotData) // We have been cancelled between reads return; + if (m_wantToPause) { + m_isPaused = true; + return; + } + int bytesRead = 0; if (!read(&bytesRead)) { diff --git a/WebKit/android/WebCoreSupport/WebRequest.h b/WebKit/android/WebCoreSupport/WebRequest.h index 7fb614f..ae386fd 100644 --- a/WebKit/android/WebCoreSupport/WebRequest.h +++ b/WebKit/android/WebCoreSupport/WebRequest.h @@ -69,6 +69,7 @@ public: void setRequestContext(WebRequestContext* context); void start(); void cancel(); + void pauseLoad(bool pause); // From URLRequest::Delegate virtual void OnReceivedRedirect(URLRequest*, const GURL&, bool* deferRedirect); @@ -110,6 +111,8 @@ private: int m_authRequestCount; int m_cacheMode; ScopedRunnableMethodFactory<WebRequest> m_runnableFactory; + bool m_wantToPause; + bool m_isPaused; }; } // namespace android diff --git a/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp index 864dc30..5c54000 100644 --- a/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp +++ b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp @@ -251,6 +251,12 @@ void WebUrlLoaderClient::cancel() void WebUrlLoaderClient::pauseLoad(bool pause) { + if (!isActive()) + return; + + base::Thread* thread = ioThread(); + if (thread) + thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::pauseLoad, pause)); } void WebUrlLoaderClient::setAuth(const std::string& username, const std::string& password) |