Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: content/browser/renderer_host/resource_dispatcher_host_impl.h

Issue 11270027: Add a ResourceScheduler to ResourceDispatcherHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Track background requests Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This is the browser side of the resource dispatcher, it receives requests 5 // This is the browser side of the resource dispatcher, it receives requests
6 // from the child process (i.e. [Renderer, Plugin, Worker]ProcessHost), and 6 // from the child process (i.e. [Renderer, Plugin, Worker]ProcessHost), and
7 // dispatches them to URLRequests. It then forwards the messages from the 7 // dispatches them to URLRequests. It then forwards the messages from the
8 // URLRequests back to the correct process for handling. 8 // URLRequests back to the correct process for handling.
9 // 9 //
10 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 10 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
11 11
12 #ifndef CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_ 12 #ifndef CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_
13 #define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_ 13 #define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_
14 14
15 #include <map> 15 #include <map>
16 #include <set> 16 #include <set>
17 #include <string> 17 #include <string>
18 #include <vector> 18 #include <vector>
19 19
20 #include "base/basictypes.h" 20 #include "base/basictypes.h"
21 #include "base/gtest_prod_util.h" 21 #include "base/gtest_prod_util.h"
22 #include "base/memory/linked_ptr.h" 22 #include "base/memory/linked_ptr.h"
23 #include "base/memory/scoped_ptr.h" 23 #include "base/memory/scoped_ptr.h"
24 #include "base/time.h" 24 #include "base/time.h"
25 #include "base/timer.h" 25 #include "base/timer.h"
26 #include "content/browser/download/download_resource_handler.h" 26 #include "content/browser/download/download_resource_handler.h"
27 #include "content/browser/renderer_host/resource_loader.h" 27 #include "content/browser/renderer_host/resource_loader.h"
28 #include "content/browser/renderer_host/resource_loader_delegate.h" 28 #include "content/browser/renderer_host/resource_loader_delegate.h"
29 #include "content/browser/renderer_host/resource_scheduler.h"
29 #include "content/common/content_export.h" 30 #include "content/common/content_export.h"
30 #include "content/public/browser/child_process_data.h" 31 #include "content/public/browser/child_process_data.h"
31 #include "content/public/browser/notification_types.h" 32 #include "content/public/browser/notification_types.h"
32 #include "content/public/browser/resource_dispatcher_host.h" 33 #include "content/public/browser/resource_dispatcher_host.h"
33 #include "ipc/ipc_message.h" 34 #include "ipc/ipc_message.h"
34 #include "net/cookies/canonical_cookie.h" 35 #include "net/cookies/canonical_cookie.h"
35 #include "net/url_request/url_request.h" 36 #include "net/url_request/url_request.h"
36 #include "webkit/glue/resource_type.h" 37 #include "webkit/glue/resource_type.h"
37 38
38 class ResourceHandler; 39 class ResourceHandler;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 bool Send(IPC::Message* message); 193 bool Send(IPC::Message* message);
193 194
194 // Indicates whether third-party sub-content can pop-up HTTP basic auth 195 // Indicates whether third-party sub-content can pop-up HTTP basic auth
195 // dialog boxes. 196 // dialog boxes.
196 bool allow_cross_origin_auth_prompt(); 197 bool allow_cross_origin_auth_prompt();
197 198
198 ResourceDispatcherHostDelegate* delegate() { 199 ResourceDispatcherHostDelegate* delegate() {
199 return delegate_; 200 return delegate_;
200 } 201 }
201 202
203 ResourceScheduler* scheduler() {
204 return resource_scheduler_;
205 }
206
202 // Must be called after the ResourceRequestInfo has been created 207 // Must be called after the ResourceRequestInfo has been created
203 // and associated with the request. 208 // and associated with the request.
204 scoped_ptr<ResourceHandler> CreateResourceHandlerForDownload( 209 scoped_ptr<ResourceHandler> CreateResourceHandlerForDownload(
205 net::URLRequest* request, 210 net::URLRequest* request,
206 bool is_content_initiated, 211 bool is_content_initiated,
207 scoped_ptr<DownloadSaveInfo> save_info, 212 scoped_ptr<DownloadSaveInfo> save_info,
208 const DownloadResourceHandler::OnStartedCallback& started_cb); 213 const DownloadResourceHandler::OnStartedCallback& started_cb);
209 214
210 void ClearSSLClientAuthHandlerForRequest(net::URLRequest* request); 215 void ClearSSLClientAuthHandlerForRequest(net::URLRequest* request);
211 216
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // data structures supporting this request (net::URLRequest object, 273 // data structures supporting this request (net::URLRequest object,
269 // HttpNetworkTransaction, etc...). 274 // HttpNetworkTransaction, etc...).
270 // The value of |cost| is added to the running total, and the resulting 275 // The value of |cost| is added to the running total, and the resulting
271 // sum is returned. 276 // sum is returned.
272 int IncrementOutstandingRequestsMemoryCost(int cost, 277 int IncrementOutstandingRequestsMemoryCost(int cost,
273 int child_id); 278 int child_id);
274 279
275 // Estimate how much heap space |request| will consume to run. 280 // Estimate how much heap space |request| will consume to run.
276 static int CalculateApproximateMemoryCost(net::URLRequest* request); 281 static int CalculateApproximateMemoryCost(net::URLRequest* request);
277 282
278 // The list of all requests that we have pending. This list is not really 283 // The list of all requests that we have scheduled. This list is not really
279 // optimized, and assumes that we have relatively few requests pending at once 284 // optimized, and assumes that we have relatively few requests pending at once
280 // since some operations require brute-force searching of the list. 285 // since some operations require brute-force searching of the list.
281 // 286 //
282 // It may be enhanced in the future to provide some kind of prioritization 287 // We should also consider a hashtable or binary tree if it turns out we have
283 // mechanism. We should also consider a hashtable or binary tree if it turns 288 // a lot of things here.
284 // out we have a lot of things here. 289 typedef std::map<
285 typedef std::map<GlobalRequestID, linked_ptr<ResourceLoader> > LoaderMap; 290 GlobalRequestID, linked_ptr<ResourceScheduler::LoadHandle> > LoaderMap;
286 291
287 // Deletes the pending request identified by the iterator passed in. 292 // Deletes the pending request identified by the iterator passed in.
288 // This function will invalidate the iterator passed in. Callers should 293 // This function will invalidate the iterator passed in. Callers should
289 // not rely on this iterator being valid on return. 294 // not rely on this iterator being valid on return.
290 void RemovePendingLoader(const LoaderMap::iterator& iter); 295 void RemovePendingLoader(const LoaderMap::iterator& iter);
291 296
292 // Checks all pending requests and updates the load states and upload 297 // Checks all pending requests and updates the load states and upload
293 // progress if necessary. 298 // progress if necessary.
294 void UpdateLoadStates(); 299 void UpdateLoadStates();
295 300
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 ResourceMessageFilter* filter_; 411 ResourceMessageFilter* filter_;
407 412
408 ResourceDispatcherHostDelegate* delegate_; 413 ResourceDispatcherHostDelegate* delegate_;
409 414
410 bool allow_cross_origin_auth_prompt_; 415 bool allow_cross_origin_auth_prompt_;
411 416
412 // http://crbug.com/90971 - Assists in tracking down use-after-frees on 417 // http://crbug.com/90971 - Assists in tracking down use-after-frees on
413 // shutdown. 418 // shutdown.
414 std::set<const ResourceContext*> active_resource_contexts_; 419 std::set<const ResourceContext*> active_resource_contexts_;
415 420
421 ResourceScheduler* resource_scheduler_;
willchan no longer on Chromium 2012/12/03 02:30:16 I commented elsewhere, but yeah, just embed the fu
James Simonsen 2012/12/05 01:52:45 Done.
422
416 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); 423 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl);
417 }; 424 };
418 425
419 } // namespace content 426 } // namespace content
420 427
421 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_ 428 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698