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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/frame_tree_node.cc
diff --git a/content/browser/frame_host/frame_tree_node.cc b/content/browser/frame_host/frame_tree_node.cc
index 4a0db77650e2671ddbad1a3bd49d12d14e9fa7cd..15679805e80deb41c13d12ad670af4db0ea014df 100644
--- a/content/browser/frame_host/frame_tree_node.cc
+++ b/content/browser/frame_host/frame_tree_node.cc
@@ -7,6 +7,7 @@
#include <queue>
#include "base/command_line.h"
+#include "base/profiler/scoped_tracker.h"
#include "base/stl_util.h"
#include "content/browser/frame_host/frame_tree.h"
#include "content/browser/frame_host/navigation_request.h"
@@ -27,11 +28,14 @@ typedef base::hash_map<int64, FrameTreeNode*> FrameTreeNodeIDMap;
base::LazyInstance<FrameTreeNodeIDMap> g_frame_tree_node_id_map =
LAZY_INSTANCE_INITIALIZER;
-} // namespace
+// These values indicate the loading progress status. The minimum progress
+// value matches what Blink's ProgressTracker has traditionally used for a
+// minimum progress value.
+const double kLoadingProgressNotStarted = 0.0;
+const double kLoadingProgressMinimum = 0.1;
+const double kLoadingProgressDone = 1.0;
-const double FrameTreeNode::kLoadingProgressNotStarted = 0.0;
-const double FrameTreeNode::kLoadingProgressMinimum = 0.1;
-const double FrameTreeNode::kLoadingProgressDone = 1.0;
+} // namespace
int64 FrameTreeNode::next_frame_tree_node_id_ = 1;
@@ -194,4 +198,69 @@ void FrameTreeNode::ResetNavigationRequest(bool is_commit) {
navigation_request_.reset();
}
+bool FrameTreeNode::has_started_loading() const {
+ return loading_progress_ != kLoadingProgressNotStarted;
+}
+
+void FrameTreeNode::reset_loading_progress() {
+ loading_progress_ = kLoadingProgressNotStarted;
+}
+
+void FrameTreeNode::DidStartLoading(bool to_different_document) {
+ // Any main frame load to a new document should reset the load progress since
+ // it will replace the current page and any frames. The WebContents will
+ // be notified when DidChangeLoadProgress is called.
+ if (to_different_document && IsMainFrame())
+ frame_tree_->ResetLoadProgress();
+
+ // Notify the WebContents.
+ if (!frame_tree_->IsLoading())
+ navigator()->GetDelegate()->DidStartLoading(this, to_different_document);
+
+ // Set initial load progress and update overall progress. This will notify
+ // the WebContents of the load progress change.
+ DidChangeLoadProgress(kLoadingProgressMinimum);
+
+ // Notify the RenderFrameHostManager of the event.
+ render_manager()->OnDidStartLoading();
+}
+
+void FrameTreeNode::DidStopLoading() {
+ // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is fixed.
+ tracked_objects::ScopedTracker tracking_profile1(
+ FROM_HERE_WITH_EXPLICIT_FUNCTION(
+ "465796 FrameTreeNode::DidStopLoading::Start"));
+
+ // Set final load progress and update overall progress. This will notify
+ // the WebContents of the load progress change.
+ DidChangeLoadProgress(kLoadingProgressDone);
+
+ // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is fixed.
+ tracked_objects::ScopedTracker tracking_profile2(
+ FROM_HERE_WITH_EXPLICIT_FUNCTION(
+ "465796 FrameTreeNode::DidStopLoading::WCIDidStopLoading"));
+
+ // Notify the WebContents.
+ if (!frame_tree_->IsLoading())
+ navigator()->GetDelegate()->DidStopLoading();
+
+ // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is fixed.
+ tracked_objects::ScopedTracker tracking_profile3(
+ FROM_HERE_WITH_EXPLICIT_FUNCTION(
+ "465796 FrameTreeNode::DidStopLoading::RFHMDidStopLoading"));
+
+ // Notify the RenderFrameHostManager of the event.
+ render_manager()->OnDidStopLoading();
+
+ // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is fixed.
+ tracked_objects::ScopedTracker tracking_profile4(
+ FROM_HERE_WITH_EXPLICIT_FUNCTION(
+ "465796 FrameTreeNode::DidStopLoading::End"));
+}
+
+void FrameTreeNode::DidChangeLoadProgress(double load_progress) {
+ loading_progress_ = load_progress;
+ frame_tree_->UpdateLoadProgress();
+}
+
} // namespace content
« 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