| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include "content/public/test/navigation_simulator.h" | 5 #include "content/public/test/navigation_simulator.h" |
| 6 | 6 |
| 7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "content/public/browser/navigation_handle.h" | 9 #include "content/public/browser/navigation_handle.h" |
| 10 #include "content/public/browser/navigation_throttle.h" | 10 #include "content/public/browser/navigation_throttle.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override { | 64 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override { |
| 65 return ProcessState(cancel_time_ == WILL_REDIRECT_REQUEST); | 65 return ProcessState(cancel_time_ == WILL_REDIRECT_REQUEST); |
| 66 } | 66 } |
| 67 | 67 |
| 68 NavigationThrottle::ThrottleCheckResult WillProcessResponse() override { | 68 NavigationThrottle::ThrottleCheckResult WillProcessResponse() override { |
| 69 return ProcessState(cancel_time_ == WILL_PROCESS_RESPONSE); | 69 return ProcessState(cancel_time_ == WILL_PROCESS_RESPONSE); |
| 70 } | 70 } |
| 71 | 71 |
| 72 const char* GetNameForLogging() override { |
| 73 return "CancellingNavigationThrottle"; |
| 74 } |
| 75 |
| 72 NavigationThrottle::ThrottleCheckResult ProcessState(bool should_cancel) { | 76 NavigationThrottle::ThrottleCheckResult ProcessState(bool should_cancel) { |
| 73 if (sync_ == ASYNCHRONOUS) { | 77 if (sync_ == ASYNCHRONOUS) { |
| 74 BrowserThread::PostTask( | 78 BrowserThread::PostTask( |
| 75 BrowserThread::UI, FROM_HERE, | 79 BrowserThread::UI, FROM_HERE, |
| 76 base::Bind(&CancellingNavigationThrottle::MaybeCancel, | 80 base::Bind(&CancellingNavigationThrottle::MaybeCancel, |
| 77 weak_ptr_factory_.GetWeakPtr(), should_cancel)); | 81 weak_ptr_factory_.GetWeakPtr(), should_cancel)); |
| 78 return NavigationThrottle::DEFER; | 82 return NavigationThrottle::DEFER; |
| 79 } | 83 } |
| 80 return should_cancel ? NavigationThrottle::CANCEL | 84 return should_cancel ? NavigationThrottle::CANCEL |
| 81 : NavigationThrottle::PROCEED; | 85 : NavigationThrottle::PROCEED; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 ::testing::Values(std::make_tuple(WILL_SEND_REQUEST, SYNCHRONOUS), | 161 ::testing::Values(std::make_tuple(WILL_SEND_REQUEST, SYNCHRONOUS), |
| 158 std::make_tuple(WILL_SEND_REQUEST, ASYNCHRONOUS), | 162 std::make_tuple(WILL_SEND_REQUEST, ASYNCHRONOUS), |
| 159 std::make_tuple(WILL_REDIRECT_REQUEST, SYNCHRONOUS), | 163 std::make_tuple(WILL_REDIRECT_REQUEST, SYNCHRONOUS), |
| 160 std::make_tuple(WILL_REDIRECT_REQUEST, ASYNCHRONOUS), | 164 std::make_tuple(WILL_REDIRECT_REQUEST, ASYNCHRONOUS), |
| 161 std::make_tuple(WILL_PROCESS_RESPONSE, SYNCHRONOUS), | 165 std::make_tuple(WILL_PROCESS_RESPONSE, SYNCHRONOUS), |
| 162 std::make_tuple(WILL_PROCESS_RESPONSE, ASYNCHRONOUS), | 166 std::make_tuple(WILL_PROCESS_RESPONSE, ASYNCHRONOUS), |
| 163 std::make_tuple(NEVER, SYNCHRONOUS), | 167 std::make_tuple(NEVER, SYNCHRONOUS), |
| 164 std::make_tuple(NEVER, ASYNCHRONOUS))); | 168 std::make_tuple(NEVER, ASYNCHRONOUS))); |
| 165 | 169 |
| 166 } // namespace content | 170 } // namespace content |
| OLD | NEW |