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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/browser/frame_host/navigation_handle_impl.h" | 10 #include "content/browser/frame_host/navigation_handle_impl.h" |
11 #include "content/browser/frame_host/navigation_request.h" | 11 #include "content/browser/frame_host/navigation_request.h" |
12 #include "content/common/frame_messages.h" | 12 #include "content/common/frame_messages.h" |
13 #include "content/public/browser/global_request_id.h" | |
13 #include "content/public/browser/navigation_throttle.h" | 14 #include "content/public/browser/navigation_throttle.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "content/public/common/browser_side_navigation_policy.h" | 16 #include "content/public/common/browser_side_navigation_policy.h" |
16 #include "content/test/test_navigation_url_loader.h" | 17 #include "content/test/test_navigation_url_loader.h" |
17 #include "content/test/test_render_frame_host.h" | 18 #include "content/test/test_render_frame_host.h" |
18 #include "net/base/load_flags.h" | 19 #include "net/base/load_flags.h" |
19 #include "net/url_request/redirect_info.h" | 20 #include "net/url_request/redirect_info.h" |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 if (!handle_) { | 245 if (!handle_) { |
245 state_ = FAILED; | 246 state_ = FAILED; |
246 return; | 247 return; |
247 } | 248 } |
248 } | 249 } |
249 | 250 |
250 // Call NavigationHandle::WillProcessResponse if needed. | 251 // Call NavigationHandle::WillProcessResponse if needed. |
251 // Note that the handle's state can be CANCELING if a throttle cancelled it | 252 // Note that the handle's state can be CANCELING if a throttle cancelled it |
252 // synchronously in PrepareForCommit. | 253 // synchronously in PrepareForCommit. |
253 if (handle_->state_for_testing() < NavigationHandleImpl::CANCELING) { | 254 if (handle_->state_for_testing() < NavigationHandleImpl::CANCELING) { |
255 static int request_id = 0; | |
Charlie Reis
2017/05/15 20:07:43
Are there any concerns with this overlapping with
Charlie Harrison
2017/05/15 21:45:54
I think this could theoretically overlap with requ
Charlie Reis
2017/05/15 22:02:38
Maybe just start it at 1000 to reduce the chance o
Charlie Harrison
2017/05/16 03:41:42
Done.
| |
256 GlobalRequestID global_id(render_frame_host_->GetProcess()->GetID(), | |
257 ++request_id); | |
254 handle_->WillProcessResponse( | 258 handle_->WillProcessResponse( |
255 render_frame_host_, scoped_refptr<net::HttpResponseHeaders>(), | 259 render_frame_host_, scoped_refptr<net::HttpResponseHeaders>(), |
256 net::HttpResponseInfo::ConnectionInfo(), SSLStatus(), GlobalRequestID(), | 260 net::HttpResponseInfo::ConnectionInfo(), SSLStatus(), global_id, |
257 false /* should_replace_current_entry */, false /* is_download */, | 261 false /* should_replace_current_entry */, false /* is_download */, |
258 false /* is_stream */, base::Closure(), | 262 false /* is_stream */, base::Closure(), |
259 base::Callback<void(NavigationThrottle::ThrottleCheckResult)>()); | 263 base::Callback<void(NavigationThrottle::ThrottleCheckResult)>()); |
260 } | 264 } |
261 | 265 |
262 WaitForThrottleChecksComplete(); | 266 WaitForThrottleChecksComplete(); |
263 | 267 |
264 if (GetLastThrottleCheckResult() != NavigationThrottle::PROCEED) { | 268 if (GetLastThrottleCheckResult() != NavigationThrottle::PROCEED) { |
265 FailFromThrottleCheck(GetLastThrottleCheckResult()); | 269 FailFromThrottleCheck(GetLastThrottleCheckResult()); |
266 return; | 270 return; |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
609 if (!should_result_in_error_page) { | 613 if (!should_result_in_error_page) { |
610 render_frame_host_->OnMessageReceived( | 614 render_frame_host_->OnMessageReceived( |
611 FrameHostMsg_DidStopLoading(render_frame_host_->GetRoutingID())); | 615 FrameHostMsg_DidStopLoading(render_frame_host_->GetRoutingID())); |
612 CHECK_EQ(1, num_did_finish_navigation_called_); | 616 CHECK_EQ(1, num_did_finish_navigation_called_); |
613 } else { | 617 } else { |
614 CHECK_EQ(0, num_did_finish_navigation_called_); | 618 CHECK_EQ(0, num_did_finish_navigation_called_); |
615 } | 619 } |
616 } | 620 } |
617 | 621 |
618 } // namespace content | 622 } // namespace content |
OLD | NEW |