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

Unified 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: Add delegate accessor from Navigator + Re-add scoped trackers 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/frame_tree.cc
diff --git a/content/browser/frame_host/frame_tree.cc b/content/browser/frame_host/frame_tree.cc
index e7c814e6b49527fae2c15cf64ed019cd2d919f97..8cd64908c3c28b43615ce30571d55b78efe5e584 100644
--- a/content/browser/frame_host/frame_tree.cc
+++ b/content/browser/frame_host/frame_tree.cc
@@ -52,19 +52,18 @@ bool CollectLoadProgress(double* progress,
int* frame_count,
FrameTreeNode* node) {
// Ignore the current frame if it has not started loading.
- double frame_progress = node->loading_progress();
- if (frame_progress == FrameTreeNode::kLoadingProgressNotStarted)
+ if (!node->HasStartedLoading())
return true;
// Collect progress.
- *progress += frame_progress;
+ *progress += node->loading_progress();
(*frame_count)++;
return true;
}
// Helper function used with FrameTree::ForEach() to reset the load progress.
bool ResetNodeLoadProgress(FrameTreeNode* node) {
- node->set_loading_progress(FrameTreeNode::kLoadingProgressNotStarted);
+ node->ResetLoadingProgress();
return true;
}
@@ -97,7 +96,8 @@ FrameTree::FrameTree(Navigator* navigator,
render_widget_delegate,
manager_delegate,
std::string())),
- focused_frame_tree_node_id_(-1) {
+ focused_frame_tree_node_id_(-1),
+ load_progress_(0.0) {
}
FrameTree::~FrameTree() {
@@ -347,18 +347,29 @@ void FrameTree::FrameRemoved(FrameTreeNode* frame) {
on_frame_removed_.Run(frame->current_frame_host());
}
-double FrameTree::GetLoadProgress() {
+void FrameTree::UpdateLoadProgress() {
double progress = 0.0;
int frame_count = 0;
ForEach(base::Bind(&CollectLoadProgress, &progress, &frame_count));
if (frame_count != 0)
progress /= frame_count;
- return progress;
+
+ if (progress <= load_progress_)
+ return;
+ load_progress_ = progress;
+
+ // Notify the WebContents.
+ root_->navigator()->GetDelegate()->DidChangeLoadProgress();
+}
+
+double FrameTree::GetLoadProgress() {
Charlie Reis 2015/04/15 23:37:53 This should be in the .h file as load_progress() (
Fabrice (no longer in Chrome) 2015/04/16 13:55:25 Done.
+ return load_progress_;
}
void FrameTree::ResetLoadProgress() {
ForEach(base::Bind(&ResetNodeLoadProgress));
+ load_progress_ = 0.0;
}
bool FrameTree::IsLoading() {

Powered by Google App Engine
This is Rietveld 408576698