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

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

Issue 2785523002: Reduce/remove usage of BrowserThread in content/browser/loader. (Closed)
Patch Set: Remove DCHECK Created 3 years, 8 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 <stdint.h> 15 #include <stdint.h>
16 16
17 #include <map> 17 #include <map>
18 #include <memory> 18 #include <memory>
19 #include <string> 19 #include <string>
20 #include <vector> 20 #include <vector>
21 21
22 #include "base/callback_forward.h" 22 #include "base/callback_forward.h"
23 #include "base/gtest_prod_util.h" 23 #include "base/gtest_prod_util.h"
24 #include "base/macros.h" 24 #include "base/macros.h"
25 #include "base/memory/ref_counted.h" 25 #include "base/memory/ref_counted.h"
26 #include "base/observer_list.h" 26 #include "base/observer_list.h"
27 #include "base/single_thread_task_runner.h"
27 #include "base/time/time.h" 28 #include "base/time/time.h"
28 #include "content/browser/loader/global_routing_id.h" 29 #include "content/browser/loader/global_routing_id.h"
29 #include "content/browser/loader/resource_loader_delegate.h" 30 #include "content/browser/loader/resource_loader_delegate.h"
30 #include "content/common/content_export.h" 31 #include "content/common/content_export.h"
31 #include "content/common/url_loader.mojom.h" 32 #include "content/common/url_loader.mojom.h"
32 #include "content/public/browser/global_request_id.h" 33 #include "content/public/browser/global_request_id.h"
33 #include "content/public/browser/resource_dispatcher_host.h" 34 #include "content/public/browser/resource_dispatcher_host.h"
34 #include "content/public/browser/resource_request_info.h" 35 #include "content/public/browser/resource_request_info.h"
35 #include "content/public/common/previews_state.h" 36 #include "content/public/common/previews_state.h"
36 #include "content/public/common/request_context_type.h" 37 #include "content/public/common/request_context_type.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // Used to handle the result of SyncLoad IPC. |result| is null if it's 85 // Used to handle the result of SyncLoad IPC. |result| is null if it's
85 // unavailable due to an error. 86 // unavailable due to an error.
86 using SyncLoadResultCallback = 87 using SyncLoadResultCallback =
87 base::Callback<void(const SyncLoadResult* result)>; 88 base::Callback<void(const SyncLoadResult* result)>;
88 89
89 // This constructor should be used if we want downloads to work correctly. 90 // This constructor should be used if we want downloads to work correctly.
90 // TODO(ananta) 91 // TODO(ananta)
91 // Work on moving creation of download handlers out of 92 // Work on moving creation of download handlers out of
92 // ResourceDispatcherHostImpl. 93 // ResourceDispatcherHostImpl.
93 ResourceDispatcherHostImpl( 94 ResourceDispatcherHostImpl(
94 CreateDownloadHandlerIntercept download_handler_intercept); 95 CreateDownloadHandlerIntercept download_handler_intercept,
96 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_runner);
95 ResourceDispatcherHostImpl(); 97 ResourceDispatcherHostImpl();
96 ~ResourceDispatcherHostImpl() override; 98 ~ResourceDispatcherHostImpl() override;
97 99
98 // Returns the current ResourceDispatcherHostImpl. May return NULL if it 100 // Returns the current ResourceDispatcherHostImpl. May return NULL if it
99 // hasn't been created yet. 101 // hasn't been created yet.
100 static ResourceDispatcherHostImpl* Get(); 102 static ResourceDispatcherHostImpl* Get();
101 103
102 // ResourceDispatcherHost implementation: 104 // ResourceDispatcherHost implementation:
103 void SetDelegate(ResourceDispatcherHostDelegate* delegate) override; 105 void SetDelegate(ResourceDispatcherHostDelegate* delegate) override;
104 void SetAllowCrossOriginAuthPrompt(bool value) override; 106 void SetAllowCrossOriginAuthPrompt(bool value) override;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // Creates a new request ID for browser initiated requests. See the comments 323 // Creates a new request ID for browser initiated requests. See the comments
322 // of |request_id_| for the details. Must be called on the IO thread. 324 // of |request_id_| for the details. Must be called on the IO thread.
323 int MakeRequestID(); 325 int MakeRequestID();
324 326
325 // Cancels a request as requested by a renderer. This function is called when 327 // Cancels a request as requested by a renderer. This function is called when
326 // a mojo connection is lost. 328 // a mojo connection is lost.
327 // Note that this cancel is subtly different from the other CancelRequest 329 // Note that this cancel is subtly different from the other CancelRequest
328 // methods in this file, which also tear down the loader. 330 // methods in this file, which also tear down the loader.
329 void CancelRequestFromRenderer(GlobalRequestID request_id); 331 void CancelRequestFromRenderer(GlobalRequestID request_id);
330 332
333 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner() const {
334 return io_thread_task_runner_;
335 }
336
337 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner() const {
338 return main_thread_task_runner_;
339 }
340
331 private: 341 private:
332 friend class ResourceDispatcherHostTest; 342 friend class ResourceDispatcherHostTest;
333 343
334 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 344 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
335 TestBlockedRequestsProcessDies); 345 TestBlockedRequestsProcessDies);
336 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 346 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
337 CalculateApproximateMemoryCost); 347 CalculateApproximateMemoryCost);
338 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 348 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
339 DetachableResourceTimesOut); 349 DetachableResourceTimesOut);
340 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, 350 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 DelegateMap delegate_map_; 760 DelegateMap delegate_map_;
751 761
752 std::unique_ptr<ResourceScheduler> scheduler_; 762 std::unique_ptr<ResourceScheduler> scheduler_;
753 763
754 // Used to invoke an interceptor for the HTTP header. 764 // Used to invoke an interceptor for the HTTP header.
755 HeaderInterceptorMap http_header_interceptor_map_; 765 HeaderInterceptorMap http_header_interceptor_map_;
756 766
757 // Points to the registered download handler intercept. 767 // Points to the registered download handler intercept.
758 CreateDownloadHandlerIntercept create_download_handler_intercept_; 768 CreateDownloadHandlerIntercept create_download_handler_intercept_;
759 769
770 // Task runner for the main thread.
771 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
772
773 // Task runner for the IO thead.
774 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
775
760 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); 776 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl);
761 }; 777 };
762 778
763 } // namespace content 779 } // namespace content
764 780
765 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 781 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/loader/async_resource_handler_unittest.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