Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Side by Side Diff: content/browser/frame_host/navigation_request.cc

Issue 475783002: PlzNavigate: add cancel navigation logic for uncommitted requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR comments and removed the weird Observer. Trying to get this CL through and have the mo… Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 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/browser/frame_host/navigation_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/loader/resource_dispatcher_host_impl.h" 8 #include "content/browser/loader/resource_dispatcher_host_impl.h"
9 #include "content/common/resource_request_body.h" 9 #include "content/common/resource_request_body.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 namespace { 14 namespace {
15 15
16 // The next available browser-global navigation request ID.
17 static int64 next_navigation_request_id_ = 0;
18
16 void OnBeginNavigation(const NavigationRequestInfo& info, 19 void OnBeginNavigation(const NavigationRequestInfo& info,
17 scoped_refptr<ResourceRequestBody> request_body, 20 scoped_refptr<ResourceRequestBody> request_body,
21 int64 navigation_request_id,
18 int64 frame_node_id) { 22 int64 frame_node_id) {
19 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
20 ResourceDispatcherHostImpl::Get()->NavigationRequest( 24 ResourceDispatcherHostImpl::Get()->StartNavigationRequest(
21 info, request_body, frame_node_id); 25 info, request_body, navigation_request_id, frame_node_id);
26 }
27
28 void CancelNavigationRequest(int64 navigation_request_id,
29 int64 frame_node_id) {
30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
31 ResourceDispatcherHostImpl::Get()->CancelNavigationRequest(
32 navigation_request_id, frame_node_id);
22 } 33 }
23 34
24 } // namespace 35 } // namespace
25 36
26 NavigationRequest::NavigationRequest(const NavigationRequestInfo& info, 37 NavigationRequest::NavigationRequest(const NavigationRequestInfo& info,
27 int64 frame_node_id) 38 int64 frame_node_id)
28 : info_(info), 39 : navigation_request_id_(++next_navigation_request_id_),
40 info_(info),
29 frame_node_id_(frame_node_id) { 41 frame_node_id_(frame_node_id) {
30 } 42 }
31 43
32 NavigationRequest::~NavigationRequest() { 44 NavigationRequest::~NavigationRequest() {
33 // TODO(clamy): Cancel the corresponding request in ResourceDispatcherHost if
34 // it has not commited yet.
35 } 45 }
36 46
37 void NavigationRequest::BeginNavigation( 47 void NavigationRequest::BeginNavigation(
38 scoped_refptr<ResourceRequestBody> request_body) { 48 scoped_refptr<ResourceRequestBody> request_body) {
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
40 BrowserThread::PostTask( 50 BrowserThread::PostTask(
41 BrowserThread::IO, 51 BrowserThread::IO,
42 FROM_HERE, 52 FROM_HERE,
43 base::Bind(&OnBeginNavigation, info_, request_body, frame_node_id_)); 53 base::Bind(&OnBeginNavigation,
54 info_,
55 request_body,
56 navigation_request_id_,
57 frame_node_id_));
58 }
59
60 void NavigationRequest::CancelNavigation() {
61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
62 BrowserThread::PostTask(
63 BrowserThread::IO,
64 FROM_HERE,
65 base::Bind(&CancelNavigationRequest,
66 navigation_request_id_, frame_node_id_));
44 } 67 }
45 68
46 } // namespace content 69 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698