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

Side by Side Diff: headless/lib/browser/headless_devtools_client_impl.cc

Issue 2531313002: Expose the full API for attaching devtools clients: (Closed)
Patch Set: Created 4 years 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 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
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 } else {
Sami 2016/11/28 16:58:13 nit: Chromium doesn't use "else" after "return": h
tmarek 2016/11/29 10:14:58 Done.
79 return false;
80 }
81 }
82
83 void HeadlessDevToolsClientImpl::ForceAttachToHost(
73 content::DevToolsAgentHost* agent_host) { 84 content::DevToolsAgentHost* agent_host) {
74 DCHECK(!agent_host_); 85 DCHECK(!agent_host_);
75 agent_host_ = agent_host; 86 agent_host_ = agent_host;
76 agent_host_->AttachClient(this); 87 agent_host_->ForceAttachClient(this);
77 } 88 }
78 89
79 void HeadlessDevToolsClientImpl::DetachFromHost( 90 void HeadlessDevToolsClientImpl::DetachFromHost(
80 content::DevToolsAgentHost* agent_host) { 91 content::DevToolsAgentHost* agent_host) {
81 DCHECK_EQ(agent_host_, agent_host); 92 DCHECK_EQ(agent_host_, agent_host);
82 if (!renderer_crashed_) 93 if (!renderer_crashed_)
83 agent_host_->DetachClient(this); 94 agent_host_->DetachClient(this);
84 agent_host_ = nullptr; 95 agent_host_ = nullptr;
85 pending_messages_.clear(); 96 pending_messages_.clear();
86 } 97 }
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 HeadlessDevToolsClientImpl::Callback::Callback( 380 HeadlessDevToolsClientImpl::Callback::Callback(
370 base::Callback<void(const base::Value&)> callback) 381 base::Callback<void(const base::Value&)> callback)
371 : callback_with_result(callback) {} 382 : callback_with_result(callback) {}
372 383
373 HeadlessDevToolsClientImpl::Callback::~Callback() {} 384 HeadlessDevToolsClientImpl::Callback::~Callback() {}
374 385
375 HeadlessDevToolsClientImpl::Callback& HeadlessDevToolsClientImpl::Callback:: 386 HeadlessDevToolsClientImpl::Callback& HeadlessDevToolsClientImpl::Callback::
376 operator=(Callback&& other) = default; 387 operator=(Callback&& other) = default;
377 388
378 } // namespace headless 389 } // namespace headless
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698