diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-19 20:56:05 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-19 20:56:05 +0000 |
commit | c1ba9984633ed7ce0b57f939825043d196d0a1d2 (patch) | |
tree | 6544ecfd6723fb96d66435e346d2edc82bcee1b7 /content/browser | |
parent | a36773dd8f0f23e110f2ed081d8fdca327cb562c (diff) | |
download | chromium_src-c1ba9984633ed7ce0b57f939825043d196d0a1d2.zip chromium_src-c1ba9984633ed7ce0b57f939825043d196d0a1d2.tar.gz chromium_src-c1ba9984633ed7ce0b57f939825043d196d0a1d2.tar.bz2 |
Cleanup: ResourceDispatcherHost::BeginDownload takes a scoped_ptr<URLRequest> argument.
This used to take an URLRequest*, with a comment about ownership. Changing to a scoped_ptr argument makes the ownership explicit and enforceable by the compiler.
Also, changed the name of the child_id argument to be process_unique_id to be consistent with the rest of the file.
Review URL: http://codereview.chromium.org/9150028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118351 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
4 files changed, 39 insertions, 39 deletions
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc index 55d7cf6..82c61e3 100644 --- a/content/browser/download/download_manager_impl.cc +++ b/content/browser/download/download_manager_impl.cc @@ -73,11 +73,11 @@ void BeginDownload(const URLParams& url_params, ResourceDispatcherHost* resource_dispatcher_host, const RenderParams& render_params, const content::ResourceContext* context) { - net::URLRequest* request = new net::URLRequest(url_params.url_, - resource_dispatcher_host); + scoped_ptr<net::URLRequest> request( + new net::URLRequest(url_params.url_, resource_dispatcher_host)); request->set_referrer(url_params.referrer_.spec()); resource_dispatcher_host->BeginDownload( - request, save_info, true, + request.Pass(), save_info, true, DownloadResourceHandler::OnStartedCallback(), render_params.render_process_id_, render_params.render_view_id_, diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index 23e4e25..3ca9988 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -687,11 +687,11 @@ void RenderMessageFilter::OnDownloadUrl(const IPC::Message& message, bool prompt_for_save_location = false; DownloadSaveInfo save_info; save_info.suggested_name = suggested_name; - net::URLRequest* request = new net::URLRequest( - url, resource_dispatcher_host_); + scoped_ptr<net::URLRequest> request( + new net::URLRequest(url, resource_dispatcher_host_)); request->set_referrer(referrer.spec()); resource_dispatcher_host_->BeginDownload( - request, + request.Pass(), save_info, prompt_for_save_location, DownloadResourceHandler::OnStartedCallback(), diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc index bb2ad17..82eb10a 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.cc +++ b/content/browser/renderer_host/resource_dispatcher_host.cc @@ -878,14 +878,13 @@ void ResourceDispatcherHost::OnDidLoadResourceFromMemoryCache( // We are explicitly forcing the download of 'url'. void ResourceDispatcherHost::BeginDownload( - net::URLRequest* request, + scoped_ptr<net::URLRequest> request, const DownloadSaveInfo& save_info, bool prompt_for_save_location, const DownloadResourceHandler::OnStartedCallback& started_cb, int child_id, int route_id, const content::ResourceContext& context) { - scoped_ptr<net::URLRequest> delete_request(request); // If DownloadResourceHandler is not begun, then started_cb must be called // here in order to satisfy its semantics. if (is_shutdown_) { @@ -923,14 +922,15 @@ void ResourceDispatcherHost::BeginDownload( url, dl_id, download_file_manager_.get(), - request, + request.get(), prompt_for_save_location, started_cb, save_info)); if (delegate_) { handler = delegate_->DownloadStarting( - handler, context, request, child_id, route_id, request_id_, true); + handler, context, request.get(), + child_id, route_id, request_id_, true); } if (!request_context->job_factory()->IsHandledURL(url)) { @@ -943,9 +943,9 @@ void ResourceDispatcherHost::BeginDownload( ResourceDispatcherHostRequestInfo* extra_info = CreateRequestInfo(handler, child_id, route_id, true, context); - SetRequestInfo(request, extra_info); // Request takes ownership. + SetRequestInfo(request.get(), extra_info); // Request takes ownership. - BeginRequestInternal(delete_request.release()); + BeginRequestInternal(request.release()); } // This function is only used for saving feature. @@ -1009,14 +1009,14 @@ void ResourceDispatcherHost::FollowDeferredRedirect( i->second->FollowDeferredRedirect(); } -void ResourceDispatcherHost::StartDeferredRequest(int process_unique_id, +void ResourceDispatcherHost::StartDeferredRequest(int child_id, int request_id) { - GlobalRequestID global_id(process_unique_id, request_id); + GlobalRequestID global_id(child_id, request_id); PendingRequestList::iterator i = pending_requests_.find(global_id); if (i == pending_requests_.end()) { // The request may have been destroyed LOG(WARNING) << "Trying to resume a non-existent request (" - << process_unique_id << ", " << request_id << ")"; + << child_id << ", " << request_id << ")"; return; } diff --git a/content/browser/renderer_host/resource_dispatcher_host.h b/content/browser/renderer_host/resource_dispatcher_host.h index bbf27d9..c2275ad 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.h +++ b/content/browser/renderer_host/resource_dispatcher_host.h @@ -85,7 +85,7 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { // is shutting down, then |started_cb| will be called immediately. There is no // situation in which |started_cb| will never be called. void BeginDownload( - net::URLRequest* request, // ownership is taken + scoped_ptr<net::URLRequest> request, const DownloadSaveInfo& save_info, bool prompt_for_save_location, const DownloadResourceHandler::OnStartedCallback& started_cb, @@ -97,13 +97,13 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { // request from the renderer or another child process). void BeginSaveFile(const GURL& url, const GURL& referrer, - int process_unique_id, + int child_id, int route_id, const content::ResourceContext& context); // Cancels the given request if it still exists. We ignore cancels from the // renderer in the event of a download. - void CancelRequest(int process_unique_id, + void CancelRequest(int child_id, int request_id, bool from_renderer); @@ -114,21 +114,21 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { // new_first_party_for_cookies. Otherwise, pass false as // has_new_first_party_for_cookies, and new_first_party_for_cookies will not // be used. - void FollowDeferredRedirect(int process_unique_id, + void FollowDeferredRedirect(int child_id, int request_id, bool has_new_first_party_for_cookies, const GURL& new_first_party_for_cookies); // Starts a request that was deferred during ResourceHandler::OnWillStart(). - void StartDeferredRequest(int process_unique_id, int request_id); + void StartDeferredRequest(int child_id, int request_id); // Returns true if it's ok to send the data. If there are already too many // data messages pending, it pauses the request and returns false. In this // case the caller should not send the data. - bool WillSendData(int process_unique_id, int request_id); + bool WillSendData(int child_id, int request_id); // Pauses or resumes network activity for a particular request. - void PauseRequest(int process_unique_id, int request_id, bool pause); + void PauseRequest(int child_id, int request_id, bool pause); // Returns the number of pending requests. This is designed for the unittests int pending_requests() const { @@ -136,8 +136,8 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { } // Intended for unit-tests only. Returns the memory cost of all the - // outstanding requests (pending and blocked) for |process_unique_id|. - int GetOutstandingRequestsMemoryCost(int process_unique_id) const; + // outstanding requests (pending and blocked) for |child_id|. + int GetOutstandingRequestsMemoryCost(int child_id) const; // Intended for unit-tests only. Overrides the outstanding requests bound. void set_max_outstanding_requests_cost_per_process(int limit) { @@ -166,11 +166,11 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { ResourceType::Type resource_type); // Force cancels any pending requests for the given process. - void CancelRequestsForProcess(int process_unique_id); + void CancelRequestsForProcess(int child_id); // Force cancels any pending requests for the given route id. This method // acts like CancelRequestsForProcess when route_id is -1. - void CancelRequestsForRoute(int process_unique_id, int route_id); + void CancelRequestsForRoute(int child_id, int route_id); // Force cancels any pending requests for the given |context|. This is // necessary to ensure that before |context| goes away, all requests @@ -219,24 +219,24 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { net::URLRequest* GetURLRequest( const content::GlobalRequestID& request_id) const; - void RemovePendingRequest(int process_unique_id, int request_id); + void RemovePendingRequest(int child_id, int request_id); // Causes all new requests for the route identified by - // |process_unique_id| and |route_id| to be blocked (not being + // |child_id| and |route_id| to be blocked (not being // started) until ResumeBlockedRequestsForRoute or // CancelBlockedRequestsForRoute is called. - void BlockRequestsForRoute(int process_unique_id, int route_id); + void BlockRequestsForRoute(int child_id, int route_id); // Resumes any blocked request for the specified route id. - void ResumeBlockedRequestsForRoute(int process_unique_id, int route_id); + void ResumeBlockedRequestsForRoute(int child_id, int route_id); // Cancels any blocked request for the specified route id. - void CancelBlockedRequestsForRoute(int process_unique_id, int route_id); + void CancelBlockedRequestsForRoute(int child_id, int route_id); // Decrements the pending_data_count for the request and resumes // the request if it was paused due to too many pending data // messages sent. - void DataReceivedACK(int process_unique_id, int request_id); + void DataReceivedACK(int child_id, int request_id); // Maintains a collection of temp files created in support of // the download_to_file capability. Used to grant access to the @@ -334,14 +334,14 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { net::URLRequest* request, const ResourceDispatcherHostRequestInfo& request_info); - // Updates the "cost" of outstanding requests for |process_unique_id|. + // Updates the "cost" of outstanding requests for |child_id|. // The "cost" approximates how many bytes are consumed by all the in-memory // data structures supporting this request (net::URLRequest object, // HttpNetworkTransaction, etc...). // The value of |cost| is added to the running total, and the resulting // sum is returned. int IncrementOutstandingRequestsMemoryCost(int cost, - int process_unique_id); + int child_id); // Estimate how much heap space |request| will consume to run. static int CalculateApproximateMemoryCost(net::URLRequest* request); @@ -362,17 +362,17 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { void RemovePendingRequest(const PendingRequestList::iterator& iter); // Notify our observers that we started receiving a response for a request. - void NotifyResponseStarted(net::URLRequest* request, int process_unique_id); + void NotifyResponseStarted(net::URLRequest* request, int child_id); // Notify our observers that a request has been redirected. void NotifyReceivedRedirect(net::URLRequest* request, - int process_unique_id, + int child_id, const GURL& new_url); // Tries to handle the url with an external protocol. If the request is // handled, the function returns true. False otherwise. bool HandleExternalProtocol(int request_id, - int process_unique_id, + int child_id, int route_id, const GURL& url, ResourceType::Type resource_type, @@ -388,7 +388,7 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { net::URLRequest *request); // Resumes or cancels (if |cancel_requests| is true) any blocked requests. - void ProcessBlockedRequestsForRoute(int process_unique_id, + void ProcessBlockedRequestsForRoute(int child_id, int route_id, bool cancel_requests); @@ -497,7 +497,7 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { typedef std::map<ProcessRouteIDs, BlockedRequestsList*> BlockedRequestMap; BlockedRequestMap blocked_requests_map_; - // Maps the process_unique_ids to the approximate number of bytes + // Maps the child_ids to the approximate number of bytes // being used to service its resource requests. No entry implies 0 cost. typedef std::map<int, int> OutstandingRequestsMemoryCostMap; OutstandingRequestsMemoryCostMap outstanding_requests_memory_cost_map_; |