diff options
Diffstat (limited to 'chrome_frame/plugin_url_request.h')
-rw-r--r-- | chrome_frame/plugin_url_request.h | 61 |
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; |