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

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

Issue 1080143003: Move DidStartLoading, DidStopLoading, DidChangeLoadProgress to RFHI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Rebase Created 5 years, 8 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/profiler/scoped_tracker.h"
10 #include "base/stl_util.h" 11 #include "base/stl_util.h"
11 #include "content/browser/frame_host/frame_tree.h" 12 #include "content/browser/frame_host/frame_tree.h"
12 #include "content/browser/frame_host/navigation_request.h" 13 #include "content/browser/frame_host/navigation_request.h"
13 #include "content/browser/frame_host/navigator.h" 14 #include "content/browser/frame_host/navigator.h"
14 #include "content/browser/frame_host/render_frame_host_impl.h" 15 #include "content/browser/frame_host/render_frame_host_impl.h"
15 #include "content/browser/renderer_host/render_view_host_impl.h" 16 #include "content/browser/renderer_host/render_view_host_impl.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
18 19
19 namespace content { 20 namespace content {
20 21
21 namespace { 22 namespace {
22 23
23 // This is a global map between frame_tree_node_ids and pointers to 24 // This is a global map between frame_tree_node_ids and pointers to
24 // FrameTreeNodes. 25 // FrameTreeNodes.
25 typedef base::hash_map<int64, FrameTreeNode*> FrameTreeNodeIDMap; 26 typedef base::hash_map<int64, FrameTreeNode*> FrameTreeNodeIDMap;
26 27
27 base::LazyInstance<FrameTreeNodeIDMap> g_frame_tree_node_id_map = 28 base::LazyInstance<FrameTreeNodeIDMap> g_frame_tree_node_id_map =
28 LAZY_INSTANCE_INITIALIZER; 29 LAZY_INSTANCE_INITIALIZER;
29 30
31 // These values indicate the loading progress status. The minimum progress
32 // value matches what Blink's ProgressTracker has traditionally used for a
33 // minimum progress value.
34 const double kLoadingProgressNotStarted = 0.0;
35 const double kLoadingProgressMinimum = 0.1;
36 const double kLoadingProgressDone = 1.0;
37
30 } // namespace 38 } // namespace
31 39
32 const double FrameTreeNode::kLoadingProgressNotStarted = 0.0;
33 const double FrameTreeNode::kLoadingProgressMinimum = 0.1;
34 const double FrameTreeNode::kLoadingProgressDone = 1.0;
35
36 int64 FrameTreeNode::next_frame_tree_node_id_ = 1; 40 int64 FrameTreeNode::next_frame_tree_node_id_ = 1;
37 41
38 // static 42 // static
39 FrameTreeNode* FrameTreeNode::GloballyFindByID(int64 frame_tree_node_id) { 43 FrameTreeNode* FrameTreeNode::GloballyFindByID(int64 frame_tree_node_id) {
40 DCHECK_CURRENTLY_ON(BrowserThread::UI); 44 DCHECK_CURRENTLY_ON(BrowserThread::UI);
41 FrameTreeNodeIDMap* nodes = g_frame_tree_node_id_map.Pointer(); 45 FrameTreeNodeIDMap* nodes = g_frame_tree_node_id_map.Pointer();
42 FrameTreeNodeIDMap::iterator it = nodes->find(frame_tree_node_id); 46 FrameTreeNodeIDMap::iterator it = nodes->find(frame_tree_node_id);
43 return it == nodes->end() ? nullptr : it->second; 47 return it == nodes->end() ? nullptr : it->second;
44 } 48 }
45 49
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // cleanup performed since the navigation is still ongoing. If the reset 191 // cleanup performed since the navigation is still ongoing. If the reset
188 // corresponds to a cancelation, the RenderFrameHostManager should clean up 192 // corresponds to a cancelation, the RenderFrameHostManager should clean up
189 // any speculative RenderFrameHost it created for the navigation. 193 // any speculative RenderFrameHost it created for the navigation.
190 if (navigation_request_ && !is_commit) { 194 if (navigation_request_ && !is_commit) {
191 // TODO(clamy): perform the StopLoading logic. 195 // TODO(clamy): perform the StopLoading logic.
192 render_manager_.CleanUpNavigation(); 196 render_manager_.CleanUpNavigation();
193 } 197 }
194 navigation_request_.reset(); 198 navigation_request_.reset();
195 } 199 }
196 200
201 bool FrameTreeNode::has_started_loading() const {
202 return loading_progress_ != kLoadingProgressNotStarted;
203 }
204
205 void FrameTreeNode::reset_loading_progress() {
206 loading_progress_ = kLoadingProgressNotStarted;
207 }
208
209 void FrameTreeNode::DidStartLoading(bool to_different_document) {
210 // Any main frame load to a new document should reset the load progress since
211 // it will replace the current page and any frames. The WebContents will
212 // be notified when DidChangeLoadProgress is called.
213 if (to_different_document && IsMainFrame())
214 frame_tree_->ResetLoadProgress();
215
216 // Notify the WebContents.
217 if (!frame_tree_->IsLoading())
218 navigator()->GetDelegate()->DidStartLoading(this, to_different_document);
219
220 // Set initial load progress and update overall progress. This will notify
221 // the WebContents of the load progress change.
222 DidChangeLoadProgress(kLoadingProgressMinimum);
223
224 // Notify the RenderFrameHostManager of the event.
225 render_manager()->OnDidStartLoading();
226 }
227
228 void FrameTreeNode::DidStopLoading() {
229 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is fixed.
230 tracked_objects::ScopedTracker tracking_profile1(
231 FROM_HERE_WITH_EXPLICIT_FUNCTION(
232 "465796 FrameTreeNode::DidStopLoading::Start"));
233
234 // Set final load progress and update overall progress. This will notify
235 // the WebContents of the load progress change.
236 DidChangeLoadProgress(kLoadingProgressDone);
237
238 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is fixed.
239 tracked_objects::ScopedTracker tracking_profile2(
240 FROM_HERE_WITH_EXPLICIT_FUNCTION(
241 "465796 FrameTreeNode::DidStopLoading::WCIDidStopLoading"));
242
243 // Notify the WebContents.
244 if (!frame_tree_->IsLoading())
245 navigator()->GetDelegate()->DidStopLoading();
246
247 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is fixed.
248 tracked_objects::ScopedTracker tracking_profile3(
249 FROM_HERE_WITH_EXPLICIT_FUNCTION(
250 "465796 FrameTreeNode::DidStopLoading::RFHMDidStopLoading"));
251
252 // Notify the RenderFrameHostManager of the event.
253 render_manager()->OnDidStopLoading();
254
255 // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is fixed.
256 tracked_objects::ScopedTracker tracking_profile4(
257 FROM_HERE_WITH_EXPLICIT_FUNCTION(
258 "465796 FrameTreeNode::DidStopLoading::End"));
259 }
260
261 void FrameTreeNode::DidChangeLoadProgress(double load_progress) {
262 loading_progress_ = load_progress;
263 frame_tree_->UpdateLoadProgress();
264 }
265
197 } // namespace content 266 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree_node.h ('k') | content/browser/frame_host/interstitial_page_navigator_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698