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