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 #include "content/test/test_navigation_url_loader.h" | 5 #include "content/test/test_navigation_url_loader.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "content/browser/loader/navigation_url_loader_delegate.h" | 9 #include "content/browser/loader/navigation_url_loader_delegate.h" |
10 #include "content/public/browser/stream_handle.h" | 10 #include "content/public/browser/stream_handle.h" |
11 #include "content/public/common/resource_response.h" | 11 #include "content/public/common/resource_response.h" |
12 #include "net/url_request/redirect_info.h" | 12 #include "net/url_request/redirect_info.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 TestNavigationURLLoader::TestNavigationURLLoader( | 16 TestNavigationURLLoader::TestNavigationURLLoader( |
17 scoped_ptr<NavigationRequestInfo> request_info, | 17 scoped_ptr<NavigationRequestInfo> request_info, |
18 NavigationURLLoaderDelegate* delegate) | 18 NavigationURLLoaderDelegate* delegate) |
19 : request_info_(std::move(request_info)), | 19 : request_info_(std::move(request_info)), |
20 delegate_(delegate), | 20 delegate_(delegate), |
21 redirect_count_(0) {} | 21 redirect_count_(0), |
| 22 response_proceeded_(false) {} |
22 | 23 |
23 void TestNavigationURLLoader::FollowRedirect() { | 24 void TestNavigationURLLoader::FollowRedirect() { |
24 redirect_count_++; | 25 redirect_count_++; |
25 } | 26 } |
26 | 27 |
| 28 void TestNavigationURLLoader::ProceedWithResponse() { |
| 29 response_proceeded_ = true; |
| 30 } |
| 31 |
27 void TestNavigationURLLoader::SimulateServerRedirect(const GURL& redirect_url) { | 32 void TestNavigationURLLoader::SimulateServerRedirect(const GURL& redirect_url) { |
28 net::RedirectInfo redirect_info; | 33 net::RedirectInfo redirect_info; |
29 redirect_info.status_code = 302; | 34 redirect_info.status_code = 302; |
30 redirect_info.new_method = "GET"; | 35 redirect_info.new_method = "GET"; |
31 redirect_info.new_url = redirect_url; | 36 redirect_info.new_url = redirect_url; |
32 redirect_info.new_first_party_for_cookies = redirect_url; | 37 redirect_info.new_first_party_for_cookies = redirect_url; |
33 scoped_refptr<ResourceResponse> response(new ResourceResponse); | 38 scoped_refptr<ResourceResponse> response(new ResourceResponse); |
34 CallOnRequestRedirected(redirect_info, response); | 39 CallOnRequestRedirected(redirect_info, response); |
35 } | 40 } |
36 | 41 |
37 void TestNavigationURLLoader::SimulateError(int error_code) { | 42 void TestNavigationURLLoader::SimulateError(int error_code) { |
38 delegate_->OnRequestFailed(false, error_code); | 43 delegate_->OnRequestFailed(false, error_code); |
39 } | 44 } |
40 | 45 |
41 void TestNavigationURLLoader::CallOnRequestRedirected( | 46 void TestNavigationURLLoader::CallOnRequestRedirected( |
42 const net::RedirectInfo& redirect_info, | 47 const net::RedirectInfo& redirect_info, |
43 const scoped_refptr<ResourceResponse>& response) { | 48 const scoped_refptr<ResourceResponse>& response) { |
44 delegate_->OnRequestRedirected(redirect_info, response); | 49 delegate_->OnRequestRedirected(redirect_info, response); |
45 } | 50 } |
46 | 51 |
47 void TestNavigationURLLoader::CallOnResponseStarted( | 52 void TestNavigationURLLoader::CallOnResponseStarted( |
48 const scoped_refptr<ResourceResponse>& response, | 53 const scoped_refptr<ResourceResponse>& response, |
49 scoped_ptr<StreamHandle> body) { | 54 scoped_ptr<StreamHandle> body) { |
50 delegate_->OnResponseStarted(response, std::move(body)); | 55 delegate_->OnResponseStarted(response, std::move(body)); |
51 } | 56 } |
52 | 57 |
53 TestNavigationURLLoader::~TestNavigationURLLoader() {} | 58 TestNavigationURLLoader::~TestNavigationURLLoader() {} |
54 | 59 |
55 } // namespace content | 60 } // namespace content |
OLD | NEW |