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

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

Issue 2197763002: Move LoaderIOThreadNotifier out of resource_dispatcher_host_impl.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move definition Created 4 years, 4 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
(...skipping 15 matching lines...) Expand all
26 #include "base/timer/timer.h" 26 #include "base/timer/timer.h"
27 #include "content/browser/download/download_resource_handler.h" 27 #include "content/browser/download/download_resource_handler.h"
28 #include "content/browser/download/save_types.h" 28 #include "content/browser/download/save_types.h"
29 #include "content/browser/loader/global_routing_id.h" 29 #include "content/browser/loader/global_routing_id.h"
30 #include "content/browser/loader/resource_loader.h" 30 #include "content/browser/loader/resource_loader.h"
31 #include "content/browser/loader/resource_loader_delegate.h" 31 #include "content/browser/loader/resource_loader_delegate.h"
32 #include "content/browser/loader/resource_scheduler.h" 32 #include "content/browser/loader/resource_scheduler.h"
33 #include "content/common/content_export.h" 33 #include "content/common/content_export.h"
34 #include "content/public/browser/global_request_id.h" 34 #include "content/public/browser/global_request_id.h"
35 #include "content/public/browser/resource_dispatcher_host.h" 35 #include "content/public/browser/resource_dispatcher_host.h"
36 #include "content/public/browser/web_contents_observer.h"
37 #include "content/public/common/request_context_type.h" 36 #include "content/public/common/request_context_type.h"
38 #include "content/public/common/resource_type.h" 37 #include "content/public/common/resource_type.h"
39 #include "ipc/ipc_message.h" 38 #include "ipc/ipc_message.h"
40 #include "net/base/request_priority.h" 39 #include "net/base/request_priority.h"
41 #include "net/cookies/canonical_cookie.h" 40 #include "net/cookies/canonical_cookie.h"
42 #include "net/url_request/url_request.h" 41 #include "net/url_request/url_request.h"
43 42
44 class ResourceHandler; 43 class ResourceHandler;
45 44
46 namespace base { 45 namespace base {
47 class FilePath; 46 class FilePath;
48 } 47 }
49 48
50 namespace net { 49 namespace net {
51 class URLRequestJobFactory; 50 class URLRequestJobFactory;
52 } 51 }
53 52
54 namespace storage { 53 namespace storage {
55 class ShareableFileReference; 54 class ShareableFileReference;
56 } 55 }
57 56
58 namespace content { 57 namespace content {
59 class AppCacheService; 58 class AppCacheService;
60 class AsyncRevalidationManager; 59 class AsyncRevalidationManager;
61 class CertStore; 60 class CertStore;
62 class FrameTree;
63 class LoaderDelegate; 61 class LoaderDelegate;
64 class NavigationURLLoaderImplCore; 62 class NavigationURLLoaderImplCore;
65 class RenderFrameHostImpl; 63 class RenderFrameHostImpl;
66 class ResourceContext; 64 class ResourceContext;
67 class ResourceDispatcherHostDelegate; 65 class ResourceDispatcherHostDelegate;
68 class ResourceMessageDelegate; 66 class ResourceMessageDelegate;
69 class ResourceMessageFilter; 67 class ResourceMessageFilter;
70 class ResourceRequestInfoImpl; 68 class ResourceRequestInfoImpl;
71 class SaveFileManager; 69 class SaveFileManager;
72 class ServiceWorkerNavigationHandleCore; 70 class ServiceWorkerNavigationHandleCore;
73 struct CommonNavigationParams; 71 struct CommonNavigationParams;
74 struct DownloadSaveInfo; 72 struct DownloadSaveInfo;
75 struct NavigationRequestInfo; 73 struct NavigationRequestInfo;
76 struct Referrer; 74 struct Referrer;
77 struct ResourceRequest; 75 struct ResourceRequest;
78 76
79 // This class is responsible for notifying the IO thread (specifically, the
80 // ResourceDispatcherHostImpl) of frame events. It has an interace for callers
81 // to use and also sends notifications on WebContentsObserver events. All
82 // methods (static or class) will be called from the UI thread and post to the
83 // IO thread.
84 // TODO(csharrison): Add methods tracking visibility and audio changes, to
85 // propogate to the ResourceScheduler.
86 class LoaderIOThreadNotifier : public WebContentsObserver {
87 public:
88 explicit LoaderIOThreadNotifier(WebContents* web_contents);
89 ~LoaderIOThreadNotifier() override;
90
91 // content::WebContentsObserver:
92 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
93 };
94
95 class CONTENT_EXPORT ResourceDispatcherHostImpl 77 class CONTENT_EXPORT ResourceDispatcherHostImpl
96 : public ResourceDispatcherHost, 78 : public ResourceDispatcherHost,
97 public ResourceLoaderDelegate { 79 public ResourceLoaderDelegate {
98 public: 80 public:
99 ResourceDispatcherHostImpl(); 81 ResourceDispatcherHostImpl();
100 ~ResourceDispatcherHostImpl() override; 82 ~ResourceDispatcherHostImpl() override;
101 83
102 // Returns the current ResourceDispatcherHostImpl. May return NULL if it 84 // Returns the current ResourceDispatcherHostImpl. May return NULL if it
103 // hasn't been created yet. 85 // hasn't been created yet.
104 static ResourceDispatcherHostImpl* Get(); 86 static ResourceDispatcherHostImpl* Get();
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 NavigationURLLoaderImplCore* loader); 283 NavigationURLLoaderImplCore* loader);
302 284
303 // Turns on stale-while-revalidate support, regardless of command-line flags 285 // Turns on stale-while-revalidate support, regardless of command-line flags
304 // or experiment status. For unit tests only. 286 // or experiment status. For unit tests only.
305 void EnableStaleWhileRevalidateForTesting(); 287 void EnableStaleWhileRevalidateForTesting();
306 288
307 // Sets the LoaderDelegate, which must outlive this object. Ownership is not 289 // Sets the LoaderDelegate, which must outlive this object. Ownership is not
308 // transferred. The LoaderDelegate should be interacted with on the IO thread. 290 // transferred. The LoaderDelegate should be interacted with on the IO thread.
309 void SetLoaderDelegate(LoaderDelegate* loader_delegate); 291 void SetLoaderDelegate(LoaderDelegate* loader_delegate);
310 292
293 void OnRenderFrameDeleted(const GlobalFrameRoutingId& global_routing_id);
294
311 private: 295 private:
312 friend class LoaderIOThreadNotifier;
313 friend class ResourceDispatcherHostTest; 296 friend class ResourceDispatcherHostTest;
314 297
315 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 298 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
316 TestBlockedRequestsProcessDies); 299 TestBlockedRequestsProcessDies);
317 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 300 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
318 CalculateApproximateMemoryCost); 301 CalculateApproximateMemoryCost);
319 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 302 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
320 DetachableResourceTimesOut); 303 DetachableResourceTimesOut);
321 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 304 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
322 TestProcessCancelDetachableTimesOut); 305 TestProcessCancelDetachableTimesOut);
(...skipping 30 matching lines...) Expand all
353 void DidFinishLoading(ResourceLoader* loader) override; 336 void DidFinishLoading(ResourceLoader* loader) override;
354 std::unique_ptr<net::ClientCertStore> CreateClientCertStore( 337 std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
355 ResourceLoader* loader) override; 338 ResourceLoader* loader) override;
356 339
357 // An init helper that runs on the IO thread. 340 // An init helper that runs on the IO thread.
358 void OnInit(); 341 void OnInit();
359 342
360 // A shutdown helper that runs on the IO thread. 343 // A shutdown helper that runs on the IO thread.
361 void OnShutdown(); 344 void OnShutdown();
362 345
363 void OnRenderFrameDeleted(const GlobalFrameRoutingId& global_routing_id);
364
365 // Helper function for regular and download requests. 346 // Helper function for regular and download requests.
366 void BeginRequestInternal(std::unique_ptr<net::URLRequest> request, 347 void BeginRequestInternal(std::unique_ptr<net::URLRequest> request,
367 std::unique_ptr<ResourceHandler> handler); 348 std::unique_ptr<ResourceHandler> handler);
368 349
369 void StartLoading(ResourceRequestInfoImpl* info, 350 void StartLoading(ResourceRequestInfoImpl* info,
370 std::unique_ptr<ResourceLoader> loader); 351 std::unique_ptr<ResourceLoader> loader);
371 352
372 // We keep track of how much memory each request needs and how many requests 353 // We keep track of how much memory each request needs and how many requests
373 // are issued by each renderer. These are known as OustandingRequestStats. 354 // are issued by each renderer. These are known as OustandingRequestStats.
374 // Memory limits apply to all requests sent to us by the renderers. There is a 355 // Memory limits apply to all requests sent to us by the renderers. There is a
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 // Allows tests to use a mock CertStore. If set, the CertStore must 630 // Allows tests to use a mock CertStore. If set, the CertStore must
650 // outlive this ResourceDispatcherHostImpl. 631 // outlive this ResourceDispatcherHostImpl.
651 CertStore* cert_store_for_testing_; 632 CertStore* cert_store_for_testing_;
652 633
653 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); 634 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl);
654 }; 635 };
655 636
656 } // namespace content 637 } // namespace content
657 638
658 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 639 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/loader/loader_io_thread_notifier.cc ('k') | content/browser/loader/resource_dispatcher_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698