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

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

Issue 925623002: Refactor the loading tracking logic in WebContentsImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments + track per RFH Created 5 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/frame_tree_node.h" 5 #include "content/browser/frame_host/frame_tree_node.h"
6 6
7 #include <queue> 7 #include <queue>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 16 matching lines...) Expand all
27 const std::string& name) 27 const std::string& name)
28 : frame_tree_(frame_tree), 28 : frame_tree_(frame_tree),
29 navigator_(navigator), 29 navigator_(navigator),
30 render_manager_(this, 30 render_manager_(this,
31 render_frame_delegate, 31 render_frame_delegate,
32 render_view_delegate, 32 render_view_delegate,
33 render_widget_delegate, 33 render_widget_delegate,
34 manager_delegate), 34 manager_delegate),
35 frame_tree_node_id_(next_frame_tree_node_id_++), 35 frame_tree_node_id_(next_frame_tree_node_id_++),
36 parent_(NULL), 36 parent_(NULL),
37 replication_state_(name), 37 replication_state_(name) {
38 is_loading_(false) {
39 } 38 }
40 39
41 FrameTreeNode::~FrameTreeNode() { 40 FrameTreeNode::~FrameTreeNode() {
42 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 41 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
43 switches::kEnableBrowserSideNavigation)) { 42 switches::kEnableBrowserSideNavigation)) {
44 navigator_->CancelNavigation(this); 43 navigator_->CancelNavigation(this);
45 } 44 }
46 } 45 }
47 46
48 bool FrameTreeNode::IsMainFrame() const { 47 bool FrameTreeNode::IsMainFrame() const {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 return false; 107 return false;
109 108
110 for (FrameTreeNode* node = parent(); node; node = node->parent()) { 109 for (FrameTreeNode* node = parent(); node; node = node->parent()) {
111 if (node == other) 110 if (node == other)
112 return true; 111 return true;
113 } 112 }
114 113
115 return false; 114 return false;
116 } 115 }
117 116
117 bool FrameTreeNode::IsLoading() const {
118 RenderFrameHostImpl* current_frame_host =
119 render_manager_.current_frame_host();
120 RenderFrameHostImpl* pending_frame_host =
121 render_manager_.pending_frame_host();
122
123 DCHECK(current_frame_host != nullptr);
124 if (pending_frame_host != nullptr)
125 return current_frame_host->is_loading() && pending_frame_host->is_loading();
Fabrice (no longer in Chrome) 2015/02/23 20:48:45 ... s/&&/||/ I find it worrisome that none of our
Fabrice (no longer in Chrome) 2015/02/24 13:14:47 Done. I will add a test for this case.
126 else
127 return current_frame_host->is_loading();
128 }
129
130 double FrameTreeNode::GetLoadingProgress() const {
131 RenderFrameHostImpl* current_frame_host =
132 render_manager_.current_frame_host();
133 RenderFrameHostImpl* pending_frame_host =
134 render_manager_.pending_frame_host();
135
136 DCHECK(current_frame_host != nullptr);
137 if (pending_frame_host != nullptr)
138 return (current_frame_host->loading_progress() +
139 pending_frame_host->loading_progress()) / 2;
Charlie Reis 2015/02/24 04:55:00 This is not correct. Why would the overall load p
Fabrice (no longer in Chrome) 2015/02/24 13:14:47 The loading progress can in fact go backwards but
Charlie Reis 2015/02/25 00:07:20 To be clear: it's important for UX that the load p
140 else
141 return current_frame_host->loading_progress();
142 }
143
118 } // namespace content 144 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698