OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 12 #ifndef CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ |
13 #define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ | 13 #define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ |
14 #pragma once | 14 #pragma once |
15 | 15 |
16 #include <map> | 16 #include <map> |
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/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 23 #include "base/time.h" |
23 #include "base/timer.h" | 24 #include "base/timer.h" |
24 #include "content/browser/renderer_host/resource_queue.h" | 25 #include "content/browser/renderer_host/resource_queue.h" |
25 #include "content/common/child_process_info.h" | 26 #include "content/common/child_process_info.h" |
26 #include "content/common/content_notification_types.h" | 27 #include "content/common/content_notification_types.h" |
27 #include "ipc/ipc_message.h" | 28 #include "ipc/ipc_message.h" |
28 #include "net/url_request/url_request.h" | 29 #include "net/url_request/url_request.h" |
29 #include "webkit/glue/resource_type.h" | 30 #include "webkit/glue/resource_type.h" |
30 | 31 |
31 class CrossSiteResourceHandler; | 32 class CrossSiteResourceHandler; |
32 class DownloadFileManager; | 33 class DownloadFileManager; |
33 class DownloadRequestLimiter; | 34 class DownloadRequestLimiter; |
34 class LoginHandler; | 35 class LoginHandler; |
35 class NotificationDetails; | 36 class NotificationDetails; |
36 class PluginService; | 37 class PluginService; |
37 class ResourceDispatcherHostDelegate; | 38 class ResourceDispatcherHostDelegate; |
38 class ResourceDispatcherHostRequestInfo; | 39 class ResourceDispatcherHostRequestInfo; |
39 class ResourceHandler; | 40 class ResourceHandler; |
40 class ResourceMessageFilter; | 41 class ResourceMessageFilter; |
41 class SaveFileManager; | 42 class SaveFileManager; |
42 class SSLClientAuthHandler; | 43 class SSLClientAuthHandler; |
| 44 class TabContents; |
43 class WebKitThread; | 45 class WebKitThread; |
44 struct DownloadSaveInfo; | 46 struct DownloadSaveInfo; |
45 struct GlobalRequestID; | 47 struct GlobalRequestID; |
46 struct ResourceHostMsg_Request; | 48 struct ResourceHostMsg_Request; |
47 struct ViewMsg_SwapOut_Params; | 49 struct ViewMsg_SwapOut_Params; |
48 | 50 |
49 namespace content { | 51 namespace content { |
50 class ResourceContext; | 52 class ResourceContext; |
51 } | 53 } |
52 namespace net { | 54 namespace net { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 const net::CookieList& cookie_list) const OVERRIDE; | 196 const net::CookieList& cookie_list) const OVERRIDE; |
195 virtual bool CanSetCookie(const net::URLRequest* request, | 197 virtual bool CanSetCookie(const net::URLRequest* request, |
196 const std::string& cookie_line, | 198 const std::string& cookie_line, |
197 net::CookieOptions* options) const OVERRIDE; | 199 net::CookieOptions* options) const OVERRIDE; |
198 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; | 200 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; |
199 virtual void OnReadCompleted(net::URLRequest* request, | 201 virtual void OnReadCompleted(net::URLRequest* request, |
200 int bytes_read) OVERRIDE; | 202 int bytes_read) OVERRIDE; |
201 | 203 |
202 void OnResponseCompleted(net::URLRequest* request); | 204 void OnResponseCompleted(net::URLRequest* request); |
203 | 205 |
| 206 void OnUserGesture(TabContents* tab); |
| 207 |
204 // Helper functions to get the dispatcher's request info for the request. | 208 // Helper functions to get the dispatcher's request info for the request. |
205 // If the dispatcher didn't create the request then NULL is returned. | 209 // If the dispatcher didn't create the request then NULL is returned. |
206 static ResourceDispatcherHostRequestInfo* InfoForRequest( | 210 static ResourceDispatcherHostRequestInfo* InfoForRequest( |
207 net::URLRequest* request); | 211 net::URLRequest* request); |
208 static const ResourceDispatcherHostRequestInfo* InfoForRequest( | 212 static const ResourceDispatcherHostRequestInfo* InfoForRequest( |
209 const net::URLRequest* request); | 213 const net::URLRequest* request); |
210 | 214 |
211 // Extracts the render view/process host's identifiers from the given request | 215 // Extracts the render view/process host's identifiers from the given request |
212 // and places them in the given out params (both required). If there are no | 216 // and places them in the given out params (both required). If there are no |
213 // such IDs associated with the request (such as non-page-related requests), | 217 // such IDs associated with the request (such as non-page-related requests), |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 499 |
496 // |max_outstanding_requests_cost_per_process_| is the upper bound on how | 500 // |max_outstanding_requests_cost_per_process_| is the upper bound on how |
497 // many outstanding requests can be issued per child process host. | 501 // many outstanding requests can be issued per child process host. |
498 // The constraint is expressed in terms of bytes (where the cost of | 502 // The constraint is expressed in terms of bytes (where the cost of |
499 // individual requests is given by CalculateApproximateMemoryCost). | 503 // individual requests is given by CalculateApproximateMemoryCost). |
500 // The total number of outstanding requests is roughly: | 504 // The total number of outstanding requests is roughly: |
501 // (max_outstanding_requests_cost_per_process_ / | 505 // (max_outstanding_requests_cost_per_process_ / |
502 // kAvgBytesPerOutstandingRequest) | 506 // kAvgBytesPerOutstandingRequest) |
503 int max_outstanding_requests_cost_per_process_; | 507 int max_outstanding_requests_cost_per_process_; |
504 | 508 |
| 509 // Time of the last user gesture. Stored so that we can add a load |
| 510 // flag to requests occurring soon after a gesture to indicate they |
| 511 // may be because of explicit user action. |
| 512 base::TimeTicks last_user_gesture_time_; |
| 513 |
505 // Used during IPC message dispatching so that the handlers can get a pointer | 514 // Used during IPC message dispatching so that the handlers can get a pointer |
506 // to the source of the message. | 515 // to the source of the message. |
507 ResourceMessageFilter* filter_; | 516 ResourceMessageFilter* filter_; |
508 | 517 |
509 ResourceDispatcherHostDelegate* delegate_; | 518 ResourceDispatcherHostDelegate* delegate_; |
510 | 519 |
511 static bool is_prefetch_enabled_; | 520 static bool is_prefetch_enabled_; |
512 bool allow_cross_origin_auth_prompt_; | 521 bool allow_cross_origin_auth_prompt_; |
513 | 522 |
514 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); | 523 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); |
515 }; | 524 }; |
516 | 525 |
517 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ | 526 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ |
OLD | NEW |