Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_THROTTLE_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_THROTTLE_H_ |
| 6 #define CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_THROTTLE_H_ | 6 #define CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_THROTTLE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "content/common/url_loader.mojom.h" | |
| 11 #include "content/public/browser/navigation_throttle.h" | 12 #include "content/public/browser/navigation_throttle.h" |
| 12 #include "content/public/browser/resource_throttle.h" | 13 #include "content/public/browser/resource_throttle.h" |
| 13 #include "content/public/common/request_context_type.h" | 14 #include "content/public/common/request_context_type.h" |
| 14 | 15 |
| 15 namespace net { | 16 namespace net { |
| 16 class URLRequest; | 17 class URLRequest; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 class ResourceDispatcherHostDelegate; | 21 class ResourceDispatcherHostDelegate; |
| 21 | 22 |
| 22 // This ResourceThrottle is used to convey throttling information to the UI | 23 // This ResourceThrottle is used to convey throttling information to the UI |
| 23 // thread during navigations. The UI thread can then use its NavigationThrottle | 24 // thread during navigations. The UI thread can then use its NavigationThrottle |
| 24 // mechanism to interact with the navigation. | 25 // mechanism to interact with the navigation. |
| 25 class NavigationResourceThrottle : public ResourceThrottle { | 26 class NavigationResourceThrottle : public ResourceThrottle { |
| 26 public: | 27 public: |
| 28 using TransferCallback = | |
| 29 base::Callback<void(mojom::URLLoaderAssociatedRequest, | |
| 30 mojom::URLLoaderClientAssociatedPtr)>; | |
| 31 | |
| 27 NavigationResourceThrottle( | 32 NavigationResourceThrottle( |
| 28 net::URLRequest* request, | 33 net::URLRequest* request, |
| 29 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate, | 34 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate, |
| 30 RequestContextType request_context_type); | 35 RequestContextType request_context_type, |
| 36 const TransferCallback& on_transfer); | |
| 31 ~NavigationResourceThrottle() override; | 37 ~NavigationResourceThrottle() override; |
| 32 | 38 |
| 33 // ResourceThrottle overrides: | 39 // ResourceThrottle overrides: |
| 34 void WillStartRequest(bool* defer) override; | 40 void WillStartRequest(bool* defer) override; |
| 35 void WillRedirectRequest(const net::RedirectInfo& redirect_info, | 41 void WillRedirectRequest(const net::RedirectInfo& redirect_info, |
| 36 bool* defer) override; | 42 bool* defer) override; |
| 37 void WillProcessResponse(bool* defer) override; | 43 void WillProcessResponse(bool* defer) override; |
| 38 const char* GetNameForLogging() const override; | 44 const char* GetNameForLogging() const override; |
| 39 | 45 |
| 40 // Used in unit tests to make UI checks pass when they would fail due to no | 46 // Used in unit tests to make UI checks pass when they would fail due to no |
| 41 // NavigationHandle being present in the RenderFrameHost. | 47 // NavigationHandle being present in the RenderFrameHost. |
| 42 CONTENT_EXPORT static void set_ui_checks_always_succeed_for_testing( | 48 CONTENT_EXPORT static void set_ui_checks_always_succeed_for_testing( |
| 43 bool ui_checks_always_succeed); | 49 bool ui_checks_always_succeed); |
| 44 | 50 |
| 45 // Used in unit tests to make all navigations transfer. | 51 // Used in unit tests to make all navigations transfer. |
| 46 CONTENT_EXPORT static void set_force_transfer_for_testing( | 52 CONTENT_EXPORT static void set_force_transfer_for_testing( |
| 47 bool force_transfer); | 53 bool force_transfer); |
| 48 | 54 |
| 49 private: | 55 private: |
| 50 void OnUIChecksPerformed(NavigationThrottle::ThrottleCheckResult result); | 56 void OnUIChecksPerformed(NavigationThrottle::ThrottleCheckResult result); |
| 51 | 57 |
| 52 // Used in transfer navigations. | 58 // Used in transfer navigations. |
| 53 void InitiateTransfer(); | 59 void InitiateTransfer(); |
| 54 void OnTransferComplete(); | 60 void OnTransferComplete( |
| 61 mojom::URLLoaderAssociatedRequest mojo_request, | |
|
clamy
2016/11/21 17:55:54
Should mojo_request/url_load_client be passed as c
yhirano
2016/11/22 08:12:55
These are movable-but-not-copyable types, so I thi
| |
| 62 mojom::URLLoaderClientAssociatedPtr url_loader_client); | |
| 55 | 63 |
| 56 net::URLRequest* request_; | 64 net::URLRequest* request_; |
| 57 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate_; | 65 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate_; |
| 58 RequestContextType request_context_type_; | 66 RequestContextType request_context_type_; |
| 59 bool in_cross_site_transition_; | 67 bool in_cross_site_transition_; |
| 60 NavigationThrottle::ThrottleCheckResult on_transfer_done_result_; | 68 NavigationThrottle::ThrottleCheckResult on_transfer_done_result_; |
| 69 TransferCallback on_transfer_; | |
| 61 | 70 |
| 62 base::WeakPtrFactory<NavigationResourceThrottle> weak_ptr_factory_; | 71 base::WeakPtrFactory<NavigationResourceThrottle> weak_ptr_factory_; |
| 63 | 72 |
| 64 DISALLOW_COPY_AND_ASSIGN(NavigationResourceThrottle); | 73 DISALLOW_COPY_AND_ASSIGN(NavigationResourceThrottle); |
| 65 }; | 74 }; |
| 66 | 75 |
| 67 } // namespace content | 76 } // namespace content |
| 68 | 77 |
| 69 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_THROTTLE_H_ | 78 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_RESOURCE_THROTTLE_H_ |
| OLD | NEW |