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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 std::vector<HeadlessWebContents*> result; | 139 std::vector<HeadlessWebContents*> result; |
140 result.reserve(web_contents_map_.size()); | 140 result.reserve(web_contents_map_.size()); |
141 | 141 |
142 for (const auto& web_contents_pair : web_contents_map_) { | 142 for (const auto& web_contents_pair : web_contents_map_) { |
143 result.push_back(web_contents_pair.second.get()); | 143 result.push_back(web_contents_pair.second.get()); |
144 } | 144 } |
145 | 145 |
146 return result; | 146 return result; |
147 } | 147 } |
148 | 148 |
| 149 void HeadlessBrowserContextImpl::SetFrameTreeNodeId(int render_process_id, |
| 150 int render_frame_routing_id, |
| 151 int frame_tree_node_id) { |
| 152 base::AutoLock lock(frame_tree_node_map_lock_); |
| 153 frame_tree_node_map_[std::make_pair( |
| 154 render_process_id, render_frame_routing_id)] = frame_tree_node_id; |
| 155 } |
| 156 |
| 157 void HeadlessBrowserContextImpl::RemoveFrameTreeNode( |
| 158 int render_process_id, |
| 159 int render_frame_routing_id) { |
| 160 base::AutoLock lock(frame_tree_node_map_lock_); |
| 161 frame_tree_node_map_.erase( |
| 162 std::make_pair(render_process_id, render_frame_routing_id)); |
| 163 } |
| 164 |
| 165 int HeadlessBrowserContextImpl::GetFrameTreeNodeId(int render_process_id, |
| 166 int render_frame_id) const { |
| 167 base::AutoLock lock(frame_tree_node_map_lock_); |
| 168 const auto& find_it = frame_tree_node_map_.find( |
| 169 std::make_pair(render_process_id, render_frame_id)); |
| 170 if (find_it == frame_tree_node_map_.end()) |
| 171 return -1; |
| 172 return find_it->second; |
| 173 } |
| 174 |
149 void HeadlessBrowserContextImpl::Close() { | 175 void HeadlessBrowserContextImpl::Close() { |
150 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 176 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
151 browser_->DestroyBrowserContext(this); | 177 browser_->DestroyBrowserContext(this); |
152 } | 178 } |
153 | 179 |
154 void HeadlessBrowserContextImpl::InitWhileIOAllowed() { | 180 void HeadlessBrowserContextImpl::InitWhileIOAllowed() { |
155 if (!context_options_->user_data_dir().empty()) { | 181 if (!context_options_->user_data_dir().empty()) { |
156 path_ = context_options_->user_data_dir(); | 182 path_ = context_options_->user_data_dir(); |
157 } else { | 183 } else { |
158 PathService::Get(base::DIR_EXE, &path_); | 184 PathService::Get(base::DIR_EXE, &path_); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 HeadlessBrowserContext::Builder::MojoBindings::MojoBindings() {} | 451 HeadlessBrowserContext::Builder::MojoBindings::MojoBindings() {} |
426 | 452 |
427 HeadlessBrowserContext::Builder::MojoBindings::MojoBindings( | 453 HeadlessBrowserContext::Builder::MojoBindings::MojoBindings( |
428 const std::string& mojom_name, | 454 const std::string& mojom_name, |
429 const std::string& js_bindings) | 455 const std::string& js_bindings) |
430 : mojom_name(mojom_name), js_bindings(js_bindings) {} | 456 : mojom_name(mojom_name), js_bindings(js_bindings) {} |
431 | 457 |
432 HeadlessBrowserContext::Builder::MojoBindings::~MojoBindings() {} | 458 HeadlessBrowserContext::Builder::MojoBindings::~MojoBindings() {} |
433 | 459 |
434 } // namespace headless | 460 } // namespace headless |
OLD | NEW |