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

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

Issue 1312213010: PageLoadMetrics renderer and browser implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Relax DCHECK constraints slightly for tests Created 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_handle_impl.h" 5 #include "content/browser/frame_host/navigation_handle_impl.h"
6 6
7 #include "content/browser/frame_host/navigator_delegate.h" 7 #include "content/browser/frame_host/navigator_delegate.h"
8 #include "net/url_request/redirect_info.h" 8 #include "net/url_request/redirect_info.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 // static 12 // static
13 scoped_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( 13 scoped_ptr<NavigationHandleImpl> NavigationHandleImpl::Create(
14 const GURL& url, 14 const GURL& url,
15 const bool is_main_frame, 15 const bool is_main_frame,
16 NavigatorDelegate* delegate) { 16 NavigatorDelegate* delegate) {
17 return scoped_ptr<NavigationHandleImpl>( 17 return scoped_ptr<NavigationHandleImpl>(
18 new NavigationHandleImpl(url, is_main_frame, delegate)); 18 new NavigationHandleImpl(url, is_main_frame, delegate));
19 } 19 }
20 20
21 NavigationHandleImpl::NavigationHandleImpl(const GURL& url, 21 NavigationHandleImpl::NavigationHandleImpl(const GURL& url,
22 const bool is_main_frame, 22 const bool is_main_frame,
23 NavigatorDelegate* delegate) 23 NavigatorDelegate* delegate)
24 : url_(url), 24 : url_(url),
25 net_error_code_(net::OK), 25 net_error_code_(net::OK),
26 state_(DID_START), 26 state_(DID_START),
27 is_main_frame_(is_main_frame), 27 is_main_frame_(is_main_frame),
28 is_same_page_(false),
28 is_transferring_(false), 29 is_transferring_(false),
29 delegate_(delegate) { 30 delegate_(delegate) {
30 delegate_->DidStartNavigation(this); 31 delegate_->DidStartNavigation(this);
31 } 32 }
32 33
33 NavigationHandleImpl::~NavigationHandleImpl() { 34 NavigationHandleImpl::~NavigationHandleImpl() {
34 delegate_->DidFinishNavigation(this); 35 delegate_->DidFinishNavigation(this);
35 } 36 }
36 37
37 const GURL& NavigationHandleImpl::GetURL() const { 38 const GURL& NavigationHandleImpl::GetURL() const {
38 return url_; 39 return url_;
39 } 40 }
40 41
41 net::Error NavigationHandleImpl::GetNetErrorCode() const { 42 net::Error NavigationHandleImpl::GetNetErrorCode() const {
42 return net_error_code_; 43 return net_error_code_;
43 } 44 }
44 45
45 bool NavigationHandleImpl::IsInMainFrame() const { 46 bool NavigationHandleImpl::IsInMainFrame() const {
46 return is_main_frame_; 47 return is_main_frame_;
47 } 48 }
48 49
50 bool NavigationHandleImpl::IsSamePage() {
51 DCHECK(state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE)
52 << "This accessor should not be called before the navigation has "
53 "committed.";
54 return is_same_page_;
55 }
56
49 bool NavigationHandleImpl::HasCommittedDocument() const { 57 bool NavigationHandleImpl::HasCommittedDocument() const {
50 return state_ == DID_COMMIT; 58 return state_ == DID_COMMIT;
51 } 59 }
52 60
53 bool NavigationHandleImpl::HasCommittedErrorPage() const { 61 bool NavigationHandleImpl::HasCommittedErrorPage() const {
54 return state_ == DID_COMMIT_ERROR_PAGE; 62 return state_ == DID_COMMIT_ERROR_PAGE;
55 } 63 }
56 64
57 void NavigationHandleImpl::DidRedirectNavigation(const GURL& new_url) { 65 void NavigationHandleImpl::DidRedirectNavigation(const GURL& new_url) {
58 url_ = new_url; 66 url_ = new_url;
59 delegate_->DidRedirectNavigation(this); 67 delegate_->DidRedirectNavigation(this);
60 } 68 }
61 69
62 void NavigationHandleImpl::DidCommitNavigation() { 70 void NavigationHandleImpl::DidCommitNavigation(bool same_page) {
71 is_same_page_ = same_page;
63 state_ = net_error_code_ == net::OK ? DID_COMMIT : DID_COMMIT_ERROR_PAGE; 72 state_ = net_error_code_ == net::OK ? DID_COMMIT : DID_COMMIT_ERROR_PAGE;
64 delegate_->DidCommitNavigation(this); 73 delegate_->DidCommitNavigation(this);
65 } 74 }
66 75
67 } // namespace content 76 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698