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/global_request_id.h" | 10 #include "content/public/browser/global_request_id.h" |
11 #include "content/public/browser/navigation_data.h" | 11 #include "content/public/browser/navigation_data.h" |
12 #include "content/public/browser/render_process_host.h" | |
12 #include "content/public/browser/ssl_status.h" | 13 #include "content/public/browser/ssl_status.h" |
13 #include "content/public/browser/stream_handle.h" | 14 #include "content/public/browser/stream_handle.h" |
15 #include "content/public/browser/web_contents.h" | |
16 #include "content/public/common/browser_side_navigation_policy.h" | |
14 #include "content/public/common/resource_response.h" | 17 #include "content/public/common/resource_response.h" |
15 #include "net/url_request/redirect_info.h" | 18 #include "net/url_request/redirect_info.h" |
16 | 19 |
17 namespace content { | 20 namespace content { |
18 | 21 |
19 TestNavigationURLLoader::TestNavigationURLLoader( | 22 TestNavigationURLLoader::TestNavigationURLLoader( |
20 std::unique_ptr<NavigationRequestInfo> request_info, | 23 std::unique_ptr<NavigationRequestInfo> request_info, |
21 NavigationURLLoaderDelegate* delegate) | 24 NavigationURLLoaderDelegate* delegate) |
22 : request_info_(std::move(request_info)), | 25 : request_info_(std::move(request_info)), |
23 delegate_(delegate), | 26 delegate_(delegate), |
24 redirect_count_(0), | 27 redirect_count_(0), |
25 response_proceeded_(false) {} | 28 response_proceeded_(false) { |
29 DCHECK(IsBrowserSideNavigationEnabled()); | |
30 } | |
26 | 31 |
27 void TestNavigationURLLoader::FollowRedirect() { | 32 void TestNavigationURLLoader::FollowRedirect() { |
28 redirect_count_++; | 33 redirect_count_++; |
29 } | 34 } |
30 | 35 |
31 void TestNavigationURLLoader::ProceedWithResponse() { | 36 void TestNavigationURLLoader::ProceedWithResponse() { |
32 response_proceeded_ = true; | 37 response_proceeded_ = true; |
33 } | 38 } |
34 | 39 |
35 void TestNavigationURLLoader::SimulateServerRedirect(const GURL& redirect_url) { | 40 void TestNavigationURLLoader::SimulateServerRedirect(const GURL& redirect_url) { |
(...skipping 13 matching lines...) Expand all Loading... | |
49 void TestNavigationURLLoader::CallOnRequestRedirected( | 54 void TestNavigationURLLoader::CallOnRequestRedirected( |
50 const net::RedirectInfo& redirect_info, | 55 const net::RedirectInfo& redirect_info, |
51 const scoped_refptr<ResourceResponse>& response) { | 56 const scoped_refptr<ResourceResponse>& response) { |
52 delegate_->OnRequestRedirected(redirect_info, response); | 57 delegate_->OnRequestRedirected(redirect_info, response); |
53 } | 58 } |
54 | 59 |
55 void TestNavigationURLLoader::CallOnResponseStarted( | 60 void TestNavigationURLLoader::CallOnResponseStarted( |
56 const scoped_refptr<ResourceResponse>& response, | 61 const scoped_refptr<ResourceResponse>& response, |
57 std::unique_ptr<StreamHandle> body, | 62 std::unique_ptr<StreamHandle> body, |
58 std::unique_ptr<NavigationData> navigation_data) { | 63 std::unique_ptr<NavigationData> navigation_data) { |
64 // Start the request_ids at 1000 to avoid collisions with request ids from | |
65 // network resoures (it should be rare to compare these in unit tests). | |
arthursonzogni
2017/05/16 09:16:05
nit: s/resoures/resources
Charlie Harrison
2017/05/16 12:23:39
Done.
| |
66 static int request_id = 1000; | |
67 int child_id = | |
68 WebContents::FromFrameTreeNodeId(request_info_->frame_tree_node_id) | |
69 ->GetRenderProcessHost() | |
70 ->GetID(); | |
71 GlobalRequestID global_id(child_id, ++request_id); | |
59 delegate_->OnResponseStarted( | 72 delegate_->OnResponseStarted( |
60 response, std::move(body), mojo::ScopedDataPipeConsumerHandle(), | 73 response, std::move(body), mojo::ScopedDataPipeConsumerHandle(), |
61 SSLStatus(), std::move(navigation_data), GlobalRequestID(), false, false); | 74 SSLStatus(), std::move(navigation_data), global_id, false, false); |
62 } | 75 } |
63 | 76 |
64 TestNavigationURLLoader::~TestNavigationURLLoader() {} | 77 TestNavigationURLLoader::~TestNavigationURLLoader() {} |
65 | 78 |
66 } // namespace content | 79 } // namespace content |
OLD | NEW |