diff options
28 files changed, 287 insertions, 553 deletions
diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc index 32f3729..0a19163 100644 --- a/content/browser/download/download_resource_handler.cc +++ b/content/browser/download/download_resource_handler.cc @@ -135,14 +135,12 @@ DownloadResourceHandler::DownloadResourceHandler( "Download in progress"); } -bool DownloadResourceHandler::OnUploadProgress(int request_id, - uint64 position, +bool DownloadResourceHandler::OnUploadProgress(uint64 position, uint64 size) { return true; } bool DownloadResourceHandler::OnRequestRedirected( - int request_id, const GURL& url, ResourceResponse* response, bool* defer) { @@ -154,7 +152,6 @@ bool DownloadResourceHandler::OnRequestRedirected( // Send the download creation information to the download thread. bool DownloadResourceHandler::OnResponseStarted( - int request_id, ResourceResponse* response, bool* defer) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); @@ -162,8 +159,7 @@ bool DownloadResourceHandler::OnResponseStarted( DCHECK(!on_response_started_called_); on_response_started_called_ = true; - VLOG(20) << __FUNCTION__ << "()" << DebugString() - << " request_id = " << request_id; + VLOG(20) << __FUNCTION__ << "()" << DebugString(); download_start_time_ = base::TimeTicks::Now(); // If it's a download, we don't want to poison the cache with it. @@ -279,22 +275,18 @@ void DownloadResourceHandler::CallStartedCB( started_cb_.Reset(); } -bool DownloadResourceHandler::OnWillStart(int request_id, - const GURL& url, - bool* defer) { +bool DownloadResourceHandler::OnWillStart(const GURL& url, bool* defer) { return true; } -bool DownloadResourceHandler::OnBeforeNetworkStart(int request_id, - const GURL& url, +bool DownloadResourceHandler::OnBeforeNetworkStart(const GURL& url, bool* defer) { return true; } // Create a new buffer, which will be handed to the download thread for file // writing and deletion. -bool DownloadResourceHandler::OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, +bool DownloadResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); @@ -309,8 +301,7 @@ bool DownloadResourceHandler::OnWillRead(int request_id, } // Pass the buffer to the download file writer. -bool DownloadResourceHandler::OnReadCompleted(int request_id, int bytes_read, - bool* defer) { +bool DownloadResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(read_buffer_.get()); @@ -350,14 +341,12 @@ bool DownloadResourceHandler::OnReadCompleted(int request_id, int bytes_read, } void DownloadResourceHandler::OnResponseCompleted( - int request_id, const net::URLRequestStatus& status, const std::string& security_info, bool* defer) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); int response_code = status.is_success() ? request()->GetResponseCode() : 0; VLOG(20) << __FUNCTION__ << "()" << DebugString() - << " request_id = " << request_id << " status.status() = " << status.status() << " status.error() = " << status.error() << " response_code = " << response_code; @@ -466,9 +455,7 @@ void DownloadResourceHandler::OnResponseCompleted( read_buffer_ = NULL; } -void DownloadResourceHandler::OnDataDownloaded( - int request_id, - int bytes_downloaded) { +void DownloadResourceHandler::OnDataDownloaded(int bytes_downloaded) { NOTREACHED(); } diff --git a/content/browser/download/download_resource_handler.h b/content/browser/download/download_resource_handler.h index fe1f64b..de6efef 100644 --- a/content/browser/download/download_resource_handler.h +++ b/content/browser/download/download_resource_handler.h @@ -15,7 +15,6 @@ #include "content/public/browser/download_manager.h" #include "content/public/browser/download_save_info.h" #include "content/public/browser/download_url_parameters.h" -#include "content/public/browser/global_request_id.h" namespace net { class URLRequest; @@ -47,47 +46,36 @@ class CONTENT_EXPORT DownloadResourceHandler const DownloadUrlParameters::OnStartedCallback& started_cb, scoped_ptr<DownloadSaveInfo> save_info); - virtual bool OnUploadProgress(int request_id, - uint64 position, - uint64 size) OVERRIDE; + virtual bool OnUploadProgress(uint64 position, uint64 size) OVERRIDE; - virtual bool OnRequestRedirected(int request_id, - const GURL& url, + virtual bool OnRequestRedirected(const GURL& url, ResourceResponse* response, bool* defer) OVERRIDE; // Send the download creation information to the download thread. - virtual bool OnResponseStarted(int request_id, - ResourceResponse* response, + virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) OVERRIDE; // Pass-through implementation. - virtual bool OnWillStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; + virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; // Pass-through implementation. - virtual bool OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; + virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) OVERRIDE; // Create a new buffer, which will be handed to the download thread for file // writing and deletion. - virtual bool OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, + virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) OVERRIDE; - virtual bool OnReadCompleted(int request_id, int bytes_read, - bool* defer) OVERRIDE; + virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE; - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& status, + virtual void OnResponseCompleted(const net::URLRequestStatus& status, const std::string& security_info, bool* defer) OVERRIDE; // N/A to this flavor of DownloadHandler. - virtual void OnDataDownloaded(int request_id, int bytes_downloaded) OVERRIDE; + virtual void OnDataDownloaded(int bytes_downloaded) OVERRIDE; void PauseRequest(); void ResumeRequest(); diff --git a/content/browser/download/save_file_resource_handler.cc b/content/browser/download/save_file_resource_handler.cc index 18abc7d..e1fc32b 100644 --- a/content/browser/download/save_file_resource_handler.cc +++ b/content/browser/download/save_file_resource_handler.cc @@ -15,11 +15,12 @@ namespace content { -SaveFileResourceHandler::SaveFileResourceHandler(int render_process_host_id, +SaveFileResourceHandler::SaveFileResourceHandler(net::URLRequest* request, + int render_process_host_id, int render_view_id, const GURL& url, SaveFileManager* manager) - : ResourceHandler(NULL), + : ResourceHandler(request), save_id_(-1), render_process_id_(render_process_host_id), render_view_id_(render_view_id), @@ -31,14 +32,11 @@ SaveFileResourceHandler::SaveFileResourceHandler(int render_process_host_id, SaveFileResourceHandler::~SaveFileResourceHandler() { } -bool SaveFileResourceHandler::OnUploadProgress(int request_id, - uint64 position, - uint64 size) { +bool SaveFileResourceHandler::OnUploadProgress(uint64 position, uint64 size) { return true; } bool SaveFileResourceHandler::OnRequestRedirected( - int request_id, const GURL& url, ResourceResponse* response, bool* defer) { @@ -46,10 +44,8 @@ bool SaveFileResourceHandler::OnRequestRedirected( return true; } -bool SaveFileResourceHandler::OnResponseStarted( - int request_id, - ResourceResponse* response, - bool* defer) { +bool SaveFileResourceHandler::OnResponseStarted(ResourceResponse* response, + bool* defer) { save_id_ = save_manager_->GetNextId(); // |save_manager_| consumes (deletes): SaveFileCreateInfo* info = new SaveFileCreateInfo; @@ -59,7 +55,7 @@ bool SaveFileResourceHandler::OnResponseStarted( info->save_id = save_id_; info->render_process_id = render_process_id_; info->render_view_id = render_view_id_; - info->request_id = request_id; + info->request_id = GetRequestID(); info->content_disposition = content_disposition_; info->save_source = SaveFileCreateInfo::SAVE_FILE_FROM_NET; BrowserThread::PostTask( @@ -68,20 +64,16 @@ bool SaveFileResourceHandler::OnResponseStarted( return true; } -bool SaveFileResourceHandler::OnWillStart(int request_id, - const GURL& url, - bool* defer) { +bool SaveFileResourceHandler::OnWillStart(const GURL& url, bool* defer) { return true; } -bool SaveFileResourceHandler::OnBeforeNetworkStart(int request_id, - const GURL& url, +bool SaveFileResourceHandler::OnBeforeNetworkStart(const GURL& url, bool* defer) { return true; } -bool SaveFileResourceHandler::OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, +bool SaveFileResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) { DCHECK(buf && buf_size); @@ -93,8 +85,7 @@ bool SaveFileResourceHandler::OnWillRead(int request_id, return true; } -bool SaveFileResourceHandler::OnReadCompleted(int request_id, int bytes_read, - bool* defer) { +bool SaveFileResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { DCHECK(read_buffer_.get()); // We are passing ownership of this buffer to the save file manager. scoped_refptr<net::IOBuffer> buffer; @@ -107,7 +98,6 @@ bool SaveFileResourceHandler::OnReadCompleted(int request_id, int bytes_read, } void SaveFileResourceHandler::OnResponseCompleted( - int request_id, const net::URLRequestStatus& status, const std::string& security_info, bool* defer) { @@ -118,9 +108,7 @@ void SaveFileResourceHandler::OnResponseCompleted( read_buffer_ = NULL; } -void SaveFileResourceHandler::OnDataDownloaded( - int request_id, - int bytes_downloaded) { +void SaveFileResourceHandler::OnDataDownloaded(int bytes_downloaded) { NOTREACHED(); } diff --git a/content/browser/download/save_file_resource_handler.h b/content/browser/download/save_file_resource_handler.h index fceaee9..5adbc5c 100644 --- a/content/browser/download/save_file_resource_handler.h +++ b/content/browser/download/save_file_resource_handler.h @@ -11,63 +11,57 @@ #include "content/browser/loader/resource_handler.h" #include "url/gurl.h" +namespace net { +class URLRequest; +} + namespace content { class SaveFileManager; // Forwards data to the save thread. class SaveFileResourceHandler : public ResourceHandler { public: - SaveFileResourceHandler(int render_process_host_id, + SaveFileResourceHandler(net::URLRequest* request, + int render_process_host_id, int render_view_id, const GURL& url, SaveFileManager* manager); virtual ~SaveFileResourceHandler(); // ResourceHandler Implementation: - virtual bool OnUploadProgress(int request_id, - uint64 position, - uint64 size) OVERRIDE; + virtual bool OnUploadProgress(uint64 position, uint64 size) OVERRIDE; // Saves the redirected URL to final_url_, we need to use the original // URL to match original request. - virtual bool OnRequestRedirected(int request_id, - const GURL& url, + virtual bool OnRequestRedirected(const GURL& url, ResourceResponse* response, bool* defer) OVERRIDE; // Sends the download creation information to the download thread. - virtual bool OnResponseStarted(int request_id, - ResourceResponse* response, + virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) OVERRIDE; // Pass-through implementation. - virtual bool OnWillStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; + virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; // Pass-through implementation. - virtual bool OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; + virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) OVERRIDE; // Creates a new buffer, which will be handed to the download thread for file // writing and deletion. - virtual bool OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, + virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) OVERRIDE; // Passes the buffer to the download file writer. - virtual bool OnReadCompleted(int request_id, int bytes_read, - bool* defer) OVERRIDE; + virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE; - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& status, + virtual void OnResponseCompleted(const net::URLRequestStatus& status, const std::string& security_info, bool* defer) OVERRIDE; // N/A to this flavor of SaveFileResourceHandler. - virtual void OnDataDownloaded(int request_id, int bytes_downloaded) OVERRIDE; + virtual void OnDataDownloaded(int bytes_downloaded) OVERRIDE; // If the content-length header is not present (or contains something other // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and diff --git a/content/browser/loader/async_resource_handler.cc b/content/browser/loader/async_resource_handler.cc index fbd8f14..69e831bd2 100644 --- a/content/browser/loader/async_resource_handler.cc +++ b/content/browser/loader/async_resource_handler.cc @@ -23,7 +23,6 @@ #include "content/browser/resource_context_impl.h" #include "content/common/resource_messages.h" #include "content/common/view_messages.h" -#include "content/public/browser/global_request_id.h" #include "content/public/browser/resource_dispatcher_host_delegate.h" #include "content/public/common/resource_response.h" #include "net/base/io_buffer.h" @@ -126,18 +125,16 @@ void AsyncResourceHandler::OnDataReceivedACK(int request_id) { } } -bool AsyncResourceHandler::OnUploadProgress(int request_id, - uint64 position, +bool AsyncResourceHandler::OnUploadProgress(uint64 position, uint64 size) { ResourceMessageFilter* filter = GetFilter(); if (!filter) return false; return filter->Send( - new ResourceMsg_UploadProgress(request_id, position, size)); + new ResourceMsg_UploadProgress(GetRequestID(), position, size)); } -bool AsyncResourceHandler::OnRequestRedirected(int request_id, - const GURL& new_url, +bool AsyncResourceHandler::OnRequestRedirected(const GURL& new_url, ResourceResponse* response, bool* defer) { const ResourceRequestInfoImpl* info = GetRequestInfo(); @@ -162,12 +159,11 @@ bool AsyncResourceHandler::OnRequestRedirected(int request_id, // and hopefully those will eventually all be owned by the browser. It's // possible this is still needed while renderer-owned ones exist. return info->filter()->Send(new ResourceMsg_ReceivedRedirect( - request_id, new_url, request()->first_party_for_cookies(), + GetRequestID(), new_url, request()->first_party_for_cookies(), response->head)); } -bool AsyncResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* response, +bool AsyncResourceHandler::OnResponseStarted(ResourceResponse* response, bool* defer) { // For changes to the main frame, inform the renderer of the new URL's // per-host settings before the request actually commits. This way the @@ -208,7 +204,7 @@ bool AsyncResourceHandler::OnResponseStarted(int request_id, response->head.request_start = request()->creation_time(); response->head.response_start = TimeTicks::Now(); - info->filter()->Send(new ResourceMsg_ReceivedResponse(request_id, + info->filter()->Send(new ResourceMsg_ReceivedResponse(GetRequestID(), response->head)); sent_received_response_msg_ = true; @@ -216,27 +212,22 @@ bool AsyncResourceHandler::OnResponseStarted(int request_id, std::vector<char> copy(request()->response_info().metadata->data(), request()->response_info().metadata->data() + request()->response_info().metadata->size()); - info->filter()->Send(new ResourceMsg_ReceivedCachedMetadata(request_id, + info->filter()->Send(new ResourceMsg_ReceivedCachedMetadata(GetRequestID(), copy)); } return true; } -bool AsyncResourceHandler::OnWillStart(int request_id, - const GURL& url, - bool* defer) { +bool AsyncResourceHandler::OnWillStart(const GURL& url, bool* defer) { return true; } -bool AsyncResourceHandler::OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) { +bool AsyncResourceHandler::OnBeforeNetworkStart(const GURL& url, bool* defer) { return true; } -bool AsyncResourceHandler::OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, +bool AsyncResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) { DCHECK_EQ(-1, min_size); @@ -257,8 +248,7 @@ bool AsyncResourceHandler::OnWillRead(int request_id, return true; } -bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, - bool* defer) { +bool AsyncResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { DCHECK_GE(bytes_read, 0); if (!bytes_read) @@ -283,7 +273,7 @@ bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, if (!buffer_->ShareToProcess(filter->PeerHandle(), &handle, &size)) return false; filter->Send(new ResourceMsg_SetDataBuffer( - request_id, handle, size, filter->peer_pid())); + GetRequestID(), handle, size, filter->peer_pid())); sent_first_data_msg_ = true; } @@ -294,7 +284,7 @@ bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, reported_transfer_size_ = current_transfer_size; filter->Send(new ResourceMsg_DataReceived( - request_id, data_offset, bytes_read, encoded_data_length)); + GetRequestID(), data_offset, bytes_read, encoded_data_length)); ++pending_data_count_; UMA_HISTOGRAM_CUSTOM_COUNTS( "Net.AsyncResourceHandler_PendingDataCount", @@ -311,8 +301,7 @@ bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, return true; } -void AsyncResourceHandler::OnDataDownloaded( - int request_id, int bytes_downloaded) { +void AsyncResourceHandler::OnDataDownloaded(int bytes_downloaded) { int64_t current_transfer_size = request()->GetTotalReceivedBytes(); int encoded_data_length = current_transfer_size - reported_transfer_size_; reported_transfer_size_ = current_transfer_size; @@ -320,12 +309,11 @@ void AsyncResourceHandler::OnDataDownloaded( ResourceMessageFilter* filter = GetFilter(); if (filter) { filter->Send(new ResourceMsg_DataDownloaded( - request_id, bytes_downloaded, encoded_data_length)); + GetRequestID(), bytes_downloaded, encoded_data_length)); } } void AsyncResourceHandler::OnResponseCompleted( - int request_id, const net::URLRequestStatus& status, const std::string& security_info, bool* defer) { @@ -375,7 +363,7 @@ void AsyncResourceHandler::OnResponseCompleted( request_complete_data.encoded_data_length = request()->GetTotalReceivedBytes(); info->filter()->Send( - new ResourceMsg_RequestComplete(request_id, request_complete_data)); + new ResourceMsg_RequestComplete(GetRequestID(), request_complete_data)); } bool AsyncResourceHandler::EnsureResourceBufferIsInitialized() { diff --git a/content/browser/loader/async_resource_handler.h b/content/browser/loader/async_resource_handler.h index 4d6aa50..b082119 100644 --- a/content/browser/loader/async_resource_handler.h +++ b/content/browser/loader/async_resource_handler.h @@ -35,35 +35,22 @@ class AsyncResourceHandler : public ResourceHandler, virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; // ResourceHandler implementation: - virtual bool OnUploadProgress(int request_id, - uint64 position, - uint64 size) OVERRIDE; - virtual bool OnRequestRedirected(int request_id, - const GURL& new_url, + virtual bool OnUploadProgress(uint64 position, uint64 size) OVERRIDE; + virtual bool OnRequestRedirected(const GURL& new_url, ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnResponseStarted(int request_id, - ResourceResponse* response, + virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnWillStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; - virtual bool OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; - virtual bool OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, + virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; + virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) OVERRIDE; + virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) OVERRIDE; - virtual bool OnReadCompleted(int request_id, - int bytes_read, - bool* defer) OVERRIDE; - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& status, + virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE; + virtual void OnResponseCompleted(const net::URLRequestStatus& status, const std::string& security_info, bool* defer) OVERRIDE; - virtual void OnDataDownloaded(int request_id, - int bytes_downloaded) OVERRIDE; + virtual void OnDataDownloaded(int bytes_downloaded) OVERRIDE; private: // IPC message handlers: diff --git a/content/browser/loader/buffered_resource_handler.cc b/content/browser/loader/buffered_resource_handler.cc index 97c260b..e8ea684 100644 --- a/content/browser/loader/buffered_resource_handler.cc +++ b/content/browser/loader/buffered_resource_handler.cc @@ -103,10 +103,8 @@ void BufferedResourceHandler::SetController(ResourceController* controller) { next_handler_->SetController(this); } -bool BufferedResourceHandler::OnResponseStarted( - int request_id, - ResourceResponse* response, - bool* defer) { +bool BufferedResourceHandler::OnResponseStarted(ResourceResponse* response, + bool* defer) { response_ = response; // TODO(darin): It is very odd to special-case 304 responses at this level. @@ -146,12 +144,11 @@ bool BufferedResourceHandler::OnResponseStarted( // We'll let the original event handler provide a buffer, and reuse it for // subsequent reads until we're done buffering. -bool BufferedResourceHandler::OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, +bool BufferedResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) { if (state_ == STATE_STREAMING) - return next_handler_->OnWillRead(request_id, buf, buf_size, min_size); + return next_handler_->OnWillRead(buf, buf_size, min_size); DCHECK_EQ(-1, min_size); @@ -160,7 +157,7 @@ bool BufferedResourceHandler::OnWillRead(int request_id, *buf = new DependentIOBuffer(read_buffer_.get(), bytes_read_); *buf_size = read_buffer_size_ - bytes_read_; } else { - if (!next_handler_->OnWillRead(request_id, buf, buf_size, min_size)) + if (!next_handler_->OnWillRead(buf, buf_size, min_size)) return false; read_buffer_ = *buf; @@ -170,10 +167,9 @@ bool BufferedResourceHandler::OnWillRead(int request_id, return true; } -bool BufferedResourceHandler::OnReadCompleted(int request_id, int bytes_read, - bool* defer) { +bool BufferedResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { if (state_ == STATE_STREAMING) - return next_handler_->OnReadCompleted(request_id, bytes_read, defer); + return next_handler_->OnReadCompleted(bytes_read, defer); DCHECK_EQ(state_, STATE_BUFFERING); bytes_read_ += bytes_read; @@ -186,7 +182,6 @@ bool BufferedResourceHandler::OnReadCompleted(int request_id, int bytes_read, } void BufferedResourceHandler::OnResponseCompleted( - int request_id, const net::URLRequestStatus& status, const std::string& security_info, bool* defer) { @@ -194,7 +189,7 @@ void BufferedResourceHandler::OnResponseCompleted( // handler defers OnResponseCompleted. state_ = STATE_STREAMING; - next_handler_->OnResponseCompleted(request_id, status, security_info, defer); + next_handler_->OnResponseCompleted(status, security_info, defer); } void BufferedResourceHandler::Resume() { @@ -242,7 +237,7 @@ bool BufferedResourceHandler::ProcessResponse(bool* defer) { state_ = STATE_REPLAYING; - if (!next_handler_->OnResponseStarted(GetRequestID(), response_.get(), defer)) + if (!next_handler_->OnResponseStarted(response_.get(), defer)) return false; if (!read_buffer_.get()) { @@ -369,21 +364,18 @@ bool BufferedResourceHandler::UseAlternateNextHandler( return false; } - int request_id = GetRequestID(); - // Inform the original ResourceHandler that this will be handled entirely by // the new ResourceHandler. // TODO(darin): We should probably check the return values of these. bool defer_ignored = false; - next_handler_->OnResponseStarted(request_id, response_.get(), &defer_ignored); + next_handler_->OnResponseStarted(response_.get(), &defer_ignored); // Although deferring OnResponseStarted is legal, the only downstream handler // which does so is CrossSiteResourceHandler. Cross-site transitions should // not trigger when switching handlers. DCHECK(!defer_ignored); net::URLRequestStatus status(net::URLRequestStatus::CANCELED, net::ERR_ABORTED); - next_handler_->OnResponseCompleted(request_id, status, std::string(), - &defer_ignored); + next_handler_->OnResponseCompleted(status, std::string(), &defer_ignored); DCHECK(!defer_ignored); // This is handled entirely within the new ResourceHandler, so just reset the @@ -391,14 +383,13 @@ bool BufferedResourceHandler::UseAlternateNextHandler( next_handler_ = new_handler.Pass(); next_handler_->SetController(this); - return CopyReadBufferToNextHandler(request_id); + return CopyReadBufferToNextHandler(); } bool BufferedResourceHandler::ReplayReadCompleted(bool* defer) { DCHECK(read_buffer_.get()); - bool result = next_handler_->OnReadCompleted(GetRequestID(), bytes_read_, - defer); + bool result = next_handler_->OnReadCompleted(bytes_read_, defer); read_buffer_ = NULL; read_buffer_size_ = 0; @@ -458,13 +449,13 @@ bool BufferedResourceHandler::HasSupportingPlugin(bool* stale) { #endif } -bool BufferedResourceHandler::CopyReadBufferToNextHandler(int request_id) { +bool BufferedResourceHandler::CopyReadBufferToNextHandler() { if (!read_buffer_.get()) return true; scoped_refptr<net::IOBuffer> buf; int buf_len = 0; - if (!next_handler_->OnWillRead(request_id, &buf, &buf_len, bytes_read_)) + if (!next_handler_->OnWillRead(&buf, &buf_len, bytes_read_)) return false; CHECK((buf_len >= bytes_read_) && (bytes_read_ >= 0)); diff --git a/content/browser/loader/buffered_resource_handler.h b/content/browser/loader/buffered_resource_handler.h index 23d15cc..a6ddff1 100644 --- a/content/browser/loader/buffered_resource_handler.h +++ b/content/browser/loader/buffered_resource_handler.h @@ -33,17 +33,13 @@ class BufferedResourceHandler private: // ResourceHandler implementation: virtual void SetController(ResourceController* controller) OVERRIDE; - virtual bool OnResponseStarted(int request_id, - ResourceResponse* response, + virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, + virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) OVERRIDE; - virtual bool OnReadCompleted(int request_id, int bytes_read, - bool* defer) OVERRIDE; - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& status, + virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE; + virtual void OnResponseCompleted(const net::URLRequestStatus& status, const std::string& security_info, bool* defer) OVERRIDE; @@ -67,7 +63,7 @@ class BufferedResourceHandler bool HasSupportingPlugin(bool* is_stale); // Copies data from |read_buffer_| to |next_handler_|. - bool CopyReadBufferToNextHandler(int request_id); + bool CopyReadBufferToNextHandler(); // Called on the IO thread once the list of plugins has been loaded. void OnPluginsLoaded(const std::vector<WebPluginInfo>& plugins); diff --git a/content/browser/loader/certificate_resource_handler.cc b/content/browser/loader/certificate_resource_handler.cc index 3c39599..2fe7cf9 100644 --- a/content/browser/loader/certificate_resource_handler.cc +++ b/content/browser/loader/certificate_resource_handler.cc @@ -29,43 +29,36 @@ CertificateResourceHandler::CertificateResourceHandler( CertificateResourceHandler::~CertificateResourceHandler() { } -bool CertificateResourceHandler::OnUploadProgress(int request_id, - uint64 position, - uint64 size) { +bool CertificateResourceHandler::OnUploadProgress(uint64 position, + uint64 size) { return true; } -bool CertificateResourceHandler::OnRequestRedirected(int request_id, - const GURL& url, - ResourceResponse* resp, - bool* defer) { +bool CertificateResourceHandler::OnRequestRedirected(const GURL& url, + ResourceResponse* resp, + bool* defer) { url_ = url; return true; } -bool CertificateResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* resp, - bool* defer) { +bool CertificateResourceHandler::OnResponseStarted(ResourceResponse* resp, + bool* defer) { cert_type_ = net::GetCertificateMimeTypeForMimeType(resp->head.mime_type); return cert_type_ != net::CERTIFICATE_MIME_TYPE_UNKNOWN; } -bool CertificateResourceHandler::OnWillStart(int request_id, - const GURL& url, - bool* defer) { +bool CertificateResourceHandler::OnWillStart(const GURL& url, bool* defer) { return true; } -bool CertificateResourceHandler::OnBeforeNetworkStart(int request_id, - const GURL& url, +bool CertificateResourceHandler::OnBeforeNetworkStart(const GURL& url, bool* defer) { return true; } -bool CertificateResourceHandler::OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, - int* buf_size, - int min_size) { +bool CertificateResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, + int* buf_size, + int min_size) { static const int kReadBufSize = 32768; // TODO(gauravsh): Should we use 'min_size' here? @@ -79,9 +72,7 @@ bool CertificateResourceHandler::OnWillRead(int request_id, return true; } -bool CertificateResourceHandler::OnReadCompleted(int request_id, - int bytes_read, - bool* defer) { +bool CertificateResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { if (!bytes_read) return true; @@ -100,7 +91,6 @@ bool CertificateResourceHandler::OnReadCompleted(int request_id, } void CertificateResourceHandler::OnResponseCompleted( - int request_id, const net::URLRequestStatus& urs, const std::string& sec_info, bool* defer) { @@ -144,9 +134,7 @@ void CertificateResourceHandler::AssembleResource() { DCHECK_EQ(content_length_, bytes_copied); } -void CertificateResourceHandler::OnDataDownloaded( - int request_id, - int bytes_downloaded) { +void CertificateResourceHandler::OnDataDownloaded(int bytes_downloaded) { NOTREACHED(); } diff --git a/content/browser/loader/certificate_resource_handler.h b/content/browser/loader/certificate_resource_handler.h index b6b6361..9c67860 100644 --- a/content/browser/loader/certificate_resource_handler.h +++ b/content/browser/loader/certificate_resource_handler.h @@ -34,50 +34,38 @@ class CertificateResourceHandler : public ResourceHandler { explicit CertificateResourceHandler(net::URLRequest* request); virtual ~CertificateResourceHandler(); - virtual bool OnUploadProgress(int request_id, - uint64 position, - uint64 size) OVERRIDE; + virtual bool OnUploadProgress(uint64 position, uint64 size) OVERRIDE; // Not needed, as this event handler ought to be the final resource. - virtual bool OnRequestRedirected(int request_id, - const GURL& url, + virtual bool OnRequestRedirected(const GURL& url, ResourceResponse* resp, bool* defer) OVERRIDE; // Check if this indeed an X509 cert. - virtual bool OnResponseStarted(int request_id, - ResourceResponse* resp, + virtual bool OnResponseStarted(ResourceResponse* resp, bool* defer) OVERRIDE; // Pass-through implementation. - virtual bool OnWillStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; + virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; // Pass-through implementation. - virtual bool OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; + virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) OVERRIDE; // Create a new buffer to store received data. - virtual bool OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, + virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) OVERRIDE; // A read was completed, maybe allocate a new buffer for further data. - virtual bool OnReadCompleted(int request_id, - int bytes_read, - bool* defer) OVERRIDE; + virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE; // Done downloading the certificate. - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& urs, + virtual void OnResponseCompleted(const net::URLRequestStatus& urs, const std::string& sec_info, bool* defer) OVERRIDE; // N/A to cert downloading. - virtual void OnDataDownloaded(int request_id, int bytes_downloaded) OVERRIDE; + virtual void OnDataDownloaded(int bytes_downloaded) OVERRIDE; private: typedef std::vector<std::pair<scoped_refptr<net::IOBuffer>, diff --git a/content/browser/loader/cross_site_resource_handler.cc b/content/browser/loader/cross_site_resource_handler.cc index 3e88d33..8fa7238 100644 --- a/content/browser/loader/cross_site_resource_handler.cc +++ b/content/browser/loader/cross_site_resource_handler.cc @@ -117,7 +117,6 @@ CrossSiteResourceHandler::~CrossSiteResourceHandler() { } bool CrossSiteResourceHandler::OnRequestRedirected( - int request_id, const GURL& new_url, ResourceResponse* response, bool* defer) { @@ -128,12 +127,10 @@ bool CrossSiteResourceHandler::OnRequestRedirected( // We should not have started the transition before being redirected. DCHECK(!in_cross_site_transition_); - return next_handler_->OnRequestRedirected( - request_id, new_url, response, defer); + return next_handler_->OnRequestRedirected(new_url, response, defer); } bool CrossSiteResourceHandler::OnResponseStarted( - int request_id, ResourceResponse* response, bool* defer) { // At this point, we know that the response is safe to send back to the @@ -186,13 +183,13 @@ bool CrossSiteResourceHandler::OnResponseStarted( if (!swap_needed || info->IsDownload() || info->is_stream() || (response->head.headers.get() && response->head.headers->response_code() == 204)) { - return next_handler_->OnResponseStarted(request_id, response, defer); + return next_handler_->OnResponseStarted(response, defer); } // Now that we know a swap is needed and we have something to commit, we // pause to let the UI thread run the unload handler of the previous page // and set up a transfer if needed. - StartCrossSiteTransition(request_id, response, should_transfer); + StartCrossSiteTransition(response, should_transfer); // Defer loading until after the onunload event handler has run. *defer = true; @@ -202,22 +199,18 @@ bool CrossSiteResourceHandler::OnResponseStarted( void CrossSiteResourceHandler::ResumeOrTransfer(bool is_transfer) { if (is_transfer) { - ResourceRequestInfoImpl* info = GetRequestInfo(); - StartCrossSiteTransition(info->GetRequestID(), response_, is_transfer); + StartCrossSiteTransition(response_, is_transfer); } else { ResumeResponse(); } } -bool CrossSiteResourceHandler::OnReadCompleted(int request_id, - int bytes_read, - bool* defer) { +bool CrossSiteResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { CHECK(!in_cross_site_transition_); - return next_handler_->OnReadCompleted(request_id, bytes_read, defer); + return next_handler_->OnReadCompleted(bytes_read, defer); } void CrossSiteResourceHandler::OnResponseCompleted( - int request_id, const net::URLRequestStatus& status, const std::string& security_info, bool* defer) { @@ -230,8 +223,7 @@ void CrossSiteResourceHandler::OnResponseCompleted( status.status() != net::URLRequestStatus::FAILED || !CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest( info->GetChildID(), info->GetRouteID())) { - next_handler_->OnResponseCompleted(request_id, status, - security_info, defer); + next_handler_->OnResponseCompleted(status, security_info, defer); return; } @@ -239,7 +231,7 @@ void CrossSiteResourceHandler::OnResponseCompleted( // so that the error message (e.g., 404) can be displayed to the user. // Also continue with the logic below to remember that we completed // during the cross-site transition. - StartCrossSiteTransition(request_id, NULL, false); + StartCrossSiteTransition(NULL, false); } // We have to buffer the call until after the transition completes. @@ -264,8 +256,7 @@ void CrossSiteResourceHandler::ResumeResponse() { // Send OnResponseStarted to the new renderer. DCHECK(response_); bool defer = false; - if (!next_handler_->OnResponseStarted(info->GetRequestID(), response_.get(), - &defer)) { + if (!next_handler_->OnResponseStarted(response_.get(), &defer)) { controller()->Cancel(); } else if (!defer) { // Unpause the request to resume reading. Any further reads will be @@ -281,8 +272,7 @@ void CrossSiteResourceHandler::ResumeResponse() { // event handler. if (completed_during_transition_) { bool defer = false; - next_handler_->OnResponseCompleted(info->GetRequestID(), - completed_status_, + next_handler_->OnResponseCompleted(completed_status_, completed_security_info_, &defer); if (!defer) @@ -299,7 +289,6 @@ void CrossSiteResourceHandler::SetLeakRequestsForTesting( // Prepare to render the cross-site response in a new RenderFrameHost, by // telling the old RenderFrameHost to run its onunload handler. void CrossSiteResourceHandler::StartCrossSiteTransition( - int request_id, ResourceResponse* response, bool should_transfer) { in_cross_site_transition_ = true; @@ -310,7 +299,6 @@ void CrossSiteResourceHandler::StartCrossSiteTransition( ResourceRequestInfoImpl* info = GetRequestInfo(); info->set_cross_site_handler(this); - DCHECK_EQ(request_id, info->GetRequestID()); GlobalRequestID global_id(info->GetChildID(), info->GetRequestID()); // Tell the contents responsible for this request that a cross-site response diff --git a/content/browser/loader/cross_site_resource_handler.h b/content/browser/loader/cross_site_resource_handler.h index df6c7a3..257af02 100644 --- a/content/browser/loader/cross_site_resource_handler.h +++ b/content/browser/loader/cross_site_resource_handler.h @@ -29,18 +29,14 @@ class CrossSiteResourceHandler : public LayeredResourceHandler { virtual ~CrossSiteResourceHandler(); // ResourceHandler implementation: - virtual bool OnRequestRedirected(int request_id, - const GURL& new_url, + virtual bool OnRequestRedirected(const GURL& new_url, ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnResponseStarted(int request_id, - ResourceResponse* response, + virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnReadCompleted(int request_id, - int bytes_read, + virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE; - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& status, + virtual void OnResponseCompleted(const net::URLRequestStatus& status, const std::string& security_info, bool* defer) OVERRIDE; @@ -56,8 +52,7 @@ class CrossSiteResourceHandler : public LayeredResourceHandler { private: // Prepare to render the cross-site response in a new RenderViewHost, by // telling the old RenderViewHost to run its onunload handler. - void StartCrossSiteTransition(int request_id, - ResourceResponse* response, + void StartCrossSiteTransition(ResourceResponse* response, bool should_transfer); // Defer the navigation to the UI thread to check whether transfer is required diff --git a/content/browser/loader/detachable_resource_handler.cc b/content/browser/loader/detachable_resource_handler.cc index 42c7d1f..b8ef55d 100644 --- a/content/browser/loader/detachable_resource_handler.cc +++ b/content/browser/loader/detachable_resource_handler.cc @@ -44,8 +44,7 @@ void DetachableResourceHandler::Detach() { net::URLRequestStatus status(net::URLRequestStatus::CANCELED, net::ERR_ABORTED); bool defer_ignored = false; - next_handler_->OnResponseCompleted(GetRequestID(), status, std::string(), - &defer_ignored); + next_handler_->OnResponseCompleted(status, std::string(), &defer_ignored); DCHECK(!defer_ignored); // If |next_handler_| were to defer its shutdown in OnResponseCompleted, // this would destroy it anyway. Fortunately, AsyncResourceHandler never @@ -83,17 +82,14 @@ void DetachableResourceHandler::SetController(ResourceController* controller) { next_handler_->SetController(this); } -bool DetachableResourceHandler::OnUploadProgress(int request_id, - uint64 position, - uint64 size) { +bool DetachableResourceHandler::OnUploadProgress(uint64 position, uint64 size) { if (!next_handler_) return true; - return next_handler_->OnUploadProgress(request_id, position, size); + return next_handler_->OnUploadProgress(position, size); } -bool DetachableResourceHandler::OnRequestRedirected(int request_id, - const GURL& url, +bool DetachableResourceHandler::OnRequestRedirected(const GURL& url, ResourceResponse* response, bool* defer) { DCHECK(!is_deferred_); @@ -101,14 +97,12 @@ bool DetachableResourceHandler::OnRequestRedirected(int request_id, if (!next_handler_) return true; - bool ret = next_handler_->OnRequestRedirected(request_id, url, response, - &is_deferred_); + bool ret = next_handler_->OnRequestRedirected(url, response, &is_deferred_); *defer = is_deferred_; return ret; } -bool DetachableResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* response, +bool DetachableResourceHandler::OnResponseStarted(ResourceResponse* response, bool* defer) { DCHECK(!is_deferred_); @@ -116,25 +110,23 @@ bool DetachableResourceHandler::OnResponseStarted(int request_id, return true; bool ret = - next_handler_->OnResponseStarted(request_id, response, &is_deferred_); + next_handler_->OnResponseStarted(response, &is_deferred_); *defer = is_deferred_; return ret; } -bool DetachableResourceHandler::OnWillStart(int request_id, const GURL& url, - bool* defer) { +bool DetachableResourceHandler::OnWillStart(const GURL& url, bool* defer) { DCHECK(!is_deferred_); if (!next_handler_) return true; - bool ret = next_handler_->OnWillStart(request_id, url, &is_deferred_); + bool ret = next_handler_->OnWillStart(url, &is_deferred_); *defer = is_deferred_; return ret; } -bool DetachableResourceHandler::OnBeforeNetworkStart(int request_id, - const GURL& url, +bool DetachableResourceHandler::OnBeforeNetworkStart(const GURL& url, bool* defer) { DCHECK(!is_deferred_); @@ -142,13 +134,12 @@ bool DetachableResourceHandler::OnBeforeNetworkStart(int request_id, return true; bool ret = - next_handler_->OnBeforeNetworkStart(request_id, url, &is_deferred_); + next_handler_->OnBeforeNetworkStart(url, &is_deferred_); *defer = is_deferred_; return ret; } -bool DetachableResourceHandler::OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, +bool DetachableResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) { if (!next_handler_) { @@ -160,24 +151,22 @@ bool DetachableResourceHandler::OnWillRead(int request_id, return true; } - return next_handler_->OnWillRead(request_id, buf, buf_size, min_size); + return next_handler_->OnWillRead(buf, buf_size, min_size); } -bool DetachableResourceHandler::OnReadCompleted(int request_id, int bytes_read, - bool* defer) { +bool DetachableResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { DCHECK(!is_deferred_); if (!next_handler_) return true; bool ret = - next_handler_->OnReadCompleted(request_id, bytes_read, &is_deferred_); + next_handler_->OnReadCompleted(bytes_read, &is_deferred_); *defer = is_deferred_; return ret; } void DetachableResourceHandler::OnResponseCompleted( - int request_id, const net::URLRequestStatus& status, const std::string& security_info, bool* defer) { @@ -189,17 +178,15 @@ void DetachableResourceHandler::OnResponseCompleted( is_finished_ = true; - next_handler_->OnResponseCompleted(request_id, status, security_info, - &is_deferred_); + next_handler_->OnResponseCompleted(status, security_info, &is_deferred_); *defer = is_deferred_; } -void DetachableResourceHandler::OnDataDownloaded(int request_id, - int bytes_downloaded) { +void DetachableResourceHandler::OnDataDownloaded(int bytes_downloaded) { if (!next_handler_) return; - next_handler_->OnDataDownloaded(request_id, bytes_downloaded); + next_handler_->OnDataDownloaded(bytes_downloaded); } void DetachableResourceHandler::Resume() { diff --git a/content/browser/loader/detachable_resource_handler.h b/content/browser/loader/detachable_resource_handler.h index 2482270..9a68570 100644 --- a/content/browser/loader/detachable_resource_handler.h +++ b/content/browser/loader/detachable_resource_handler.h @@ -48,30 +48,22 @@ class DetachableResourceHandler : public ResourceHandler, // ResourceHandler implementation: virtual void SetController(ResourceController* controller) OVERRIDE; - virtual bool OnUploadProgress(int request_id, uint64 position, - uint64 size) OVERRIDE; - virtual bool OnRequestRedirected(int request_id, const GURL& url, + virtual bool OnUploadProgress(uint64 position, uint64 size) OVERRIDE; + virtual bool OnRequestRedirected(const GURL& url, ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnResponseStarted(int request_id, - ResourceResponse* response, + virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnWillStart(int request_id, const GURL& url, - bool* defer) OVERRIDE; - virtual bool OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; - virtual bool OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, + virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; + virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) OVERRIDE; + virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) OVERRIDE; - virtual bool OnReadCompleted(int request_id, int bytes_read, - bool* defer) OVERRIDE; - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& status, + virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE; + virtual void OnResponseCompleted(const net::URLRequestStatus& status, const std::string& security_info, bool* defer) OVERRIDE; - virtual void OnDataDownloaded(int request_id, int bytes_downloaded) OVERRIDE; + virtual void OnDataDownloaded(int bytes_downloaded) OVERRIDE; // ResourceController implementation: virtual void Resume() OVERRIDE; diff --git a/content/browser/loader/layered_resource_handler.cc b/content/browser/loader/layered_resource_handler.cc index eee529e..1c65820 100644 --- a/content/browser/loader/layered_resource_handler.cc +++ b/content/browser/loader/layered_resource_handler.cc @@ -29,67 +29,60 @@ void LayeredResourceHandler::SetController(ResourceController* controller) { next_handler_->SetController(controller); } -bool LayeredResourceHandler::OnUploadProgress(int request_id, uint64 position, +bool LayeredResourceHandler::OnUploadProgress(uint64 position, uint64 size) { DCHECK(next_handler_.get()); - return next_handler_->OnUploadProgress(request_id, position, size); + return next_handler_->OnUploadProgress(position, size); } -bool LayeredResourceHandler::OnRequestRedirected(int request_id, - const GURL& url, +bool LayeredResourceHandler::OnRequestRedirected(const GURL& url, ResourceResponse* response, bool* defer) { DCHECK(next_handler_.get()); - return next_handler_->OnRequestRedirected(request_id, url, response, defer); + return next_handler_->OnRequestRedirected(url, response, defer); } -bool LayeredResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* response, +bool LayeredResourceHandler::OnResponseStarted(ResourceResponse* response, bool* defer) { DCHECK(next_handler_.get()); - return next_handler_->OnResponseStarted(request_id, response, defer); + return next_handler_->OnResponseStarted(response, defer); } -bool LayeredResourceHandler::OnWillStart(int request_id, const GURL& url, +bool LayeredResourceHandler::OnWillStart(const GURL& url, bool* defer) { DCHECK(next_handler_.get()); - return next_handler_->OnWillStart(request_id, url, defer); + return next_handler_->OnWillStart(url, defer); } -bool LayeredResourceHandler::OnBeforeNetworkStart(int request_id, - const GURL& url, +bool LayeredResourceHandler::OnBeforeNetworkStart(const GURL& url, bool* defer) { DCHECK(next_handler_.get()); - return next_handler_->OnBeforeNetworkStart(request_id, url, defer); + return next_handler_->OnBeforeNetworkStart(url, defer); } -bool LayeredResourceHandler::OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, +bool LayeredResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) { DCHECK(next_handler_.get()); - return next_handler_->OnWillRead(request_id, buf, buf_size, min_size); + return next_handler_->OnWillRead(buf, buf_size, min_size); } -bool LayeredResourceHandler::OnReadCompleted(int request_id, int bytes_read, - bool* defer) { +bool LayeredResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { DCHECK(next_handler_.get()); - return next_handler_->OnReadCompleted(request_id, bytes_read, defer); + return next_handler_->OnReadCompleted(bytes_read, defer); } void LayeredResourceHandler::OnResponseCompleted( - int request_id, const net::URLRequestStatus& status, const std::string& security_info, bool* defer) { DCHECK(next_handler_.get()); - next_handler_->OnResponseCompleted(request_id, status, security_info, defer); + next_handler_->OnResponseCompleted(status, security_info, defer); } -void LayeredResourceHandler::OnDataDownloaded(int request_id, - int bytes_downloaded) { +void LayeredResourceHandler::OnDataDownloaded(int bytes_downloaded) { DCHECK(next_handler_.get()); - next_handler_->OnDataDownloaded(request_id, bytes_downloaded); + next_handler_->OnDataDownloaded(bytes_downloaded); } } // namespace content diff --git a/content/browser/loader/layered_resource_handler.h b/content/browser/loader/layered_resource_handler.h index 63dbc81..dc6de23 100644 --- a/content/browser/loader/layered_resource_handler.h +++ b/content/browser/loader/layered_resource_handler.h @@ -25,30 +25,23 @@ class CONTENT_EXPORT LayeredResourceHandler : public ResourceHandler { // ResourceHandler implementation: virtual void SetController(ResourceController* controller) OVERRIDE; - virtual bool OnUploadProgress(int request_id, uint64 position, - uint64 size) OVERRIDE; - virtual bool OnRequestRedirected(int request_id, const GURL& url, + virtual bool OnUploadProgress(uint64 position, uint64 size) OVERRIDE; + virtual bool OnRequestRedirected(const GURL& url, ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnResponseStarted(int request_id, - ResourceResponse* response, + virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnWillStart(int request_id, const GURL& url, - bool* defer) OVERRIDE; - virtual bool OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; - virtual bool OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, + virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; + virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) OVERRIDE; + virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) OVERRIDE; - virtual bool OnReadCompleted(int request_id, int bytes_read, + virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE; - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& status, + virtual void OnResponseCompleted(const net::URLRequestStatus& status, const std::string& security_info, bool* defer) OVERRIDE; - virtual void OnDataDownloaded(int request_id, int bytes_downloaded) OVERRIDE; + virtual void OnDataDownloaded(int bytes_downloaded) OVERRIDE; scoped_ptr<ResourceHandler> next_handler_; }; diff --git a/content/browser/loader/redirect_to_file_resource_handler.cc b/content/browser/loader/redirect_to_file_resource_handler.cc index 85dfec8..caf36cd 100644 --- a/content/browser/loader/redirect_to_file_resource_handler.cc +++ b/content/browser/loader/redirect_to_file_resource_handler.cc @@ -155,7 +155,6 @@ void RedirectToFileResourceHandler:: } bool RedirectToFileResourceHandler::OnResponseStarted( - int request_id, ResourceResponse* response, bool* defer) { if (response->head.error_code == net::OK || @@ -163,12 +162,10 @@ bool RedirectToFileResourceHandler::OnResponseStarted( DCHECK(writer_); response->head.download_file_path = writer_->path(); } - return next_handler_->OnResponseStarted(request_id, response, defer); + return next_handler_->OnResponseStarted(response, defer); } -bool RedirectToFileResourceHandler::OnWillStart(int request_id, - const GURL& url, - bool* defer) { +bool RedirectToFileResourceHandler::OnWillStart(const GURL& url, bool* defer) { DCHECK(!writer_); // Defer starting the request until we have created the temporary file. @@ -189,7 +186,6 @@ bool RedirectToFileResourceHandler::OnWillStart(int request_id, } bool RedirectToFileResourceHandler::OnWillRead( - int request_id, scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) { @@ -208,8 +204,7 @@ bool RedirectToFileResourceHandler::OnWillRead( return true; } -bool RedirectToFileResourceHandler::OnReadCompleted(int request_id, - int bytes_read, +bool RedirectToFileResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { DCHECK(buf_write_pending_); buf_write_pending_ = false; @@ -233,7 +228,6 @@ bool RedirectToFileResourceHandler::OnReadCompleted(int request_id, } void RedirectToFileResourceHandler::OnResponseCompleted( - int request_id, const net::URLRequestStatus& status, const std::string& security_info, bool* defer) { @@ -245,7 +239,7 @@ void RedirectToFileResourceHandler::OnResponseCompleted( *defer = true; return; } - next_handler_->OnResponseCompleted(request_id, status, security_info, defer); + next_handler_->OnResponseCompleted(status, security_info, defer); } void RedirectToFileResourceHandler::DidCreateTemporaryFile( @@ -263,7 +257,7 @@ void RedirectToFileResourceHandler::DidCreateTemporaryFile( // Resume the request. DCHECK(did_defer_); bool defer = false; - if (!next_handler_->OnWillStart(GetRequestID(), will_start_url_, &defer)) { + if (!next_handler_->OnWillStart(will_start_url_, &defer)) { controller()->Cancel(); } else if (!defer) { ResumeIfDeferred(); @@ -274,11 +268,9 @@ void RedirectToFileResourceHandler::DidCreateTemporaryFile( } void RedirectToFileResourceHandler::DidWriteToFile(int result) { - int request_id = GetRequestID(); - bool failed = false; if (result > 0) { - next_handler_->OnDataDownloaded(request_id, result); + next_handler_->OnDataDownloaded(result); write_cursor_ += result; failed = !WriteMore(); } else { @@ -304,8 +296,7 @@ void RedirectToFileResourceHandler::DidWriteToFile(int result) { // this should run even in the |failed| case above, otherwise a failed write // leaves the handler stuck. bool defer = false; - next_handler_->OnResponseCompleted(request_id, - completed_status_, + next_handler_->OnResponseCompleted(completed_status_, completed_security_info_, &defer); if (!defer) { @@ -357,7 +348,7 @@ bool RedirectToFileResourceHandler::WriteMore() { return true; if (rv <= 0) return false; - next_handler_->OnDataDownloaded(GetRequestID(), rv); + next_handler_->OnDataDownloaded(rv); write_cursor_ += rv; } } diff --git a/content/browser/loader/redirect_to_file_resource_handler.h b/content/browser/loader/redirect_to_file_resource_handler.h index 6c4007b..07763f5 100644 --- a/content/browser/loader/redirect_to_file_resource_handler.h +++ b/content/browser/loader/redirect_to_file_resource_handler.h @@ -56,21 +56,14 @@ class CONTENT_EXPORT RedirectToFileResourceHandler const CreateTemporaryFileStreamFunction& create_temporary_file_stream); // LayeredResourceHandler implementation: - virtual bool OnResponseStarted(int request_id, - ResourceResponse* response, + virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnWillStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; - virtual bool OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, + virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; + virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) OVERRIDE; - virtual bool OnReadCompleted(int request_id, - int bytes_read, - bool* defer) OVERRIDE; - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& status, + virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE; + virtual void OnResponseCompleted(const net::URLRequestStatus& status, const std::string& security_info, bool* defer) OVERRIDE; diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc index 46a12e4..e52549c 100644 --- a/content/browser/loader/resource_dispatcher_host_impl.cc +++ b/content/browser/loader/resource_dispatcher_host_impl.cc @@ -1338,11 +1338,6 @@ void ResourceDispatcherHostImpl::BeginSaveFile( base::debug::Alias(url_buf); CHECK(ContainsKey(active_resource_contexts_, context)); - scoped_ptr<ResourceHandler> handler( - new SaveFileResourceHandler(child_id, - route_id, - url, - save_file_manager_.get())); request_id_--; const net::URLRequestContext* request_context = context->GetRequestContext(); @@ -1375,6 +1370,13 @@ void ResourceDispatcherHostImpl::BeginSaveFile( CreateRequestInfo(child_id, route_id, false, context); extra_info->AssociateWithRequest(request.get()); // Request takes ownership. + scoped_ptr<ResourceHandler> handler( + new SaveFileResourceHandler(request.get(), + child_id, + route_id, + url, + save_file_manager_.get())); + BeginRequestInternal(request.Pass(), handler.Pass()); } @@ -1643,8 +1645,7 @@ void ResourceDispatcherHostImpl::BeginRequestInternal( request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); bool defer = false; - handler->OnResponseCompleted(info->GetRequestID(), request->status(), - std::string(), &defer); + handler->OnResponseCompleted(request->status(), std::string(), &defer); if (defer) { // TODO(darin): The handler is not ready for us to kill the request. Oops! NOTREACHED(); diff --git a/content/browser/loader/resource_handler.h b/content/browser/loader/resource_handler.h index e47aa81..a9d8a38 100644 --- a/content/browser/loader/resource_handler.h +++ b/content/browser/loader/resource_handler.h @@ -45,15 +45,13 @@ class CONTENT_EXPORT ResourceHandler virtual void SetController(ResourceController* controller); // Called as upload progress is made. The return value is ignored. - virtual bool OnUploadProgress(int request_id, - uint64 position, - uint64 size) = 0; + virtual bool OnUploadProgress(uint64 position, uint64 size) = 0; // The request was redirected to a new URL. |*defer| has an initial value of // false. Set |*defer| to true to defer the redirect. The redirect may be // followed later on via ResourceDispatcherHost::FollowDeferredRedirect. If // the handler returns false, then the request is cancelled. - virtual bool OnRequestRedirected(int request_id, const GURL& url, + virtual bool OnRequestRedirected(const GURL& url, ResourceResponse* response, bool* defer) = 0; @@ -61,26 +59,22 @@ class CONTENT_EXPORT ResourceHandler // false, then the request is cancelled. Set |*defer| to true to defer // processing of the response. Call ResourceDispatcherHostImpl:: // ResumeDeferredRequest to continue processing the response. - virtual bool OnResponseStarted(int request_id, - ResourceResponse* response, - bool* defer) = 0; - - // Called before the net::URLRequest for |request_id| (whose url is |url|) is - // to be started. If the handler returns false, then the request is - // cancelled. Otherwise if the return value is true, the ResourceHandler can - // delay the request from starting by setting |*defer = true|. A deferred - // request will not have called net::URLRequest::Start(), and will not resume - // until someone calls ResourceDispatcherHost::StartDeferredRequest(). - virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) = 0; - - // Called before the net::URLRequest for |request_id| (whose url is |url|} - // uses the network for the first time to load the resource. If the handler - // returns false, then the request is cancelled. Otherwise if the return value - // is true, the ResourceHandler can delay the request from starting by setting - // |*defer = true|. Call controller()->Resume() to continue if deferred. - virtual bool OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) = 0; + virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) = 0; + + // Called before the net::URLRequest (whose url is |url|) is to be started. + // If the handler returns false, then the request is cancelled. Otherwise if + // the return value is true, the ResourceHandler can delay the request from + // starting by setting |*defer = true|. A deferred request will not have + // called net::URLRequest::Start(), and will not resume until someone calls + // ResourceDispatcherHost::StartDeferredRequest(). + virtual bool OnWillStart(const GURL& url, bool* defer) = 0; + + // Called before the net::URLRequest (whose url is |url|} uses the network for + // the first time to load the resource. If the handler returns false, then the + // request is cancelled. Otherwise if the return value is true, the + // ResourceHandler can delay the request from starting by setting |*defer = + // true|. Call controller()->Resume() to continue if deferred. + virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) = 0; // Data will be read for the response. Upon success, this method places the // size and address of the buffer where the data is to be written in its @@ -92,8 +86,7 @@ class CONTENT_EXPORT ResourceHandler // // If the handler returns false, then the request is cancelled. Otherwise, // once data is available, OnReadCompleted will be called. - virtual bool OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, + virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) = 0; @@ -102,14 +95,12 @@ class CONTENT_EXPORT ResourceHandler // reading data. Set |*defer| to true to defer reading more response data. // Call controller()->Resume() to continue reading response data. A zero // |bytes_read| signals that no further data is available. - virtual bool OnReadCompleted(int request_id, int bytes_read, - bool* defer) = 0; + virtual bool OnReadCompleted(int bytes_read, bool* defer) = 0; // The response is complete. The final response status is given. Set // |*defer| to true to defer destruction to a later time. Otherwise, the // request will be destroyed upon return. - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& status, + virtual void OnResponseCompleted(const net::URLRequestStatus& status, const std::string& security_info, bool* defer) = 0; @@ -117,7 +108,7 @@ class CONTENT_EXPORT ResourceHandler // to indicate progress of 'download_to_file' requests. OnReadCompleted // calls are consumed by the RedirectToFileResourceHandler and replaced // with OnDataDownloaded calls. - virtual void OnDataDownloaded(int request_id, int bytes_downloaded) = 0; + virtual void OnDataDownloaded(int bytes_downloaded) = 0; protected: ResourceHandler(net::URLRequest* request); diff --git a/content/browser/loader/resource_loader.cc b/content/browser/loader/resource_loader.cc index 450f193..0becbf4 100644 --- a/content/browser/loader/resource_loader.cc +++ b/content/browser/loader/resource_loader.cc @@ -99,8 +99,7 @@ void ResourceLoader::StartRequest() { // Give the handler a chance to delay the URLRequest from being started. bool defer_start = false; - if (!handler_->OnWillStart(GetRequestInfo()->GetRequestID(), request_->url(), - &defer_start)) { + if (!handler_->OnWillStart(request_->url(), &defer_start)) { Cancel(); return; } @@ -127,8 +126,6 @@ void ResourceLoader::CancelWithError(int error_code) { } void ResourceLoader::ReportUploadProgress() { - ResourceRequestInfoImpl* info = GetRequestInfo(); - if (waiting_for_upload_progress_ack_) return; // Send one progress event at a time. @@ -152,8 +149,7 @@ void ResourceLoader::ReportUploadProgress() { if (is_finished || enough_new_progress || too_much_time_passed) { if (request_->load_flags() & net::LOAD_ENABLE_UPLOAD_PROGRESS) { - handler_->OnUploadProgress( - info->GetRequestID(), progress.position(), progress.size()); + handler_->OnUploadProgress(progress.position(), progress.size()); waiting_for_upload_progress_ack_ = true; } last_upload_ticks_ = TimeTicks::Now(); @@ -227,8 +223,7 @@ void ResourceLoader::OnReceivedRedirect(net::URLRequest* unused, scoped_refptr<ResourceResponse> response(new ResourceResponse()); PopulateResourceResponse(request_.get(), response.get()); - if (!handler_->OnRequestRedirected( - info->GetRequestID(), new_url, response.get(), defer)) { + if (!handler_->OnRequestRedirected(new_url, response.get(), defer)) { Cancel(); } else if (*defer) { deferred_stage_ = DEFERRED_REDIRECT; // Follow redirect when resumed. @@ -299,8 +294,7 @@ void ResourceLoader::OnBeforeNetworkStart(net::URLRequest* unused, DCHECK_EQ(request_.get(), unused); // Give the handler a chance to delay the URLRequest from using the network. - if (!handler_->OnBeforeNetworkStart( - GetRequestInfo()->GetRequestID(), request_->url(), defer)) { + if (!handler_->OnBeforeNetworkStart(request_->url(), defer)) { Cancel(); return; } else if (*defer) { @@ -554,8 +548,7 @@ void ResourceLoader::CompleteResponseStarted() { delegate_->DidReceiveResponse(this); bool defer = false; - if (!handler_->OnResponseStarted( - info->GetRequestID(), response.get(), &defer)) { + if (!handler_->OnResponseStarted(response.get(), &defer)) { Cancel(); } else if (defer) { read_deferral_start_time_ = base::TimeTicks::Now(); @@ -601,7 +594,6 @@ void ResourceLoader::ResumeReading() { } void ResourceLoader::ReadMore(int* bytes_read) { - ResourceRequestInfoImpl* info = GetRequestInfo(); DCHECK(!is_deferred()); // Make sure we track the buffer in at least one place. This ensures it gets @@ -609,7 +601,7 @@ void ResourceLoader::ReadMore(int* bytes_read) { // doesn't use the buffer. scoped_refptr<net::IOBuffer> buf; int buf_size; - if (!handler_->OnWillRead(info->GetRequestID(), &buf, &buf_size, -1)) { + if (!handler_->OnWillRead(&buf, &buf_size, -1)) { Cancel(); return; } @@ -627,10 +619,8 @@ void ResourceLoader::CompleteRead(int bytes_read) { DCHECK(bytes_read >= 0); DCHECK(request_->status().is_success()); - ResourceRequestInfoImpl* info = GetRequestInfo(); - bool defer = false; - if (!handler_->OnReadCompleted(info->GetRequestID(), bytes_read, &defer)) { + if (!handler_->OnReadCompleted(bytes_read, &defer)) { Cancel(); } else if (defer) { deferred_stage_ = @@ -664,8 +654,7 @@ void ResourceLoader::ResponseCompleted() { } bool defer = false; - handler_->OnResponseCompleted(info->GetRequestID(), request_->status(), - security_info, &defer); + handler_->OnResponseCompleted(request_->status(), security_info, &defer); if (defer) { // The handler is not ready to die yet. We will call DidFinishLoading when // we resume. diff --git a/content/browser/loader/resource_loader_unittest.cc b/content/browser/loader/resource_loader_unittest.cc index e26184d..d2fdd99 100644 --- a/content/browser/loader/resource_loader_unittest.cc +++ b/content/browser/loader/resource_loader_unittest.cc @@ -127,46 +127,37 @@ class ResourceHandlerStub : public ResourceHandler { } // ResourceHandler implementation: - virtual bool OnUploadProgress(int request_id, - uint64 position, - uint64 size) OVERRIDE { + virtual bool OnUploadProgress(uint64 position, uint64 size) OVERRIDE { NOTREACHED(); return true; } - virtual bool OnRequestRedirected(int request_id, - const GURL& url, + virtual bool OnRequestRedirected(const GURL& url, ResourceResponse* response, bool* defer) OVERRIDE { NOTREACHED(); return true; } - virtual bool OnResponseStarted(int request_id, - ResourceResponse* response, + virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) OVERRIDE { EXPECT_FALSE(response_); response_ = response; return true; } - virtual bool OnWillStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE { + virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE { EXPECT_TRUE(start_url_.is_empty()); start_url_ = url; *defer = defer_request_on_will_start_; return true; } - virtual bool OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE { + virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) OVERRIDE { return true; } - virtual bool OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, + virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) OVERRIDE { EXPECT_TRUE(expect_reads_); @@ -180,9 +171,7 @@ class ResourceHandlerStub : public ResourceHandler { return true; } - virtual bool OnReadCompleted(int request_id, - int bytes_read, - bool* defer) OVERRIDE { + virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE { EXPECT_TRUE(received_on_will_read_); EXPECT_TRUE(expect_reads_); EXPECT_FALSE(received_response_completed_); @@ -201,8 +190,7 @@ class ResourceHandlerStub : public ResourceHandler { return !cancel_on_read_completed_; } - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& status, + virtual void OnResponseCompleted(const net::URLRequestStatus& status, const std::string& security_info, bool* defer) OVERRIDE { EXPECT_FALSE(received_response_completed_); @@ -213,8 +201,7 @@ class ResourceHandlerStub : public ResourceHandler { status_ = status; } - virtual void OnDataDownloaded(int request_id, - int bytes_downloaded) OVERRIDE { + virtual void OnDataDownloaded(int bytes_downloaded) OVERRIDE { EXPECT_FALSE(expect_reads_); total_bytes_downloaded_ += bytes_downloaded; } diff --git a/content/browser/loader/stream_resource_handler.cc b/content/browser/loader/stream_resource_handler.cc index 9bb8c12..46713fc 100644 --- a/content/browser/loader/stream_resource_handler.cc +++ b/content/browser/loader/stream_resource_handler.cc @@ -31,39 +31,31 @@ StreamResourceHandler::~StreamResourceHandler() { stream_->RemoveWriteObserver(this); } -bool StreamResourceHandler::OnUploadProgress(int request_id, - uint64 position, +bool StreamResourceHandler::OnUploadProgress(uint64 position, uint64 size) { return true; } -bool StreamResourceHandler::OnRequestRedirected(int request_id, - const GURL& url, +bool StreamResourceHandler::OnRequestRedirected(const GURL& url, ResourceResponse* resp, bool* defer) { return true; } -bool StreamResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* resp, +bool StreamResourceHandler::OnResponseStarted(ResourceResponse* resp, bool* defer) { return true; } -bool StreamResourceHandler::OnWillStart(int request_id, - const GURL& url, - bool* defer) { +bool StreamResourceHandler::OnWillStart(const GURL& url, bool* defer) { return true; } -bool StreamResourceHandler::OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) { +bool StreamResourceHandler::OnBeforeNetworkStart(const GURL& url, bool* defer) { return true; } -bool StreamResourceHandler::OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, +bool StreamResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) { static const int kReadBufSize = 32768; @@ -77,9 +69,7 @@ bool StreamResourceHandler::OnWillRead(int request_id, return true; } -bool StreamResourceHandler::OnReadCompleted(int request_id, - int bytes_read, - bool* defer) { +bool StreamResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { if (!bytes_read) return true; @@ -99,16 +89,13 @@ bool StreamResourceHandler::OnReadCompleted(int request_id, } void StreamResourceHandler::OnResponseCompleted( - int request_id, const net::URLRequestStatus& status, const std::string& sec_info, bool* defer) { stream_->Finalize(); } -void StreamResourceHandler::OnDataDownloaded( - int request_id, - int bytes_downloaded) { +void StreamResourceHandler::OnDataDownloaded(int bytes_downloaded) { NOTREACHED(); } diff --git a/content/browser/loader/stream_resource_handler.h b/content/browser/loader/stream_resource_handler.h index daa9b50..3b8bc21 100644 --- a/content/browser/loader/stream_resource_handler.h +++ b/content/browser/loader/stream_resource_handler.h @@ -31,45 +31,33 @@ class StreamResourceHandler : public StreamWriteObserver, const GURL& origin); virtual ~StreamResourceHandler(); - virtual bool OnUploadProgress(int request_id, - uint64 position, - uint64 size) OVERRIDE; + virtual bool OnUploadProgress(uint64 position, uint64 size) OVERRIDE; // Not needed, as this event handler ought to be the final resource. - virtual bool OnRequestRedirected(int request_id, - const GURL& url, + virtual bool OnRequestRedirected(const GURL& url, ResourceResponse* resp, bool* defer) OVERRIDE; - virtual bool OnResponseStarted(int request_id, - ResourceResponse* resp, + virtual bool OnResponseStarted(ResourceResponse* resp, bool* defer) OVERRIDE; - virtual bool OnWillStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; + virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; - virtual bool OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; + virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) OVERRIDE; // Create a new buffer to store received data. - virtual bool OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, + virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) OVERRIDE; // A read was completed, forward the data to the Stream. - virtual bool OnReadCompleted(int request_id, - int bytes_read, - bool* defer) OVERRIDE; + virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE; - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& status, + virtual void OnResponseCompleted(const net::URLRequestStatus& status, const std::string& sec_info, bool* defer) OVERRIDE; - virtual void OnDataDownloaded(int request_id, int bytes_downloaded) OVERRIDE; + virtual void OnDataDownloaded(int bytes_downloaded) OVERRIDE; Stream* stream() { return stream_.get(); } diff --git a/content/browser/loader/sync_resource_handler.cc b/content/browser/loader/sync_resource_handler.cc index 865b29e..090b939 100644 --- a/content/browser/loader/sync_resource_handler.cc +++ b/content/browser/loader/sync_resource_handler.cc @@ -10,7 +10,6 @@ #include "content/browser/loader/resource_message_filter.h" #include "content/browser/loader/resource_request_info_impl.h" #include "content/common/resource_messages.h" -#include "content/public/browser/global_request_id.h" #include "content/public/browser/resource_dispatcher_host_delegate.h" #include "content/public/browser/resource_request_info.h" #include "net/base/io_buffer.h" @@ -41,14 +40,11 @@ SyncResourceHandler::~SyncResourceHandler() { } } -bool SyncResourceHandler::OnUploadProgress(int request_id, - uint64 position, - uint64 size) { +bool SyncResourceHandler::OnUploadProgress(uint64 position, uint64 size) { return true; } bool SyncResourceHandler::OnRequestRedirected( - int request_id, const GURL& new_url, ResourceResponse* response, bool* defer) { @@ -72,7 +68,6 @@ bool SyncResourceHandler::OnRequestRedirected( } bool SyncResourceHandler::OnResponseStarted( - int request_id, ResourceResponse* response, bool* defer) { const ResourceRequestInfoImpl* info = GetRequestInfo(); @@ -98,20 +93,15 @@ bool SyncResourceHandler::OnResponseStarted( return true; } -bool SyncResourceHandler::OnWillStart(int request_id, - const GURL& url, - bool* defer) { +bool SyncResourceHandler::OnWillStart(const GURL& url, bool* defer) { return true; } -bool SyncResourceHandler::OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) { +bool SyncResourceHandler::OnBeforeNetworkStart(const GURL& url, bool* defer) { return true; } -bool SyncResourceHandler::OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, +bool SyncResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) { DCHECK(min_size == -1); @@ -120,8 +110,7 @@ bool SyncResourceHandler::OnWillRead(int request_id, return true; } -bool SyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, - bool* defer) { +bool SyncResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { if (!bytes_read) return true; result_.data.append(read_buffer_->data(), bytes_read); @@ -129,7 +118,6 @@ bool SyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, } void SyncResourceHandler::OnResponseCompleted( - int request_id, const net::URLRequestStatus& status, const std::string& security_info, bool* defer) { @@ -148,9 +136,7 @@ void SyncResourceHandler::OnResponseCompleted( return; } -void SyncResourceHandler::OnDataDownloaded( - int request_id, - int bytes_downloaded) { +void SyncResourceHandler::OnDataDownloaded(int bytes_downloaded) { // Sync requests don't involve ResourceMsg_DataDownloaded messages // being sent back to renderers as progress is made. } diff --git a/content/browser/loader/sync_resource_handler.h b/content/browser/loader/sync_resource_handler.h index 3a71483..693b48f 100644 --- a/content/browser/loader/sync_resource_handler.h +++ b/content/browser/loader/sync_resource_handler.h @@ -33,34 +33,22 @@ class SyncResourceHandler : public ResourceHandler { ResourceDispatcherHostImpl* resource_dispatcher_host); virtual ~SyncResourceHandler(); - virtual bool OnUploadProgress(int request_id, - uint64 position, - uint64 size) OVERRIDE; - virtual bool OnRequestRedirected(int request_id, - const GURL& new_url, + virtual bool OnUploadProgress(uint64 position, uint64 size) OVERRIDE; + virtual bool OnRequestRedirected(const GURL& new_url, ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnResponseStarted(int request_id, - ResourceResponse* response, + virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnWillStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; - virtual bool OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; - virtual bool OnWillRead(int request_id, - scoped_refptr<net::IOBuffer>* buf, + virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; + virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) OVERRIDE; + virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, int* buf_size, int min_size) OVERRIDE; - virtual bool OnReadCompleted(int request_id, - int bytes_read, - bool* defer) OVERRIDE; - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& status, + virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE; + virtual void OnResponseCompleted(const net::URLRequestStatus& status, const std::string& security_info, bool* defer) OVERRIDE; - virtual void OnDataDownloaded(int request_id, int bytes_downloaded) OVERRIDE; + virtual void OnDataDownloaded(int bytes_downloaded) OVERRIDE; private: enum { kReadBufSize = 3840 }; diff --git a/content/browser/loader/throttling_resource_handler.cc b/content/browser/loader/throttling_resource_handler.cc index 0de6177..a302f1d 100644 --- a/content/browser/loader/throttling_resource_handler.cc +++ b/content/browser/loader/throttling_resource_handler.cc @@ -31,8 +31,7 @@ ThrottlingResourceHandler::ThrottlingResourceHandler( ThrottlingResourceHandler::~ThrottlingResourceHandler() { } -bool ThrottlingResourceHandler::OnRequestRedirected(int request_id, - const GURL& new_url, +bool ThrottlingResourceHandler::OnRequestRedirected(const GURL& new_url, ResourceResponse* response, bool* defer) { DCHECK(!cancelled_by_resource_throttle_); @@ -55,13 +54,10 @@ bool ThrottlingResourceHandler::OnRequestRedirected(int request_id, next_index_ = 0; // Reset for next time. - return next_handler_->OnRequestRedirected(request_id, new_url, response, - defer); + return next_handler_->OnRequestRedirected(new_url, response, defer); } -bool ThrottlingResourceHandler::OnWillStart(int request_id, - const GURL& url, - bool* defer) { +bool ThrottlingResourceHandler::OnWillStart(const GURL& url, bool* defer) { DCHECK(!cancelled_by_resource_throttle_); *defer = false; @@ -81,11 +77,10 @@ bool ThrottlingResourceHandler::OnWillStart(int request_id, next_index_ = 0; // Reset for next time. - return next_handler_->OnWillStart(request_id, url, defer); + return next_handler_->OnWillStart(url, defer); } -bool ThrottlingResourceHandler::OnBeforeNetworkStart(int request_id, - const GURL& url, +bool ThrottlingResourceHandler::OnBeforeNetworkStart(const GURL& url, bool* defer) { DCHECK(!cancelled_by_resource_throttle_); @@ -106,11 +101,10 @@ bool ThrottlingResourceHandler::OnBeforeNetworkStart(int request_id, next_index_ = 0; // Reset for next time. - return next_handler_->OnBeforeNetworkStart(request_id, url, defer); + return next_handler_->OnBeforeNetworkStart(url, defer); } -bool ThrottlingResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* response, +bool ThrottlingResourceHandler::OnResponseStarted(ResourceResponse* response, bool* defer) { DCHECK(!cancelled_by_resource_throttle_); @@ -130,7 +124,7 @@ bool ThrottlingResourceHandler::OnResponseStarted(int request_id, next_index_ = 0; // Reset for next time. - return next_handler_->OnResponseStarted(request_id, response, defer); + return next_handler_->OnResponseStarted(response, defer); } void ThrottlingResourceHandler::Cancel() { @@ -181,7 +175,7 @@ void ThrottlingResourceHandler::ResumeStart() { deferred_url_ = GURL(); bool defer = false; - if (!OnWillStart(GetRequestID(), url, &defer)) { + if (!OnWillStart(url, &defer)) { controller()->Cancel(); } else if (!defer) { controller()->Resume(); @@ -195,7 +189,7 @@ void ThrottlingResourceHandler::ResumeNetworkStart() { deferred_url_ = GURL(); bool defer = false; - if (!OnBeforeNetworkStart(GetRequestID(), url, &defer)) { + if (!OnBeforeNetworkStart(url, &defer)) { controller()->Cancel(); } else if (!defer) { controller()->Resume(); @@ -211,7 +205,7 @@ void ThrottlingResourceHandler::ResumeRedirect() { deferred_response_.swap(response); bool defer = false; - if (!OnRequestRedirected(GetRequestID(), new_url, response.get(), &defer)) { + if (!OnRequestRedirected(new_url, response.get(), &defer)) { controller()->Cancel(); } else if (!defer) { controller()->Resume(); @@ -225,7 +219,7 @@ void ThrottlingResourceHandler::ResumeResponse() { deferred_response_.swap(response); bool defer = false; - if (!OnResponseStarted(GetRequestID(), response.get(), &defer)) { + if (!OnResponseStarted(response.get(), &defer)) { controller()->Cancel(); } else if (!defer) { controller()->Resume(); diff --git a/content/browser/loader/throttling_resource_handler.h b/content/browser/loader/throttling_resource_handler.h index 9de6951..fd284db 100644 --- a/content/browser/loader/throttling_resource_handler.h +++ b/content/browser/loader/throttling_resource_handler.h @@ -31,17 +31,13 @@ class ThrottlingResourceHandler : public LayeredResourceHandler, virtual ~ThrottlingResourceHandler(); // LayeredResourceHandler overrides: - virtual bool OnRequestRedirected(int request_id, const GURL& url, + virtual bool OnRequestRedirected(const GURL& url, ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnResponseStarted(int request_id, - ResourceResponse* response, + virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnWillStart(int request_id, const GURL& url, - bool* defer) OVERRIDE; - virtual bool OnBeforeNetworkStart(int request_id, - const GURL& url, - bool* defer) OVERRIDE; + virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; + virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) OVERRIDE; // ResourceController implementation: virtual void Cancel() OVERRIDE; |