OLD | NEW |
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 |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "content/browser/renderer_host/resource_loader_delegate.h" | 28 #include "content/browser/renderer_host/resource_loader_delegate.h" |
29 #include "content/common/content_export.h" | 29 #include "content/common/content_export.h" |
30 #include "content/public/browser/child_process_data.h" | 30 #include "content/public/browser/child_process_data.h" |
31 #include "content/public/browser/notification_types.h" | 31 #include "content/public/browser/notification_types.h" |
32 #include "content/public/browser/resource_dispatcher_host.h" | 32 #include "content/public/browser/resource_dispatcher_host.h" |
33 #include "ipc/ipc_message.h" | 33 #include "ipc/ipc_message.h" |
34 #include "net/cookies/canonical_cookie.h" | 34 #include "net/cookies/canonical_cookie.h" |
35 #include "net/url_request/url_request.h" | 35 #include "net/url_request/url_request.h" |
36 #include "webkit/glue/resource_type.h" | 36 #include "webkit/glue/resource_type.h" |
37 | 37 |
| 38 class DownloadFileManager; |
38 class ResourceHandler; | 39 class ResourceHandler; |
39 class SaveFileManager; | 40 class SaveFileManager; |
40 class WebContentsImpl; | 41 class WebContentsImpl; |
41 struct ResourceHostMsg_Request; | 42 struct ResourceHostMsg_Request; |
42 struct ViewMsg_SwapOut_Params; | 43 struct ViewMsg_SwapOut_Params; |
43 | 44 |
44 namespace net { | 45 namespace net { |
45 class URLRequestJobFactory; | 46 class URLRequestJobFactory; |
46 } | 47 } |
47 | 48 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 137 |
137 // Intended for unit-tests only. Overrides the outstanding requests bound. | 138 // Intended for unit-tests only. Overrides the outstanding requests bound. |
138 void set_max_outstanding_requests_cost_per_process(int limit) { | 139 void set_max_outstanding_requests_cost_per_process(int limit) { |
139 max_outstanding_requests_cost_per_process_ = limit; | 140 max_outstanding_requests_cost_per_process_ = limit; |
140 } | 141 } |
141 | 142 |
142 // The average private bytes increase of the browser for each new pending | 143 // The average private bytes increase of the browser for each new pending |
143 // request. Experimentally obtained. | 144 // request. Experimentally obtained. |
144 static const int kAvgBytesPerOutstandingRequest = 4400; | 145 static const int kAvgBytesPerOutstandingRequest = 4400; |
145 | 146 |
| 147 DownloadFileManager* download_file_manager() const { |
| 148 return download_file_manager_; |
| 149 } |
| 150 |
146 SaveFileManager* save_file_manager() const { | 151 SaveFileManager* save_file_manager() const { |
147 return save_file_manager_; | 152 return save_file_manager_; |
148 } | 153 } |
149 | 154 |
150 // Called when the unload handler for a cross-site request has finished. | 155 // Called when the unload handler for a cross-site request has finished. |
151 void OnSwapOutACK(const ViewMsg_SwapOut_Params& params); | 156 void OnSwapOutACK(const ViewMsg_SwapOut_Params& params); |
152 | 157 |
153 // Called when the renderer loads a resource from its internal cache. | 158 // Called when the renderer loads a resource from its internal cache. |
154 void OnDidLoadResourceFromMemoryCache(const GURL& url, | 159 void OnDidLoadResourceFromMemoryCache(const GURL& url, |
155 const std::string& security_info, | 160 const std::string& security_info, |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 DeletableFilesMap; // key is request id | 349 DeletableFilesMap; // key is request id |
345 typedef std::map<int, DeletableFilesMap> | 350 typedef std::map<int, DeletableFilesMap> |
346 RegisteredTempFiles; // key is child process id | 351 RegisteredTempFiles; // key is child process id |
347 RegisteredTempFiles registered_temp_files_; | 352 RegisteredTempFiles registered_temp_files_; |
348 | 353 |
349 // A timer that periodically calls UpdateLoadStates while pending_requests_ | 354 // A timer that periodically calls UpdateLoadStates while pending_requests_ |
350 // is not empty. | 355 // is not empty. |
351 scoped_ptr<base::RepeatingTimer<ResourceDispatcherHostImpl> > | 356 scoped_ptr<base::RepeatingTimer<ResourceDispatcherHostImpl> > |
352 update_load_states_timer_; | 357 update_load_states_timer_; |
353 | 358 |
| 359 // We own the download file writing thread and manager |
| 360 scoped_refptr<DownloadFileManager> download_file_manager_; |
| 361 |
354 // We own the save file manager. | 362 // We own the save file manager. |
355 scoped_refptr<SaveFileManager> save_file_manager_; | 363 scoped_refptr<SaveFileManager> save_file_manager_; |
356 | 364 |
357 // Request ID for browser initiated requests. request_ids generated by | 365 // Request ID for browser initiated requests. request_ids generated by |
358 // child processes are counted up from 0, while browser created requests | 366 // child processes are counted up from 0, while browser created requests |
359 // start at -2 and go down from there. (We need to start at -2 because -1 is | 367 // start at -2 and go down from there. (We need to start at -2 because -1 is |
360 // used as a special value all over the resource_dispatcher_host for | 368 // used as a special value all over the resource_dispatcher_host for |
361 // uninitialized variables.) This way, we no longer have the unlikely (but | 369 // uninitialized variables.) This way, we no longer have the unlikely (but |
362 // observed in the real world!) event where we have two requests with the same | 370 // observed in the real world!) event where we have two requests with the same |
363 // request_id_. | 371 // request_id_. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 // http://crbug.com/90971 - Assists in tracking down use-after-frees on | 409 // http://crbug.com/90971 - Assists in tracking down use-after-frees on |
402 // shutdown. | 410 // shutdown. |
403 std::set<const ResourceContext*> active_resource_contexts_; | 411 std::set<const ResourceContext*> active_resource_contexts_; |
404 | 412 |
405 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 413 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
406 }; | 414 }; |
407 | 415 |
408 } // namespace content | 416 } // namespace content |
409 | 417 |
410 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 418 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
OLD | NEW |