summaryrefslogtreecommitdiffstats
path: root/chrome_frame/plugin_url_request.h
diff options
context:
space:
mode:
authorstoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-08 16:53:57 +0000
committerstoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-08 16:53:57 +0000
commit0ce46404deb06c137b2e2c253004c43cf42e8a70 (patch)
tree5a4026ada47051c2af1ccffe105a2d68a38ce77e /chrome_frame/plugin_url_request.h
parent3e59bacae6bff857dfb5e3d3e8359dbde60ccb04 (diff)
downloadchromium_src-0ce46404deb06c137b2e2c253004c43cf42e8a70.zip
chromium_src-0ce46404deb06c137b2e2c253004c43cf42e8a70.tar.gz
chromium_src-0ce46404deb06c137b2e2c253004c43cf42e8a70.tar.bz2
Move Urlmon network requests to UI thread, thus allowing reusing the bind context (and already fetched data) via INET_E_TERMINATED_BIND error code.
Make caching of data more sensible, so the UI does not freeze (the reason why url request have been moved to a background thread). Always return INET_E_TERMINATED_BIND on OnDataAvailable when BSCF_LASTDATANOTIFICATION flag is detected, so if a subsequent DownloadToHost request comes from Chrome, bind context and already fetched data can be reused. BUG=36694 Review URL: http://codereview.chromium.org/1523014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/plugin_url_request.h')
-rw-r--r--chrome_frame/plugin_url_request.h61
1 files changed, 3 insertions, 58 deletions
diff --git a/chrome_frame/plugin_url_request.h b/chrome_frame/plugin_url_request.h
index dbec76f..aea4fa8 100644
--- a/chrome_frame/plugin_url_request.h
+++ b/chrome_frame/plugin_url_request.h
@@ -21,67 +21,12 @@ class PluginUrlRequest;
class PluginUrlRequestDelegate;
class PluginUrlRequestManager;
-// A thread-safe ref-counted wrapper for the non-thread-safe ref-counted
-// net::UploadData. I'm trying to avoid making net::UploadData thread-safe
-// as it is a widely used data structure whose performance characteristics
-// I do not wish to change.
-class UploadDataThreadSafe
- : public base::RefCountedThreadSafe<UploadDataThreadSafe> {
- public:
- explicit UploadDataThreadSafe(net::UploadData* upload_data) {
- DCHECK(upload_data == NULL || upload_data->HasOneRef());
- upload_data_ = upload_data;
- }
-
- net::UploadData* get_data() {
- DCHECK(upload_data_.get() == NULL || upload_data_->HasOneRef());
- return upload_data_.get();
- }
-
- private:
- scoped_refptr<net::UploadData> upload_data_;
-};
-
-// A class that can be used in place of an IPC::AutomationUrlRequest but can be
-// safely passed across threads. Note that this takes ownership of the
-// net::UploadData instance and that the instance must have a ref_count of
-// exactly 1 when this is called.
-class ThreadSafeAutomationUrlRequest {
- public:
- // Note that the constructor mutates the "const" ipc_request parameter.
- explicit ThreadSafeAutomationUrlRequest(
- const IPC::AutomationURLRequest& ipc_request)
- : url(ipc_request.url), method(ipc_request.method),
- referrer(ipc_request.referrer),
- extra_request_headers(ipc_request.extra_request_headers) {
- // Make sure that we have exactly one reference when taking ownership.
- net::UploadData* temp_data = const_cast<IPC::AutomationURLRequest&>(
- ipc_request).upload_data.release();
- DCHECK(temp_data == NULL || temp_data->HasOneRef());
-
- upload_data = new UploadDataThreadSafe(temp_data);
-
- if (temp_data) {
- temp_data->Release();
- }
- // Make sure that we have exactly one reference after taking ownership.
- DCHECK(temp_data == NULL || temp_data->HasOneRef());
- }
-
- std::string url;
- std::string method;
- std::string referrer;
- std::string extra_request_headers;
- scoped_refptr<UploadDataThreadSafe> upload_data;
-};
-
-
class DECLSPEC_NOVTABLE PluginUrlRequestDelegate { // NOLINT
public:
virtual void OnResponseStarted(int request_id, const char* mime_type,
const char* headers, int size, base::Time last_modified,
const std::string& redirect_url, int redirect_status) = 0;
- virtual void OnReadComplete(int request_id, const void* buffer, int len) = 0;
+ virtual void OnReadComplete(int request_id, const std::string& data) = 0;
virtual void OnResponseEnd(int request_id,
const URLRequestStatus& status) = 0;
virtual void AddPrivacyDataForUrl(const std::string& url,
@@ -116,7 +61,7 @@ class DECLSPEC_NOVTABLE PluginUrlRequestManager { // NOLINT
// derived classes.
void StartUrlRequest(int tab, int request_id,
const IPC::AutomationURLRequest& request_info) {
- StartRequest(request_id, ThreadSafeAutomationUrlRequest(request_info));
+ StartRequest(request_id, request_info);
}
void ReadUrlRequest(int tab, int request_id, int bytes_to_read) {
@@ -151,7 +96,7 @@ class DECLSPEC_NOVTABLE PluginUrlRequestManager { // NOLINT
private:
virtual void StartRequest(int request_id,
- const ThreadSafeAutomationUrlRequest& request_info) = 0;
+ const IPC::AutomationURLRequest& request_info) = 0;
virtual void ReadRequest(int request_id, int bytes_to_read) = 0;
virtual void EndRequest(int request_id) = 0;
virtual void DownloadRequestInHost(int request_id) = 0;