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

Side by Side Diff: content/browser/frame_host/frame_tree.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
« no previous file with comments | « content/browser/frame_host/frame_tree.h ('k') | content/browser/frame_host/frame_tree_node.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 5 #include "content/browser/frame_host/frame_tree.h"
6 6
7 #include <queue> 7 #include <queue>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 node->render_manager()->CreateRenderFrameProxy(instance.get()); 45 node->render_manager()->CreateRenderFrameProxy(instance.get());
46 return true; 46 return true;
47 } 47 }
48 48
49 // Helper function used with FrameTree::ForEach() for retrieving the total 49 // Helper function used with FrameTree::ForEach() for retrieving the total
50 // loading progress and number of frames in a frame tree. 50 // loading progress and number of frames in a frame tree.
51 bool CollectLoadProgress(double* progress, 51 bool CollectLoadProgress(double* progress,
52 int* frame_count, 52 int* frame_count,
53 FrameTreeNode* node) { 53 FrameTreeNode* node) {
54 // Ignore the current frame if it has not started loading. 54 // Ignore the current frame if it has not started loading.
55 double frame_progress = node->loading_progress(); 55 if (!node->has_started_loading())
56 if (frame_progress == FrameTreeNode::kLoadingProgressNotStarted)
57 return true; 56 return true;
58 57
59 // Collect progress. 58 // Collect progress.
60 *progress += frame_progress; 59 *progress += node->loading_progress();
61 (*frame_count)++; 60 (*frame_count)++;
62 return true; 61 return true;
63 } 62 }
64 63
65 // Helper function used with FrameTree::ForEach() to reset the load progress. 64 // Helper function used with FrameTree::ForEach() to reset the load progress.
66 bool ResetNodeLoadProgress(FrameTreeNode* node) { 65 bool ResetNodeLoadProgress(FrameTreeNode* node) {
67 node->set_loading_progress(FrameTreeNode::kLoadingProgressNotStarted); 66 node->reset_loading_progress();
68 return true; 67 return true;
69 } 68 }
70 69
71 // Helper function used with FrameTree::ForEach() to check if at least one of 70 // Helper function used with FrameTree::ForEach() to check if at least one of
72 // the nodes is loading. 71 // the nodes is loading.
73 bool IsNodeLoading(bool* is_loading, FrameTreeNode* node) { 72 bool IsNodeLoading(bool* is_loading, FrameTreeNode* node) {
74 if (node->IsLoading()) { 73 if (node->IsLoading()) {
75 // There is at least one node loading, so abort traversal. 74 // There is at least one node loading, so abort traversal.
76 *is_loading = true; 75 *is_loading = true;
77 return false; 76 return false;
(...skipping 12 matching lines...) Expand all
90 render_view_delegate_(render_view_delegate), 89 render_view_delegate_(render_view_delegate),
91 render_widget_delegate_(render_widget_delegate), 90 render_widget_delegate_(render_widget_delegate),
92 manager_delegate_(manager_delegate), 91 manager_delegate_(manager_delegate),
93 root_(new FrameTreeNode(this, 92 root_(new FrameTreeNode(this,
94 navigator, 93 navigator,
95 render_frame_delegate, 94 render_frame_delegate,
96 render_view_delegate, 95 render_view_delegate,
97 render_widget_delegate, 96 render_widget_delegate,
98 manager_delegate, 97 manager_delegate,
99 std::string())), 98 std::string())),
100 focused_frame_tree_node_id_(-1) { 99 focused_frame_tree_node_id_(-1),
100 load_progress_(0.0) {
101 } 101 }
102 102
103 FrameTree::~FrameTree() { 103 FrameTree::~FrameTree() {
104 } 104 }
105 105
106 FrameTreeNode* FrameTree::FindByID(int64 frame_tree_node_id) { 106 FrameTreeNode* FrameTree::FindByID(int64 frame_tree_node_id) {
107 FrameTreeNode* node = NULL; 107 FrameTreeNode* node = NULL;
108 ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node)); 108 ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node));
109 return node; 109 return node;
110 } 110 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 if (!frame->parent()) { 340 if (!frame->parent()) {
341 CHECK_EQ(frame, root_.get()); 341 CHECK_EQ(frame, root_.get());
342 return; 342 return;
343 } 343 }
344 344
345 // Notify observers of the frame removal. 345 // Notify observers of the frame removal.
346 if (!on_frame_removed_.is_null()) 346 if (!on_frame_removed_.is_null())
347 on_frame_removed_.Run(frame->current_frame_host()); 347 on_frame_removed_.Run(frame->current_frame_host());
348 } 348 }
349 349
350 double FrameTree::GetLoadProgress() { 350 void FrameTree::UpdateLoadProgress() {
351 double progress = 0.0; 351 double progress = 0.0;
352 int frame_count = 0; 352 int frame_count = 0;
353 353
354 ForEach(base::Bind(&CollectLoadProgress, &progress, &frame_count)); 354 ForEach(base::Bind(&CollectLoadProgress, &progress, &frame_count));
355 if (frame_count != 0) 355 if (frame_count != 0)
356 progress /= frame_count; 356 progress /= frame_count;
357 return progress; 357
358 if (progress <= load_progress_)
359 return;
360 load_progress_ = progress;
361
362 // Notify the WebContents.
363 root_->navigator()->GetDelegate()->DidChangeLoadProgress();
358 } 364 }
359 365
360 void FrameTree::ResetLoadProgress() { 366 void FrameTree::ResetLoadProgress() {
361 ForEach(base::Bind(&ResetNodeLoadProgress)); 367 ForEach(base::Bind(&ResetNodeLoadProgress));
368 load_progress_ = 0.0;
362 } 369 }
363 370
364 bool FrameTree::IsLoading() { 371 bool FrameTree::IsLoading() {
365 bool is_loading = false; 372 bool is_loading = false;
366 ForEach(base::Bind(&IsNodeLoading, &is_loading)); 373 ForEach(base::Bind(&IsNodeLoading, &is_loading));
367 return is_loading; 374 return is_loading;
368 } 375 }
369 376
370 } // namespace content 377 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree.h ('k') | content/browser/frame_host/frame_tree_node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698