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

Unified Diff: components/devtools_service/devtools_agent_host.cc

Issue 1164383002: Mandoline DevTools service: remote debugging protocol over HTTP/WebSocket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: components/devtools_service/devtools_agent_host.cc
diff --git a/components/devtools_service/devtools_agent_host.cc b/components/devtools_service/devtools_agent_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..91b993206d17f83df3cdda136796ab738ff2096b
--- /dev/null
+++ b/components/devtools_service/devtools_agent_host.cc
@@ -0,0 +1,56 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/devtools_service/devtools_agent_host.h"
+
+#include "base/guid.h"
+#include "base/logging.h"
+
+namespace devtools_service {
+
+DevToolsAgentHost::DevToolsAgentHost(DevToolsAgentPtr agent)
+ : id_(base::GenerateGUID()),
+ agent_(agent.Pass()),
+ binding_(this),
+ delegate_(nullptr) {
+ DCHECK(agent_);
jam 2015/06/09 22:21:21 nit: this is redundant since the next line will gi
yzshen1 2015/06/10 15:34:39 Done.
+ agent_.set_error_handler(this);
+}
+
+DevToolsAgentHost::~DevToolsAgentHost() {
+ if (delegate_)
+ delegate_->OnAgentHostClosed(this);
+}
+
+void DevToolsAgentHost::SetDelegate(Delegate* delegate) {
+ delegate_ = delegate;
+ if (delegate_) {
+ if (binding_.is_bound())
+ return;
+
+ DevToolsAgentClientPtr client;
+ binding_.Bind(&client);
+ agent_->SetClient(client.Pass(), id_);
+ } else {
+ if (!binding_.is_bound())
+ return;
+
+ binding_.Close();
+ }
+}
+
+void DevToolsAgentHost::SendProtocolMessageToAgent(const std::string& message) {
+ agent_->DispatchProtocolMessage(message);
+}
+
+void DevToolsAgentHost::DispatchProtocolMessage(const mojo::String& message) {
+ DCHECK(delegate_);
jam 2015/06/09 22:21:21 ditto
yzshen1 2015/06/10 15:34:39 Done.
+ delegate_->DispatchProtocolMessage(this, message);
+}
+
+void DevToolsAgentHost::OnConnectionError() {
+ agent_connection_error_handler_.Run();
+}
+
+} // namespace devtools_service

Powered by Google App Engine
This is Rietveld 408576698