OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_devtools_client_impl.h" | 5 #include "headless/lib/browser/headless_devtools_client_impl.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 security_domain_(this), | 62 security_domain_(this), |
63 service_worker_domain_(this), | 63 service_worker_domain_(this), |
64 target_domain_(this), | 64 target_domain_(this), |
65 tracing_domain_(this), | 65 tracing_domain_(this), |
66 browser_main_thread_(content::BrowserThread::GetTaskRunnerForThread( | 66 browser_main_thread_(content::BrowserThread::GetTaskRunnerForThread( |
67 content::BrowserThread::UI)), | 67 content::BrowserThread::UI)), |
68 weak_ptr_factory_(this) {} | 68 weak_ptr_factory_(this) {} |
69 | 69 |
70 HeadlessDevToolsClientImpl::~HeadlessDevToolsClientImpl() {} | 70 HeadlessDevToolsClientImpl::~HeadlessDevToolsClientImpl() {} |
71 | 71 |
72 void HeadlessDevToolsClientImpl::AttachToHost( | 72 bool HeadlessDevToolsClientImpl::AttachToHost( |
| 73 content::DevToolsAgentHost* agent_host) { |
| 74 DCHECK(!agent_host_); |
| 75 if (agent_host->AttachClient(this)) { |
| 76 agent_host_ = agent_host; |
| 77 return true; |
| 78 } |
| 79 return false; |
| 80 } |
| 81 |
| 82 void HeadlessDevToolsClientImpl::ForceAttachToHost( |
73 content::DevToolsAgentHost* agent_host) { | 83 content::DevToolsAgentHost* agent_host) { |
74 DCHECK(!agent_host_); | 84 DCHECK(!agent_host_); |
75 agent_host_ = agent_host; | 85 agent_host_ = agent_host; |
76 agent_host_->AttachClient(this); | 86 agent_host_->ForceAttachClient(this); |
77 } | 87 } |
78 | 88 |
79 void HeadlessDevToolsClientImpl::DetachFromHost( | 89 void HeadlessDevToolsClientImpl::DetachFromHost( |
80 content::DevToolsAgentHost* agent_host) { | 90 content::DevToolsAgentHost* agent_host) { |
81 DCHECK_EQ(agent_host_, agent_host); | 91 DCHECK_EQ(agent_host_, agent_host); |
82 if (!renderer_crashed_) | 92 if (!renderer_crashed_) |
83 agent_host_->DetachClient(this); | 93 agent_host_->DetachClient(this); |
84 agent_host_ = nullptr; | 94 agent_host_ = nullptr; |
85 pending_messages_.clear(); | 95 pending_messages_.clear(); |
86 } | 96 } |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 HeadlessDevToolsClientImpl::Callback::Callback( | 379 HeadlessDevToolsClientImpl::Callback::Callback( |
370 base::Callback<void(const base::Value&)> callback) | 380 base::Callback<void(const base::Value&)> callback) |
371 : callback_with_result(callback) {} | 381 : callback_with_result(callback) {} |
372 | 382 |
373 HeadlessDevToolsClientImpl::Callback::~Callback() {} | 383 HeadlessDevToolsClientImpl::Callback::~Callback() {} |
374 | 384 |
375 HeadlessDevToolsClientImpl::Callback& HeadlessDevToolsClientImpl::Callback:: | 385 HeadlessDevToolsClientImpl::Callback& HeadlessDevToolsClientImpl::Callback:: |
376 operator=(Callback&& other) = default; | 386 operator=(Callback&& other) = default; |
377 | 387 |
378 } // namespace headless | 388 } // namespace headless |
OLD | NEW |