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

Side by Side Diff: chrome/browser/renderer_host/resource_dispatcher_host.h

Issue 3396029: Flesh out URLLoader's download_to_file function.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 months 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 29 matching lines...) Expand all
40 class SocketStreamDispatcherHost; 40 class SocketStreamDispatcherHost;
41 class SSLClientAuthHandler; 41 class SSLClientAuthHandler;
42 class UserScriptListener; 42 class UserScriptListener;
43 class URLRequestContext; 43 class URLRequestContext;
44 class WebKitThread; 44 class WebKitThread;
45 struct DownloadSaveInfo; 45 struct DownloadSaveInfo;
46 struct GlobalRequestID; 46 struct GlobalRequestID;
47 struct ViewHostMsg_Resource_Request; 47 struct ViewHostMsg_Resource_Request;
48 struct ViewMsg_ClosePage_Params; 48 struct ViewMsg_ClosePage_Params;
49 49
50 namespace webkit_blob {
51 class DeletableFileReference;
52 }
53
50 class ResourceDispatcherHost : public URLRequest::Delegate { 54 class ResourceDispatcherHost : public URLRequest::Delegate {
51 public: 55 public:
52 // Implemented by the client of ResourceDispatcherHost to receive messages in 56 // Implemented by the client of ResourceDispatcherHost to receive messages in
53 // response to a resource load. The messages are intended to be forwarded to 57 // response to a resource load. The messages are intended to be forwarded to
54 // the ResourceDispatcher in the child process via an IPC channel that the 58 // the ResourceDispatcher in the child process via an IPC channel that the
55 // client manages. 59 // client manages.
56 // 60 //
57 // NOTE: This class unfortunately cannot be named 'Delegate' because that 61 // NOTE: This class unfortunately cannot be named 'Delegate' because that
58 // conflicts with the name of ResourceDispatcherHost's base class. 62 // conflicts with the name of ResourceDispatcherHost's base class.
59 // 63 //
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 void ResumeBlockedRequestsForRoute(int process_unique_id, int route_id); 261 void ResumeBlockedRequestsForRoute(int process_unique_id, int route_id);
258 262
259 // Cancels any blocked request for the specified route id. 263 // Cancels any blocked request for the specified route id.
260 void CancelBlockedRequestsForRoute(int process_unique_id, int route_id); 264 void CancelBlockedRequestsForRoute(int process_unique_id, int route_id);
261 265
262 // Decrements the pending_data_count for the request and resumes 266 // Decrements the pending_data_count for the request and resumes
263 // the request if it was paused due to too many pending data 267 // the request if it was paused due to too many pending data
264 // messages sent. 268 // messages sent.
265 void DataReceivedACK(int process_unique_id, int request_id); 269 void DataReceivedACK(int process_unique_id, int request_id);
266 270
271 // Maintains a collection of temp files created in support of
272 // the download_to_file capability. Used to grant access to the
273 // child process and to defer deletion of the file until it's
274 // no longer needed.
275 void RegisterDownloadedTempFile(
276 int receiver_id, int request_id,
277 webkit_blob::DeletableFileReference* reference);
278 void UnregisterDownloadedTempFile(int receiver_id, int request_id);
279
267 // Needed for the sync IPC message dispatcher macros. 280 // Needed for the sync IPC message dispatcher macros.
268 bool Send(IPC::Message* message); 281 bool Send(IPC::Message* message);
269 282
270 // Controls if we launch or squash prefetch requests as they arrive 283 // Controls if we launch or squash prefetch requests as they arrive
271 // from renderers. 284 // from renderers.
272 static bool is_prefetch_enabled(); 285 static bool is_prefetch_enabled();
273 static void set_is_prefetch_enabled(bool value); 286 static void set_is_prefetch_enabled(bool value);
274 287
275 private: 288 private:
276 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 289 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 int request_id, 403 int request_id,
391 const ViewHostMsg_Resource_Request& request_data); 404 const ViewHostMsg_Resource_Request& request_data);
392 void OnSyncLoad(int request_id, 405 void OnSyncLoad(int request_id,
393 const ViewHostMsg_Resource_Request& request_data, 406 const ViewHostMsg_Resource_Request& request_data,
394 IPC::Message* sync_result); 407 IPC::Message* sync_result);
395 void BeginRequest(int request_id, 408 void BeginRequest(int request_id,
396 const ViewHostMsg_Resource_Request& request_data, 409 const ViewHostMsg_Resource_Request& request_data,
397 IPC::Message* sync_result, // only valid for sync 410 IPC::Message* sync_result, // only valid for sync
398 int route_id); // only valid for async 411 int route_id); // only valid for async
399 void OnDataReceivedACK(int request_id); 412 void OnDataReceivedACK(int request_id);
413 void OnDataDownloadedACK(int request_id);
400 void OnUploadProgressACK(int request_id); 414 void OnUploadProgressACK(int request_id);
401 void OnCancelRequest(int request_id); 415 void OnCancelRequest(int request_id);
402 void OnFollowRedirect(int request_id, 416 void OnFollowRedirect(int request_id,
403 bool has_new_first_party_for_cookies, 417 bool has_new_first_party_for_cookies,
404 const GURL& new_first_party_for_cookies); 418 const GURL& new_first_party_for_cookies);
419 void OnReleaseDownloadedFile(int request_id);
405 420
406 ResourceHandler* CreateSafeBrowsingResourceHandler( 421 ResourceHandler* CreateSafeBrowsingResourceHandler(
407 ResourceHandler* handler, int child_id, int route_id, 422 ResourceHandler* handler, int child_id, int route_id,
408 ResourceType::Type resource_type); 423 ResourceType::Type resource_type);
409 424
410 // Creates ResourceDispatcherHostRequestInfo for a browser-initiated request 425 // Creates ResourceDispatcherHostRequestInfo for a browser-initiated request
411 // (a download or a page save). |download| should be true if the request 426 // (a download or a page save). |download| should be true if the request
412 // is a file download. 427 // is a file download.
413 ResourceDispatcherHostRequestInfo* CreateRequestInfoForBrowserRequest( 428 ResourceDispatcherHostRequestInfo* CreateRequestInfoForBrowserRequest(
414 ResourceHandler* handler, int child_id, int route_id, bool download); 429 ResourceHandler* handler, int child_id, int route_id, bool download);
(...skipping 10 matching lines...) Expand all
425 const GURL& url, 440 const GURL& url,
426 const ResourceType::Type& resource_type, 441 const ResourceType::Type& resource_type,
427 ResourceDispatcherHostRequestInfo* request_info); 442 ResourceDispatcherHostRequestInfo* request_info);
428 443
429 // Determine request priority based on how critical this resource typically 444 // Determine request priority based on how critical this resource typically
430 // is to user-perceived page load performance. 445 // is to user-perceived page load performance.
431 static net::RequestPriority DetermineRequestPriority(ResourceType::Type type); 446 static net::RequestPriority DetermineRequestPriority(ResourceType::Type type);
432 447
433 PendingRequestList pending_requests_; 448 PendingRequestList pending_requests_;
434 449
450 // Collection of temp files downloaded for child processes via
451 // the download_to_file mechanism. We avoid deleting them until
452 // the client no longer needs them.
453 typedef std::map<int, scoped_refptr<webkit_blob::DeletableFileReference> >
454 DeletableFilesMap; // key is request id
455 typedef std::map<int, DeletableFilesMap>
456 RegisteredTempFiles; // key is child process id
457 RegisteredTempFiles registered_temp_files_;
458
435 // A timer that periodically calls UpdateLoadStates while pending_requests_ 459 // A timer that periodically calls UpdateLoadStates while pending_requests_
436 // is not empty. 460 // is not empty.
437 base::RepeatingTimer<ResourceDispatcherHost> update_load_states_timer_; 461 base::RepeatingTimer<ResourceDispatcherHost> update_load_states_timer_;
438 462
439 // Handles the resource requests from the moment we want to start them. 463 // Handles the resource requests from the moment we want to start them.
440 ResourceQueue resource_queue_; 464 ResourceQueue resource_queue_;
441 465
442 // We own the download file writing thread and manager 466 // We own the download file writing thread and manager
443 scoped_refptr<DownloadFileManager> download_file_manager_; 467 scoped_refptr<DownloadFileManager> download_file_manager_;
444 468
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 // Used during IPC message dispatching so that the handlers can get a pointer 521 // Used during IPC message dispatching so that the handlers can get a pointer
498 // to the source of the message. 522 // to the source of the message.
499 Receiver* receiver_; 523 Receiver* receiver_;
500 524
501 static bool is_prefetch_enabled_; 525 static bool is_prefetch_enabled_;
502 526
503 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); 527 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost);
504 }; 528 };
505 529
506 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ 530 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698