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

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

Issue 1041993004: content::ResourceDispatcherHostImpl changes for stale-while-revalidate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@s-w-r-yhirano-patch
Patch Set: Readability improvements suggested by tyoshino Created 5 years, 6 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
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_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 12 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
13 #define CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 13 #define CONTENT_BROWSER_LOADER_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 <utility>
18 #include <vector> 19 #include <vector>
19 20
20 #include "base/basictypes.h" 21 #include "base/basictypes.h"
21 #include "base/gtest_prod_util.h" 22 #include "base/gtest_prod_util.h"
22 #include "base/memory/linked_ptr.h" 23 #include "base/memory/linked_ptr.h"
23 #include "base/memory/scoped_ptr.h" 24 #include "base/memory/scoped_ptr.h"
24 #include "base/observer_list.h" 25 #include "base/observer_list.h"
25 #include "base/time/time.h" 26 #include "base/time/time.h"
26 #include "base/timer/timer.h" 27 #include "base/timer/timer.h"
27 #include "content/browser/download/download_resource_handler.h" 28 #include "content/browser/download/download_resource_handler.h"
(...skipping 11 matching lines...) Expand all
39 #include "content/public/browser/resource_dispatcher_host.h" 40 #include "content/public/browser/resource_dispatcher_host.h"
40 #include "content/public/common/resource_type.h" 41 #include "content/public/common/resource_type.h"
41 #include "ipc/ipc_message.h" 42 #include "ipc/ipc_message.h"
42 #include "net/cookies/canonical_cookie.h" 43 #include "net/cookies/canonical_cookie.h"
43 #include "net/url_request/url_request.h" 44 #include "net/url_request/url_request.h"
44 45
45 class ResourceHandler; 46 class ResourceHandler;
46 struct ResourceHostMsg_Request; 47 struct ResourceHostMsg_Request;
47 48
48 namespace net { 49 namespace net {
50 class URLRequestContext;
49 class URLRequestJobFactory; 51 class URLRequestJobFactory;
52 class HttpCache;
50 } 53 }
51 54
52 namespace storage { 55 namespace storage {
53 class ShareableFileReference; 56 class ShareableFileReference;
54 } 57 }
55 58
56 namespace content { 59 namespace content {
57 class AppCacheService; 60 class AppCacheService;
58 class NavigationURLLoaderImplCore; 61 class NavigationURLLoaderImplCore;
59 class ResourceContext; 62 class ResourceContext;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 int route_id, 418 int route_id,
416 int request_id, 419 int request_id,
417 const ResourceHostMsg_Request& request_data, 420 const ResourceHostMsg_Request& request_data,
418 const linked_ptr<ResourceLoader>& loader); 421 const linked_ptr<ResourceLoader>& loader);
419 422
420 void BeginRequest(int request_id, 423 void BeginRequest(int request_id,
421 const ResourceHostMsg_Request& request_data, 424 const ResourceHostMsg_Request& request_data,
422 IPC::Message* sync_result, // only valid for sync 425 IPC::Message* sync_result, // only valid for sync
423 int route_id); // only valid for async 426 int route_id); // only valid for async
424 427
428 void BeginRequestFromData(int request_id,
429 const ResourceHostMsg_Request& request_data,
430 IPC::Message* sync_result,
431 int process_type,
432 int child_id,
433 int route_id,
434 bool is_async_revalidation,
435 net::URLRequestContext* request_context,
436 ResourceContext* resource_context);
437
425 // Creates a ResourceHandler to be used by BeginRequest() for normal resource 438 // Creates a ResourceHandler to be used by BeginRequest() for normal resource
426 // loading. 439 // loading.
427 scoped_ptr<ResourceHandler> CreateResourceHandler( 440 scoped_ptr<ResourceHandler> CreateResourceHandler(
428 net::URLRequest* request, 441 net::URLRequest* request,
429 const ResourceHostMsg_Request& request_data, 442 const ResourceHostMsg_Request& request_data,
430 IPC::Message* sync_result, 443 IPC::Message* sync_result,
431 int route_id, 444 int route_id,
432 int process_type, 445 int process_type,
433 int child_id, 446 int child_id,
447 bool is_async_revalidation,
434 ResourceContext* resource_context); 448 ResourceContext* resource_context);
435 449
450 // Wraps |handler| in the BufferedResourceHandler, enabling mime-type sniffing
451 // and redirecting to download or plugins as appropriate.
452 scoped_ptr<ResourceHandler> AddBufferedResourceHandler(
453 net::URLRequest* request,
454 scoped_ptr<ResourceHandler> handler);
455
436 // Wraps |handler| in the standard resource handlers for normal resource 456 // Wraps |handler| in the standard resource handlers for normal resource
437 // loading and navigation requests. This adds BufferedResourceHandler and 457 // loading and navigation requests. This adds ResourceThrottles.
438 // ResourceThrottles. 458 scoped_ptr<ResourceHandler> AddThrottlesAndSchedule(
439 scoped_ptr<ResourceHandler> AddStandardHandlers(
440 net::URLRequest* request, 459 net::URLRequest* request,
441 ResourceType resource_type, 460 ResourceType resource_type,
442 ResourceContext* resource_context, 461 ResourceContext* resource_context,
443 AppCacheService* appcache_service, 462 AppCacheService* appcache_service,
444 int child_id, 463 int child_id,
445 int route_id, 464 int route_id,
446 scoped_ptr<ResourceHandler> handler); 465 scoped_ptr<ResourceHandler> handler);
447 466
448 void OnDataDownloadedACK(int request_id); 467 void OnDataDownloadedACK(int request_id);
449 void OnUploadProgressACK(int request_id); 468 void OnUploadProgressACK(int request_id);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 // specified |id|. 503 // specified |id|.
485 void RegisterResourceMessageDelegate(const GlobalRequestID& id, 504 void RegisterResourceMessageDelegate(const GlobalRequestID& id,
486 ResourceMessageDelegate* delegate); 505 ResourceMessageDelegate* delegate);
487 void UnregisterResourceMessageDelegate(const GlobalRequestID& id, 506 void UnregisterResourceMessageDelegate(const GlobalRequestID& id,
488 ResourceMessageDelegate* delegate); 507 ResourceMessageDelegate* delegate);
489 508
490 int BuildLoadFlagsForRequest(const ResourceHostMsg_Request& request_data, 509 int BuildLoadFlagsForRequest(const ResourceHostMsg_Request& request_data,
491 int child_id, 510 int child_id,
492 bool is_sync_load); 511 bool is_sync_load);
493 512
513 void BeginAsyncRevalidation(net::URLRequest* for_request);
514
494 LoaderMap pending_loaders_; 515 LoaderMap pending_loaders_;
495 516
496 // Collection of temp files downloaded for child processes via 517 // Collection of temp files downloaded for child processes via
497 // the download_to_file mechanism. We avoid deleting them until 518 // the download_to_file mechanism. We avoid deleting them until
498 // the client no longer needs them. 519 // the client no longer needs them.
499 typedef std::map<int, scoped_refptr<storage::ShareableFileReference> > 520 typedef std::map<int, scoped_refptr<storage::ShareableFileReference> >
500 DeletableFilesMap; // key is request id 521 DeletableFilesMap; // key is request id
501 typedef std::map<int, DeletableFilesMap> 522 typedef std::map<int, DeletableFilesMap>
502 RegisteredTempFiles; // key is child process id 523 RegisteredTempFiles; // key is child process id
503 RegisteredTempFiles registered_temp_files_; 524 RegisteredTempFiles registered_temp_files_;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 base::TimeTicks last_user_gesture_time_; 583 base::TimeTicks last_user_gesture_time_;
563 584
564 // Used during IPC message dispatching so that the handlers can get a pointer 585 // Used during IPC message dispatching so that the handlers can get a pointer
565 // to the source of the message. 586 // to the source of the message.
566 ResourceMessageFilter* filter_; 587 ResourceMessageFilter* filter_;
567 588
568 ResourceDispatcherHostDelegate* delegate_; 589 ResourceDispatcherHostDelegate* delegate_;
569 590
570 bool allow_cross_origin_auth_prompt_; 591 bool allow_cross_origin_auth_prompt_;
571 592
593 // stale-while-revalidate is enabled either via experiment or command-line
594 // flag.
595 bool async_revalidation_enabled_;
596
597 // In progress async revalidations.
598 std::set<std::pair<net::HttpCache*, std::string>>
599 in_progress_async_revalidations_;
600
572 // http://crbug.com/90971 - Assists in tracking down use-after-frees on 601 // http://crbug.com/90971 - Assists in tracking down use-after-frees on
573 // shutdown. 602 // shutdown.
574 std::set<const ResourceContext*> active_resource_contexts_; 603 std::set<const ResourceContext*> active_resource_contexts_;
575 604
576 typedef std::map<GlobalRequestID, 605 typedef std::map<GlobalRequestID,
577 ObserverList<ResourceMessageDelegate>*> DelegateMap; 606 ObserverList<ResourceMessageDelegate>*> DelegateMap;
578 DelegateMap delegate_map_; 607 DelegateMap delegate_map_;
579 608
580 scoped_ptr<ResourceScheduler> scheduler_; 609 scoped_ptr<ResourceScheduler> scheduler_;
581 610
582 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); 611 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl);
583 }; 612 };
584 613
585 } // namespace content 614 } // namespace content
586 615
587 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 616 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698