| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "headless/lib/browser/headless_browser_context_impl.h" | 5 #include "headless/lib/browser/headless_browser_context_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 std::vector<HeadlessWebContents*> result; | 137 std::vector<HeadlessWebContents*> result; |
| 138 result.reserve(web_contents_map_.size()); | 138 result.reserve(web_contents_map_.size()); |
| 139 | 139 |
| 140 for (const auto& web_contents_pair : web_contents_map_) { | 140 for (const auto& web_contents_pair : web_contents_map_) { |
| 141 result.push_back(web_contents_pair.second.get()); | 141 result.push_back(web_contents_pair.second.get()); |
| 142 } | 142 } |
| 143 | 143 |
| 144 return result; | 144 return result; |
| 145 } | 145 } |
| 146 | 146 |
| 147 void HeadlessBrowserContextImpl::SetFrameTreeNodeId(int render_process_id, |
| 148 int render_frame_routing_id, |
| 149 int frame_tree_node_id) { |
| 150 base::AutoLock lock(frame_tree_node_map_lock_); |
| 151 frame_tree_node_map_[std::make_pair( |
| 152 render_process_id, render_frame_routing_id)] = frame_tree_node_id; |
| 153 } |
| 154 |
| 155 void HeadlessBrowserContextImpl::RemoveFrameTreeNode( |
| 156 int render_process_id, |
| 157 int render_frame_routing_id) { |
| 158 base::AutoLock lock(frame_tree_node_map_lock_); |
| 159 frame_tree_node_map_.erase( |
| 160 std::make_pair(render_process_id, render_frame_routing_id)); |
| 161 } |
| 162 |
| 163 int HeadlessBrowserContextImpl::GetFrameTreeNodeId(int render_process_id, |
| 164 int render_frame_id) const { |
| 165 base::AutoLock lock(frame_tree_node_map_lock_); |
| 166 const auto& find_it = frame_tree_node_map_.find( |
| 167 std::make_pair(render_process_id, render_frame_id)); |
| 168 if (find_it == frame_tree_node_map_.end()) |
| 169 return -1; |
| 170 return find_it->second; |
| 171 } |
| 172 |
| 147 void HeadlessBrowserContextImpl::Close() { | 173 void HeadlessBrowserContextImpl::Close() { |
| 148 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 174 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 149 browser_->DestroyBrowserContext(this); | 175 browser_->DestroyBrowserContext(this); |
| 150 } | 176 } |
| 151 | 177 |
| 152 void HeadlessBrowserContextImpl::InitWhileIOAllowed() { | 178 void HeadlessBrowserContextImpl::InitWhileIOAllowed() { |
| 153 if (!context_options_->user_data_dir().empty()) { | 179 if (!context_options_->user_data_dir().empty()) { |
| 154 path_ = context_options_->user_data_dir(); | 180 path_ = context_options_->user_data_dir(); |
| 155 } else { | 181 } else { |
| 156 PathService::Get(base::DIR_EXE, &path_); | 182 PathService::Get(base::DIR_EXE, &path_); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 HeadlessBrowserContext::Builder::MojoBindings::MojoBindings() {} | 448 HeadlessBrowserContext::Builder::MojoBindings::MojoBindings() {} |
| 423 | 449 |
| 424 HeadlessBrowserContext::Builder::MojoBindings::MojoBindings( | 450 HeadlessBrowserContext::Builder::MojoBindings::MojoBindings( |
| 425 const std::string& mojom_name, | 451 const std::string& mojom_name, |
| 426 const std::string& js_bindings) | 452 const std::string& js_bindings) |
| 427 : mojom_name(mojom_name), js_bindings(js_bindings) {} | 453 : mojom_name(mojom_name), js_bindings(js_bindings) {} |
| 428 | 454 |
| 429 HeadlessBrowserContext::Builder::MojoBindings::~MojoBindings() {} | 455 HeadlessBrowserContext::Builder::MojoBindings::~MojoBindings() {} |
| 430 | 456 |
| 431 } // namespace headless | 457 } // namespace headless |
| OLD | NEW |