| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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_TEST_TEST_NAVIGATION_URL_LOADER_H_ | 5 #ifndef CONTENT_TEST_TEST_NAVIGATION_URL_LOADER_H_ |
| 6 #define CONTENT_TEST_TEST_NAVIGATION_URL_LOADER_H_ | 6 #define CONTENT_TEST_TEST_NAVIGATION_URL_LOADER_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include <memory> |
| 9 |
| 9 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 10 #include "content/browser/frame_host/navigation_request_info.h" | 11 #include "content/browser/frame_host/navigation_request_info.h" |
| 11 #include "content/browser/loader/navigation_url_loader.h" | 12 #include "content/browser/loader/navigation_url_loader.h" |
| 12 #include "content/common/navigation_params.h" | 13 #include "content/common/navigation_params.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 struct RedirectInfo; | 16 struct RedirectInfo; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 20 class NavigationURLLoaderDelegate; | 21 class NavigationURLLoaderDelegate; |
| 21 class StreamHandle; | 22 class StreamHandle; |
| 22 struct ResourceResponse; | 23 struct ResourceResponse; |
| 23 | 24 |
| 24 // PlzNavigate | 25 // PlzNavigate |
| 25 // Test implementation of NavigationURLLoader to simulate the network stack | 26 // Test implementation of NavigationURLLoader to simulate the network stack |
| 26 // response. | 27 // response. |
| 27 class TestNavigationURLLoader | 28 class TestNavigationURLLoader |
| 28 : public NavigationURLLoader, | 29 : public NavigationURLLoader, |
| 29 public base::SupportsWeakPtr<TestNavigationURLLoader> { | 30 public base::SupportsWeakPtr<TestNavigationURLLoader> { |
| 30 public: | 31 public: |
| 31 TestNavigationURLLoader(scoped_ptr<NavigationRequestInfo> request_info, | 32 TestNavigationURLLoader(std::unique_ptr<NavigationRequestInfo> request_info, |
| 32 NavigationURLLoaderDelegate* delegate); | 33 NavigationURLLoaderDelegate* delegate); |
| 33 | 34 |
| 34 // NavigationURLLoader implementation. | 35 // NavigationURLLoader implementation. |
| 35 void FollowRedirect() override; | 36 void FollowRedirect() override; |
| 36 void ProceedWithResponse() override; | 37 void ProceedWithResponse() override; |
| 37 | 38 |
| 38 NavigationRequestInfo* request_info() const { return request_info_.get(); } | 39 NavigationRequestInfo* request_info() const { return request_info_.get(); } |
| 39 | 40 |
| 40 void SimulateServerRedirect(const GURL& redirect_url); | 41 void SimulateServerRedirect(const GURL& redirect_url); |
| 41 | 42 |
| 42 void SimulateError(int error_code); | 43 void SimulateError(int error_code); |
| 43 | 44 |
| 44 void CallOnRequestRedirected(const net::RedirectInfo& redirect_info, | 45 void CallOnRequestRedirected(const net::RedirectInfo& redirect_info, |
| 45 const scoped_refptr<ResourceResponse>& response); | 46 const scoped_refptr<ResourceResponse>& response); |
| 46 void CallOnResponseStarted(const scoped_refptr<ResourceResponse>& response, | 47 void CallOnResponseStarted(const scoped_refptr<ResourceResponse>& response, |
| 47 scoped_ptr<StreamHandle> body); | 48 std::unique_ptr<StreamHandle> body); |
| 48 | 49 |
| 49 int redirect_count() { return redirect_count_; } | 50 int redirect_count() { return redirect_count_; } |
| 50 | 51 |
| 51 bool response_proceeded() { return response_proceeded_; } | 52 bool response_proceeded() { return response_proceeded_; } |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 ~TestNavigationURLLoader() override; | 55 ~TestNavigationURLLoader() override; |
| 55 | 56 |
| 56 scoped_ptr<NavigationRequestInfo> request_info_; | 57 std::unique_ptr<NavigationRequestInfo> request_info_; |
| 57 NavigationURLLoaderDelegate* delegate_; | 58 NavigationURLLoaderDelegate* delegate_; |
| 58 int redirect_count_; | 59 int redirect_count_; |
| 59 bool response_proceeded_; | 60 bool response_proceeded_; |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 } // namespace content | 63 } // namespace content |
| 63 | 64 |
| 64 #endif // CONTENT_TEST_TEST_NAVIGATION_URL_LOADER_H_ | 65 #endif // CONTENT_TEST_TEST_NAVIGATION_URL_LOADER_H_ |
| OLD | NEW |