Chromium Code Reviews| 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 daf4a71255d6b8a9c6f30493364f25644dd18620..950de6b2be0542f08d81570cf33d55e3f908143a 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/navigator.h" |
| @@ -26,11 +27,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; |
| @@ -174,4 +178,71 @@ bool FrameTreeNode::CommitPendingSandboxFlags() { |
| return did_change_flags; |
| } |
| +bool FrameTreeNode::HasStartedLoading() const { |
|
Charlie Reis
2015/04/15 23:37:53
This should be in the .h file as has_started_loadi
Fabrice (no longer in Chrome)
2015/04/16 13:55:25
Then we'd have to move the kLoadingProgress consta
nasko
2015/04/16 16:23:48
It still should be hacker_cased though, as it just
Fabrice (no longer in Chrome)
2015/04/16 16:33:30
Done.
|
| + return loading_progress_ != kLoadingProgressNotStarted; |
| +} |
| + |
| +void FrameTreeNode::ResetLoadingProgress() { |
|
Charlie Reis
2015/04/15 23:37:53
Same: reset_loading_progress().
Fabrice (no longer in Chrome)
2015/04/16 13:55:25
Same as above.
nasko
2015/04/16 16:23:48
Again, hacker_cased.
Fabrice (no longer in Chrome)
2015/04/16 16:33:30
Done.
|
| + 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 UpdateLoadProgress is called. |
| + if (to_different_document && IsMainFrame()) |
| + frame_tree_->ResetLoadProgress(); |
| + |
| + // Notify the WebContents. |
| + if (!frame_tree_->IsLoading()) |
| + navigator()->GetDelegate()->DidStartLoading(this, to_different_document); |
| + |
| + // Notify the RenderFrameHostManager of the event. |
|
nasko
2015/04/15 19:17:05
I wonder if it will be more consistent if all noti
Fabrice (no longer in Chrome)
2015/04/16 13:55:25
I am not sure what you are referring to, afaict RF
nasko
2015/04/16 16:23:48
My concerns are addressed by the usage of DidChang
|
| + render_manager()->OnDidStartLoading(); |
| + |
| + // Set initial load progress and update overall progress. This will notify |
| + // the WebContents of the load progress change. |
| + loading_progress_ = kLoadingProgressMinimum; |
| + frame_tree_->UpdateLoadProgress(); |
|
Charlie Reis
2015/04/15 23:37:53
We should probably use DidChangeLoadProgress here
Fabrice (no longer in Chrome)
2015/04/16 13:55:25
Done.
Also updated the comments.
|
| +} |
| + |
| +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")); |
| + |
| + // Notify the RenderFrameHostManager of the event. |
| + render_manager()->OnDidStopLoading(); |
|
nasko
2015/04/15 19:17:05
Same concern as above, should we change the state
Fabrice (no longer in Chrome)
2015/04/16 13:55:25
Moved that at the end of the method.
|
| + |
| + // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is fixed. |
| + tracked_objects::ScopedTracker tracking_profile2( |
| + FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| + "465796 FrameTreeNode::DidStopLoading::UpdateLoadProgress")); |
| + |
| + // Set final load progress and update overall progress. This will notify |
| + // the WebContents of the load progress change. |
| + loading_progress_ = kLoadingProgressDone; |
| + frame_tree_->UpdateLoadProgress(); |
|
Charlie Reis
2015/04/15 23:37:53
Same here: call DidChangeLoadProgress.
Fabrice (no longer in Chrome)
2015/04/16 13:55:25
Done.
|
| + |
| + // TODO(erikchen): Remove ScopedTracker below once crbug.com/465796 is fixed. |
| + tracked_objects::ScopedTracker tracking_profile3( |
| + 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_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 |