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

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: 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/stl_util.h" 10 #include "base/stl_util.h"
11 #include "content/browser/frame_host/frame_tree.h" 11 #include "content/browser/frame_host/frame_tree.h"
12 #include "content/browser/frame_host/navigator.h" 12 #include "content/browser/frame_host/navigator.h"
13 #include "content/browser/frame_host/render_frame_host_impl.h" 13 #include "content/browser/frame_host/render_frame_host_impl.h"
14 #include "content/browser/renderer_host/render_view_host_impl.h" 14 #include "content/browser/renderer_host/render_view_host_impl.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 namespace { 20 namespace {
21 21
22 // This is a global map between frame_tree_node_ids and pointers to 22 // This is a global map between frame_tree_node_ids and pointers to
23 // FrameTreeNodes. 23 // FrameTreeNodes.
24 typedef base::hash_map<int64, FrameTreeNode*> FrameTreeNodeIDMap; 24 typedef base::hash_map<int64, FrameTreeNode*> FrameTreeNodeIDMap;
25 25
26 base::LazyInstance<FrameTreeNodeIDMap> g_frame_tree_node_id_map = 26 base::LazyInstance<FrameTreeNodeIDMap> g_frame_tree_node_id_map =
27 LAZY_INSTANCE_INITIALIZER; 27 LAZY_INSTANCE_INITIALIZER;
28 28
29 // These values indicate the loading progress status. The minimum progress
30 // value matches what Blink's ProgressTracker has traditionally used for a
31 // minimum progress value.
32 static const double kLoadingProgressNotStarted = 0.0;
33 static const double kLoadingProgressMinimum = 0.1;
34 static const double kLoadingProgressDone = 1.0;
35
29 } // namespace 36 } // namespace
30 37
31 const double FrameTreeNode::kLoadingProgressNotStarted = 0.0;
32 const double FrameTreeNode::kLoadingProgressMinimum = 0.1;
33 const double FrameTreeNode::kLoadingProgressDone = 1.0;
34
35 int64 FrameTreeNode::next_frame_tree_node_id_ = 1; 38 int64 FrameTreeNode::next_frame_tree_node_id_ = 1;
36 39
37 // static 40 // static
38 FrameTreeNode* FrameTreeNode::GloballyFindByID(int64 frame_tree_node_id) { 41 FrameTreeNode* FrameTreeNode::GloballyFindByID(int64 frame_tree_node_id) {
39 DCHECK_CURRENTLY_ON(BrowserThread::UI); 42 DCHECK_CURRENTLY_ON(BrowserThread::UI);
40 FrameTreeNodeIDMap* nodes = g_frame_tree_node_id_map.Pointer(); 43 FrameTreeNodeIDMap* nodes = g_frame_tree_node_id_map.Pointer();
41 FrameTreeNodeIDMap::iterator it = nodes->find(frame_tree_node_id); 44 FrameTreeNodeIDMap::iterator it = nodes->find(frame_tree_node_id);
42 return it == nodes->end() ? nullptr : it->second; 45 return it == nodes->end() ? nullptr : it->second;
43 } 46 }
44 47
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return current_frame_host->is_loading(); 170 return current_frame_host->is_loading();
168 } 171 }
169 172
170 bool FrameTreeNode::CommitPendingSandboxFlags() { 173 bool FrameTreeNode::CommitPendingSandboxFlags() {
171 bool did_change_flags = 174 bool did_change_flags =
172 effective_sandbox_flags_ != replication_state_.sandbox_flags; 175 effective_sandbox_flags_ != replication_state_.sandbox_flags;
173 effective_sandbox_flags_ = replication_state_.sandbox_flags; 176 effective_sandbox_flags_ = replication_state_.sandbox_flags;
174 return did_change_flags; 177 return did_change_flags;
175 } 178 }
176 179
180 bool FrameTreeNode::HasStartedLoading() const {
181 return loading_progress_ != kLoadingProgressNotStarted;
182 }
183
184 void FrameTreeNode::ResetLoadingProgress() {
185 loading_progress_ = kLoadingProgressNotStarted;
186 }
187
188 void FrameTreeNode::DidStartLoading(bool to_different_document) {
189 // Any main frame load to a new document should reset the load progress since
190 // it will replace the current page and any frames.
191 if (to_different_document && IsMainFrame())
192 frame_tree_->ResetLoadProgress();
Fabrice (no longer in Chrome) 2015/04/14 16:54:11 This part was problematic. We have "FrameTree:Rese
nasko 2015/04/14 19:54:41 If it isn't obvious, then it is a good candidate f
Fabrice (no longer in Chrome) 2015/04/15 15:15:02 I clarified the comments to ensure there is no con
193
194 // Notify the Navigator.
nasko 2015/04/14 19:54:40 Navigator doesn't really need to know about this.
Fabrice (no longer in Chrome) 2015/04/15 15:15:02 The issue is that Navigator does not have a delega
195 if (!frame_tree_->IsLoading())
196 navigator()->DidStartLoading(this, to_different_document);
197
198 // Notify the RenderFrameHostManager of the event.
199 render_manager()->OnDidStartLoading();
200
201 // Set initial load progress and update overall progress.
202 loading_progress_ = kLoadingProgressMinimum;
203 frame_tree_->UpdateLoadProgress();
204
nasko 2015/04/14 19:54:41 nit: no need for empty line.
Fabrice (no longer in Chrome) 2015/04/15 15:15:02 Done.
205 }
206
207 void FrameTreeNode::DidStopLoading() {
208 // Notify the RenderFrameHostManager of the event.
209 render_manager()->OnDidStopLoading();
210
211 // Set final load progress and update overall progress.
212 loading_progress_ = kLoadingProgressDone;
213 frame_tree_->UpdateLoadProgress();
214
215 // Notify the Navigator.
216 if (!frame_tree_->IsLoading())
217 navigator()->DidStopLoading();
218 }
219
220 void FrameTreeNode::DidChangeLoadProgress(double load_progress) {
221 loading_progress_ = load_progress;
222 frame_tree_->UpdateLoadProgress();
223 }
224
177 } // namespace content 225 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698