| OLD | NEW | 
|---|
| 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 #include <utility> | 8 #include <utility> | 
| 9 | 9 | 
| 10 #include "base/bind.h" | 10 #include "base/bind.h" | 
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 114                               // The top-level frame must always be in a | 114                               // The top-level frame must always be in a | 
| 115                               // document scope. | 115                               // document scope. | 
| 116                               blink::WebTreeScopeType::Document, | 116                               blink::WebTreeScopeType::Document, | 
| 117                               std::string(), | 117                               std::string(), | 
| 118                               blink::WebSandboxFlags::None)), | 118                               blink::WebSandboxFlags::None)), | 
| 119       focused_frame_tree_node_id_(-1), | 119       focused_frame_tree_node_id_(-1), | 
| 120       load_progress_(0.0) { | 120       load_progress_(0.0) { | 
| 121 } | 121 } | 
| 122 | 122 | 
| 123 FrameTree::~FrameTree() { | 123 FrameTree::~FrameTree() { | 
|  | 124   delete root_; | 
|  | 125   root_ = nullptr; | 
| 124 } | 126 } | 
| 125 | 127 | 
| 126 FrameTreeNode* FrameTree::FindByID(int frame_tree_node_id) { | 128 FrameTreeNode* FrameTree::FindByID(int frame_tree_node_id) { | 
| 127   FrameTreeNode* node = nullptr; | 129   FrameTreeNode* node = nullptr; | 
| 128   ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node)); | 130   ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node)); | 
| 129   return node; | 131   return node; | 
| 130 } | 132 } | 
| 131 | 133 | 
| 132 FrameTreeNode* FrameTree::FindByRoutingID(int process_id, int routing_id) { | 134 FrameTreeNode* FrameTree::FindByRoutingID(int process_id, int routing_id) { | 
| 133   RenderFrameHostImpl* render_frame_host = | 135   RenderFrameHostImpl* render_frame_host = | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 144     FrameTreeNode* result = render_frame_proxy_host->frame_tree_node(); | 146     FrameTreeNode* result = render_frame_proxy_host->frame_tree_node(); | 
| 145     if (this == result->frame_tree()) | 147     if (this == result->frame_tree()) | 
| 146       return result; | 148       return result; | 
| 147   } | 149   } | 
| 148 | 150 | 
| 149   return nullptr; | 151   return nullptr; | 
| 150 } | 152 } | 
| 151 | 153 | 
| 152 FrameTreeNode* FrameTree::FindByName(const std::string& name) { | 154 FrameTreeNode* FrameTree::FindByName(const std::string& name) { | 
| 153   if (name.empty()) | 155   if (name.empty()) | 
| 154     return root_.get(); | 156     return root_; | 
| 155 | 157 | 
| 156   FrameTreeNode* node = nullptr; | 158   FrameTreeNode* node = nullptr; | 
| 157   ForEach(base::Bind(&FrameTreeNodeForName, name, &node)); | 159   ForEach(base::Bind(&FrameTreeNodeForName, name, &node)); | 
| 158   return node; | 160   return node; | 
| 159 } | 161 } | 
| 160 | 162 | 
| 161 void FrameTree::ForEach( | 163 void FrameTree::ForEach( | 
| 162     const base::Callback<bool(FrameTreeNode*)>& on_node) const { | 164     const base::Callback<bool(FrameTreeNode*)>& on_node) const { | 
| 163   ForEach(on_node, nullptr); | 165   ForEach(on_node, nullptr); | 
| 164 } | 166 } | 
| 165 | 167 | 
| 166 void FrameTree::ForEach( | 168 void FrameTree::ForEach( | 
| 167     const base::Callback<bool(FrameTreeNode*)>& on_node, | 169     const base::Callback<bool(FrameTreeNode*)>& on_node, | 
| 168     FrameTreeNode* skip_this_subtree) const { | 170     FrameTreeNode* skip_this_subtree) const { | 
| 169   std::queue<FrameTreeNode*> queue; | 171   std::queue<FrameTreeNode*> queue; | 
| 170   queue.push(root_.get()); | 172   queue.push(root_); | 
| 171 | 173 | 
| 172   while (!queue.empty()) { | 174   while (!queue.empty()) { | 
| 173     FrameTreeNode* node = queue.front(); | 175     FrameTreeNode* node = queue.front(); | 
| 174     queue.pop(); | 176     queue.pop(); | 
| 175     if (skip_this_subtree == node) | 177     if (skip_this_subtree == node) | 
| 176       continue; | 178       continue; | 
| 177 | 179 | 
| 178     if (!on_node.Run(node)) | 180     if (!on_node.Run(node)) | 
| 179       break; | 181       break; | 
| 180 | 182 | 
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 355     CHECK(render_view_host_found); | 357     CHECK(render_view_host_found); | 
| 356   } | 358   } | 
| 357 } | 359 } | 
| 358 | 360 | 
| 359 void FrameTree::FrameRemoved(FrameTreeNode* frame) { | 361 void FrameTree::FrameRemoved(FrameTreeNode* frame) { | 
| 360   if (frame->frame_tree_node_id() == focused_frame_tree_node_id_) | 362   if (frame->frame_tree_node_id() == focused_frame_tree_node_id_) | 
| 361     focused_frame_tree_node_id_ = -1; | 363     focused_frame_tree_node_id_ = -1; | 
| 362 | 364 | 
| 363   // No notification for the root frame. | 365   // No notification for the root frame. | 
| 364   if (!frame->parent()) { | 366   if (!frame->parent()) { | 
| 365     CHECK_EQ(frame, root_.get()); | 367     CHECK_EQ(frame, root_); | 
| 366     return; | 368     return; | 
| 367   } | 369   } | 
| 368 | 370 | 
| 369   // Notify observers of the frame removal. | 371   // Notify observers of the frame removal. | 
| 370   if (!on_frame_removed_.is_null()) | 372   if (!on_frame_removed_.is_null()) | 
| 371     on_frame_removed_.Run(frame->current_frame_host()); | 373     on_frame_removed_.Run(frame->current_frame_host()); | 
| 372 } | 374 } | 
| 373 | 375 | 
| 374 void FrameTree::UpdateLoadProgress() { | 376 void FrameTree::UpdateLoadProgress() { | 
| 375   double progress = 0.0; | 377   double progress = 0.0; | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 392   load_progress_ = 0.0; | 394   load_progress_ = 0.0; | 
| 393 } | 395 } | 
| 394 | 396 | 
| 395 bool FrameTree::IsLoading() { | 397 bool FrameTree::IsLoading() { | 
| 396   bool is_loading = false; | 398   bool is_loading = false; | 
| 397   ForEach(base::Bind(&IsNodeLoading, &is_loading)); | 399   ForEach(base::Bind(&IsNodeLoading, &is_loading)); | 
| 398   return is_loading; | 400   return is_loading; | 
| 399 } | 401 } | 
| 400 | 402 | 
| 401 }  // namespace content | 403 }  // namespace content | 
| OLD | NEW | 
|---|