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 |
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/memory/weak_ptr.h" | 23 #include "base/memory/weak_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_queue.h" | 27 #include "content/browser/renderer_host/resource_queue.h" |
28 #include "content/browser/ssl/ssl_error_handler.h" | |
28 #include "content/common/content_export.h" | 29 #include "content/common/content_export.h" |
29 #include "content/public/browser/child_process_data.h" | 30 #include "content/public/browser/child_process_data.h" |
30 #include "content/public/browser/notification_types.h" | 31 #include "content/public/browser/notification_types.h" |
31 #include "ipc/ipc_message.h" | 32 #include "ipc/ipc_message.h" |
32 #include "net/url_request/url_request.h" | 33 #include "net/url_request/url_request.h" |
33 #include "webkit/glue/resource_type.h" | 34 #include "webkit/glue/resource_type.h" |
34 | 35 |
35 class DownloadFileManager; | 36 class DownloadFileManager; |
36 class ResourceDispatcherHostRequestInfo; | 37 class ResourceDispatcherHostRequestInfo; |
37 class ResourceHandler; | 38 class ResourceHandler; |
(...skipping 12 matching lines...) Expand all Loading... | |
50 | 51 |
51 namespace net { | 52 namespace net { |
52 class CookieList; | 53 class CookieList; |
53 class URLRequestJobFactory; | 54 class URLRequestJobFactory; |
54 } // namespace net | 55 } // namespace net |
55 | 56 |
56 namespace webkit_blob { | 57 namespace webkit_blob { |
57 class DeletableFileReference; | 58 class DeletableFileReference; |
58 } | 59 } |
59 | 60 |
60 class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { | 61 class CONTENT_EXPORT ResourceDispatcherHost |
62 : public net::URLRequest::Delegate, | |
63 public SSLErrorHandler::Delegate { | |
61 public: | 64 public: |
62 ResourceDispatcherHost(); | 65 ResourceDispatcherHost(); |
63 virtual ~ResourceDispatcherHost(); | 66 virtual ~ResourceDispatcherHost(); |
64 | 67 |
65 // Returns the current ResourceDispatcherHost. May return NULL if it hasn't | 68 // Returns the current ResourceDispatcherHost. May return NULL if it hasn't |
66 // been created yet. | 69 // been created yet. |
67 static ResourceDispatcherHost* Get(); | 70 static ResourceDispatcherHost* Get(); |
68 | 71 |
69 // Puts the resource dispatcher host in an inactive state (unable to begin | 72 // Puts the resource dispatcher host in an inactive state (unable to begin |
70 // new requests). Cancels all pending requests. | 73 // new requests). Cancels all pending requests. |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 // such IDs associated with the request (such as non-page-related requests), | 215 // such IDs associated with the request (such as non-page-related requests), |
213 // this function will return false and both out params will be -1. | 216 // this function will return false and both out params will be -1. |
214 static bool RenderViewForRequest(const net::URLRequest* request, | 217 static bool RenderViewForRequest(const net::URLRequest* request, |
215 int* render_process_host_id, | 218 int* render_process_host_id, |
216 int* render_view_host_id); | 219 int* render_view_host_id); |
217 | 220 |
218 // Retrieves a net::URLRequest. Must be called from the IO thread. | 221 // Retrieves a net::URLRequest. Must be called from the IO thread. |
219 net::URLRequest* GetURLRequest( | 222 net::URLRequest* GetURLRequest( |
220 const content::GlobalRequestID& request_id) const; | 223 const content::GlobalRequestID& request_id) const; |
221 | 224 |
225 // Retrieves a net::URLRequest. Must be called from the IO thread. | |
226 net::URLRequest* GetURLRequest( | |
227 const SSLErrorHandler::instance_id& id) const; | |
wtc
2012/02/22 00:36:23
It seems that this new method can be private.
Thi
Takashi Toyoshima
2012/02/22 08:15:35
I can remove this function now, because I decide t
| |
228 | |
222 void RemovePendingRequest(int child_id, int request_id); | 229 void RemovePendingRequest(int child_id, int request_id); |
223 | 230 |
224 // Causes all new requests for the route identified by | 231 // Causes all new requests for the route identified by |
225 // |child_id| and |route_id| to be blocked (not being | 232 // |child_id| and |route_id| to be blocked (not being |
226 // started) until ResumeBlockedRequestsForRoute or | 233 // started) until ResumeBlockedRequestsForRoute or |
227 // CancelBlockedRequestsForRoute is called. | 234 // CancelBlockedRequestsForRoute is called. |
228 void BlockRequestsForRoute(int child_id, int route_id); | 235 void BlockRequestsForRoute(int child_id, int route_id); |
229 | 236 |
230 // Resumes any blocked request for the specified route id. | 237 // Resumes any blocked request for the specified route id. |
231 void ResumeBlockedRequestsForRoute(int child_id, int route_id); | 238 void ResumeBlockedRequestsForRoute(int child_id, int route_id); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 | 284 |
278 scoped_refptr<ResourceHandler> CreateResourceHandlerForDownload( | 285 scoped_refptr<ResourceHandler> CreateResourceHandlerForDownload( |
279 net::URLRequest* request, | 286 net::URLRequest* request, |
280 content::ResourceContext* context, | 287 content::ResourceContext* context, |
281 int child_id, | 288 int child_id, |
282 int route_id, | 289 int route_id, |
283 int request_id, | 290 int request_id, |
284 const DownloadSaveInfo& save_info, | 291 const DownloadSaveInfo& save_info, |
285 const DownloadResourceHandler::OnStartedCallback& started_cb); | 292 const DownloadResourceHandler::OnStartedCallback& started_cb); |
286 | 293 |
294 // SSLErrorHandler::Delegate | |
295 virtual ResourceType::Type ResourceTypeForInstance( | |
296 const SSLErrorHandler::instance_id& id) OVERRIDE; | |
297 | |
298 virtual const GURL& URLForInstance( | |
299 const SSLErrorHandler::instance_id& id) OVERRIDE; | |
300 | |
301 virtual bool RenderViewForInstance(const SSLErrorHandler::instance_id& id, | |
302 int* render_process_host_id, | |
303 int* render_view_host_id) OVERRIDE; | |
304 | |
305 virtual void CancelRequestForInstance(const SSLErrorHandler::instance_id& id, | |
306 int error, | |
307 const net::SSLInfo* ssl_info) OVERRIDE; | |
308 | |
309 virtual void ContinueRequestForInstance( | |
310 const SSLErrorHandler::instance_id& id) OVERRIDE; | |
311 | |
287 private: | 312 private: |
288 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 313 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
289 TestBlockedRequestsProcessDies); | 314 TestBlockedRequestsProcessDies); |
290 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 315 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
291 IncrementOutstandingRequestsMemoryCost); | 316 IncrementOutstandingRequestsMemoryCost); |
292 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 317 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
293 CalculateApproximateMemoryCost); | 318 CalculateApproximateMemoryCost); |
294 | 319 |
295 class ShutdownTask; | 320 class ShutdownTask; |
296 | 321 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
537 // Maps the request ID of request that is being transferred to a new RVH | 562 // Maps the request ID of request that is being transferred to a new RVH |
538 // to the respective request. | 563 // to the respective request. |
539 typedef std::map<content::GlobalRequestID, net::URLRequest*> | 564 typedef std::map<content::GlobalRequestID, net::URLRequest*> |
540 TransferredNavigations; | 565 TransferredNavigations; |
541 TransferredNavigations transferred_navigations_; | 566 TransferredNavigations transferred_navigations_; |
542 | 567 |
543 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); | 568 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); |
544 }; | 569 }; |
545 | 570 |
546 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ | 571 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ |
OLD | NEW |