summaryrefslogtreecommitdiffstats
path: root/components/devtools_service
diff options
context:
space:
mode:
authoryzshen <yzshen@chromium.org>2015-06-05 18:05:28 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-06 01:06:06 +0000
commit1b6797343bab734718a0c81136010863c0c56617 (patch)
tree5c37d082d5ca727e175f992cf1f3027ad3a40e97 /components/devtools_service
parenta20ef837ff3fd2e3772e91d69baf9afca29983a1 (diff)
downloadchromium_src-1b6797343bab734718a0c81136010863c0c56617.zip
chromium_src-1b6797343bab734718a0c81136010863c0c56617.tar.gz
chromium_src-1b6797343bab734718a0c81136010863c0c56617.tar.bz2
Mandoline DevTools service: split up the DevToolsService class.
The HTTP server and agent registry are moved into their own classes. BUG=478249 Review URL: https://codereview.chromium.org/1158793005 Cr-Commit-Position: refs/heads/master@{#333193}
Diffstat (limited to 'components/devtools_service')
-rw-r--r--components/devtools_service/BUILD.gn4
-rw-r--r--components/devtools_service/devtools_http_server.cc151
-rw-r--r--components/devtools_service/devtools_http_server.h63
-rw-r--r--components/devtools_service/devtools_registry_impl.cc28
-rw-r--r--components/devtools_service/devtools_registry_impl.h37
-rw-r--r--components/devtools_service/devtools_service.cc150
-rw-r--r--components/devtools_service/devtools_service.h54
-rw-r--r--components/devtools_service/devtools_service_delegate.cc4
8 files changed, 303 insertions, 188 deletions
diff --git a/components/devtools_service/BUILD.gn b/components/devtools_service/BUILD.gn
index 7b16038..1dc5c46 100644
--- a/components/devtools_service/BUILD.gn
+++ b/components/devtools_service/BUILD.gn
@@ -6,6 +6,10 @@ import("//third_party/mojo/src/mojo/public/mojo_application.gni")
source_set("lib") {
sources = [
+ "devtools_http_server.cc",
+ "devtools_http_server.h",
+ "devtools_registry_impl.cc",
+ "devtools_registry_impl.h",
"devtools_service.cc",
"devtools_service.h",
"devtools_service_delegate.cc",
diff --git a/components/devtools_service/devtools_http_server.cc b/components/devtools_service/devtools_http_server.cc
new file mode 100644
index 0000000..7199f2b
--- /dev/null
+++ b/components/devtools_service/devtools_http_server.cc
@@ -0,0 +1,151 @@
+// 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_http_server.h"
+
+#include "base/logging.h"
+#include "base/stl_util.h"
+#include "base/strings/stringprintf.h"
+#include "components/devtools_service/devtools_service.h"
+#include "mojo/application/public/cpp/application_impl.h"
+#include "mojo/services/network/public/interfaces/http_message.mojom.h"
+#include "mojo/services/network/public/interfaces/net_address.mojom.h"
+#include "mojo/services/network/public/interfaces/network_service.mojom.h"
+
+namespace devtools_service {
+
+class DevToolsHttpServer::HttpConnectionDelegateImpl
+ : public mojo::HttpConnectionDelegate,
+ public mojo::ErrorHandler {
+ public:
+ HttpConnectionDelegateImpl(
+ DevToolsHttpServer* owner,
+ mojo::HttpConnectionPtr connection,
+ mojo::InterfaceRequest<HttpConnectionDelegate> delegate_request)
+ : owner_(owner),
+ connection_(connection.Pass()),
+ binding_(this, delegate_request.Pass()) {
+ DCHECK(owner_);
+ DCHECK(connection_);
+ DCHECK(binding_.is_bound());
+
+ connection_.set_error_handler(this);
+ binding_.set_error_handler(this);
+ }
+
+ mojo::HttpConnection* connection() { return connection_.get(); }
+
+ private:
+ // mojo::HttpConnectionDelegate implementation:
+ void OnReceivedRequest(mojo::HttpRequestPtr request,
+ const OnReceivedRequestCallback& callback) override {
+ owner_->OnReceivedRequest(this, request.Pass(), callback);
+ }
+
+ void OnReceivedWebSocketRequest(
+ mojo::HttpRequestPtr request,
+ const OnReceivedWebSocketRequestCallback& callback) override {
+ owner_->OnReceivedWebSocketRequest(this, request.Pass(), callback);
+ }
+
+ // mojo::ErrorHandler implementation.
+ void OnConnectionError() override { owner_->OnConnectionClosed(this); }
+
+ DevToolsHttpServer* const owner_;
+ mojo::HttpConnectionPtr connection_;
+ mojo::Binding<HttpConnectionDelegate> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(HttpConnectionDelegateImpl);
+};
+
+DevToolsHttpServer::DevToolsHttpServer(DevToolsService* service,
+ uint16_t remote_debugging_port)
+ : service_(service) {
+ VLOG(1) << "Remote debugging HTTP server is started on port "
+ << remote_debugging_port << ".";
+ mojo::NetworkServicePtr network_service;
+ mojo::URLRequestPtr request(mojo::URLRequest::New());
+ request->url = "mojo:network_service";
+ service_->application()->ConnectToService(request.Pass(), &network_service);
+
+ mojo::NetAddressPtr local_address(mojo::NetAddress::New());
+ local_address->family = mojo::NET_ADDRESS_FAMILY_IPV4;
+ local_address->ipv4 = mojo::NetAddressIPv4::New();
+ local_address->ipv4->port = remote_debugging_port;
+ local_address->ipv4->addr.resize(4);
+ local_address->ipv4->addr[0] = 127;
+ local_address->ipv4->addr[1] = 0;
+ local_address->ipv4->addr[2] = 0;
+ local_address->ipv4->addr[3] = 1;
+
+ mojo::HttpServerDelegatePtr http_server_delegate;
+ http_server_delegate_binding_.reset(
+ new mojo::Binding<mojo::HttpServerDelegate>(this, &http_server_delegate));
+ network_service->CreateHttpServer(
+ local_address.Pass(), http_server_delegate.Pass(),
+ mojo::NetworkService::CreateHttpServerCallback());
+}
+
+DevToolsHttpServer::~DevToolsHttpServer() {
+ STLDeleteElements(&connections_);
+}
+
+void DevToolsHttpServer::OnConnected(
+ mojo::HttpConnectionPtr connection,
+ mojo::InterfaceRequest<mojo::HttpConnectionDelegate> delegate) {
+ connections_.insert(
+ new HttpConnectionDelegateImpl(this, connection.Pass(), delegate.Pass()));
+}
+
+void DevToolsHttpServer::OnReceivedRequest(
+ HttpConnectionDelegateImpl* connection,
+ mojo::HttpRequestPtr request,
+ const OnReceivedRequestCallback& callback) {
+ DCHECK(connections_.find(connection) != connections_.end());
+
+ // TODO(yzshen): Implement it.
+ static const char kNotImplemented[] = "Not implemented yet!";
+ mojo::HttpResponsePtr response(mojo::HttpResponse::New());
+ response->headers.resize(2);
+ response->headers[0] = mojo::HttpHeader::New();
+ response->headers[0]->name = "Content-Length";
+ response->headers[0]->value = base::StringPrintf(
+ "%lu", static_cast<unsigned long>(sizeof(kNotImplemented)));
+ response->headers[1] = mojo::HttpHeader::New();
+ response->headers[1]->name = "Content-Type";
+ response->headers[1]->value = "text/html";
+
+ uint32_t num_bytes = sizeof(kNotImplemented);
+ MojoCreateDataPipeOptions options;
+ options.struct_size = sizeof(MojoCreateDataPipeOptions);
+ options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE;
+ options.element_num_bytes = 1;
+ options.capacity_num_bytes = num_bytes;
+ mojo::DataPipe data_pipe(options);
+ response->body = data_pipe.consumer_handle.Pass();
+ WriteDataRaw(data_pipe.producer_handle.get(), kNotImplemented, &num_bytes,
+ MOJO_WRITE_DATA_FLAG_ALL_OR_NONE);
+
+ callback.Run(response.Pass());
+}
+
+void DevToolsHttpServer::OnReceivedWebSocketRequest(
+ HttpConnectionDelegateImpl* connection,
+ mojo::HttpRequestPtr request,
+ const OnReceivedWebSocketRequestCallback& callback) {
+ DCHECK(connections_.find(connection) != connections_.end());
+
+ // TODO(yzshen): Implement it.
+ NOTIMPLEMENTED();
+}
+
+void DevToolsHttpServer::OnConnectionClosed(
+ HttpConnectionDelegateImpl* connection) {
+ DCHECK(connections_.find(connection) != connections_.end());
+
+ delete connection;
+ connections_.erase(connection);
+}
+
+} // namespace devtools_service
diff --git a/components/devtools_service/devtools_http_server.h b/components/devtools_service/devtools_http_server.h
new file mode 100644
index 0000000..6a9a1a9
--- /dev/null
+++ b/components/devtools_service/devtools_http_server.h
@@ -0,0 +1,63 @@
+// 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.
+
+#ifndef COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_HTTP_SERVER_H_
+#define COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_HTTP_SERVER_H_
+
+#include <set>
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "mojo/services/network/public/interfaces/http_connection.mojom.h"
+#include "mojo/services/network/public/interfaces/http_server.mojom.h"
+
+namespace devtools_service {
+
+class DevToolsService;
+
+class DevToolsHttpServer : public mojo::HttpServerDelegate {
+ public:
+ // |service| must outlive this object.
+ DevToolsHttpServer(DevToolsService* service, uint16_t remote_debugging_port);
+ ~DevToolsHttpServer() override;
+
+ private:
+ class HttpConnectionDelegateImpl;
+
+ // mojo::HttpServerDelegate implementation.
+ void OnConnected(
+ mojo::HttpConnectionPtr connection,
+ mojo::InterfaceRequest<mojo::HttpConnectionDelegate> delegate) override;
+
+ // The following methods are called by HttpConnectionDelegateImpl.
+ using OnReceivedRequestCallback =
+ mojo::HttpConnectionDelegate::OnReceivedRequestCallback;
+ void OnReceivedRequest(HttpConnectionDelegateImpl* connection,
+ mojo::HttpRequestPtr request,
+ const OnReceivedRequestCallback& callback);
+
+ using OnReceivedWebSocketRequestCallback =
+ mojo::HttpConnectionDelegate::OnReceivedWebSocketRequestCallback;
+ void OnReceivedWebSocketRequest(
+ HttpConnectionDelegateImpl* connection,
+ mojo::HttpRequestPtr request,
+ const OnReceivedWebSocketRequestCallback& callback);
+
+ void OnConnectionClosed(HttpConnectionDelegateImpl* connection);
+
+ // Not owned by this object.
+ DevToolsService* const service_;
+
+ scoped_ptr<mojo::Binding<mojo::HttpServerDelegate>>
+ http_server_delegate_binding_;
+
+ // Owns the elements.
+ std::set<HttpConnectionDelegateImpl*> connections_;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsHttpServer);
+};
+
+} // namespace devtools_service
+
+#endif // COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_HTTP_SERVER_H_
diff --git a/components/devtools_service/devtools_registry_impl.cc b/components/devtools_service/devtools_registry_impl.cc
new file mode 100644
index 0000000..130f20f
--- /dev/null
+++ b/components/devtools_service/devtools_registry_impl.cc
@@ -0,0 +1,28 @@
+// 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_registry_impl.h"
+
+#include "base/logging.h"
+
+namespace devtools_service {
+
+DevToolsRegistryImpl::DevToolsRegistryImpl(DevToolsService* service)
+ : service_(service) {
+}
+
+DevToolsRegistryImpl::~DevToolsRegistryImpl() {
+}
+
+void DevToolsRegistryImpl::BindToRegistryRequest(
+ mojo::InterfaceRequest<DevToolsRegistry> request) {
+ bindings_.AddBinding(this, request.Pass());
+}
+
+void DevToolsRegistryImpl::RegisterAgent(DevToolsAgentPtr agent) {
+ // TODO(yzshen): Implement it.
+ NOTIMPLEMENTED();
+}
+
+} // namespace devtools_service
diff --git a/components/devtools_service/devtools_registry_impl.h b/components/devtools_service/devtools_registry_impl.h
new file mode 100644
index 0000000..c12c0de
--- /dev/null
+++ b/components/devtools_service/devtools_registry_impl.h
@@ -0,0 +1,37 @@
+// 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.
+
+#ifndef COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_REGISTRY_IMPL_H_
+#define COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_REGISTRY_IMPL_H_
+
+#include "base/macros.h"
+#include "components/devtools_service/public/interfaces/devtools_service.mojom.h"
+#include "mojo/common/weak_binding_set.h"
+
+namespace devtools_service {
+
+class DevToolsService;
+
+class DevToolsRegistryImpl : public DevToolsRegistry {
+ public:
+ // |service| must outlive this object.
+ explicit DevToolsRegistryImpl(DevToolsService* service);
+ ~DevToolsRegistryImpl() override;
+
+ void BindToRegistryRequest(mojo::InterfaceRequest<DevToolsRegistry> request);
+
+ private:
+ // DevToolsRegistry implementation.
+ void RegisterAgent(DevToolsAgentPtr agent) override;
+
+ DevToolsService* const service_;
+
+ mojo::WeakBindingSet<DevToolsRegistry> bindings_;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsRegistryImpl);
+};
+
+} // namespace devtools_service
+
+#endif // COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_REGISTRY_IMPL_H_
diff --git a/components/devtools_service/devtools_service.cc b/components/devtools_service/devtools_service.cc
index 479da5c..6cc0ede 100644
--- a/components/devtools_service/devtools_service.cc
+++ b/components/devtools_service/devtools_service.cc
@@ -5,77 +5,18 @@
#include "components/devtools_service/devtools_service.h"
#include "base/logging.h"
-#include "base/stl_util.h"
-#include "base/strings/stringprintf.h"
+#include "components/devtools_service/devtools_http_server.h"
+#include "components/devtools_service/devtools_registry_impl.h"
#include "mojo/application/public/cpp/application_impl.h"
-#include "mojo/services/network/public/interfaces/http_message.mojom.h"
-#include "mojo/services/network/public/interfaces/net_address.mojom.h"
-#include "mojo/services/network/public/interfaces/network_service.mojom.h"
namespace devtools_service {
-class DevToolsService::HttpConnectionDelegateImpl
- : public mojo::HttpConnectionDelegate,
- public mojo::ErrorHandler {
- public:
- HttpConnectionDelegateImpl(
- DevToolsService* owner,
- mojo::HttpConnectionPtr connection,
- mojo::InterfaceRequest<HttpConnectionDelegate> delegate_request)
- : owner_(owner),
- connection_(connection.Pass()),
- binding_(this, delegate_request.Pass()) {
- DCHECK(owner_);
- DCHECK(connection_);
- DCHECK(binding_.is_bound());
-
- connection_.set_error_handler(this);
- binding_.set_error_handler(this);
- }
-
- mojo::HttpConnection* connection() { return connection_.get(); }
-
- private:
- // mojo::HttpConnectionDelegate implementation:
- void OnReceivedRequest(mojo::HttpRequestPtr request,
- const OnReceivedRequestCallback& callback) override {
- owner_->OnReceivedRequest(this, request.Pass(), callback);
- }
-
- void OnReceivedWebSocketRequest(
- mojo::HttpRequestPtr request,
- const OnReceivedWebSocketRequestCallback& callback) override {
- owner_->OnReceivedWebSocketRequest(this, request.Pass(), callback);
- }
-
- // mojo::ErrorHandler implementation.
- void OnConnectionError() override { owner_->OnConnectionClosed(this); }
-
- DevToolsService* const owner_;
- mojo::HttpConnectionPtr connection_;
- mojo::Binding<HttpConnectionDelegate> binding_;
-
- DISALLOW_COPY_AND_ASSIGN(HttpConnectionDelegateImpl);
-};
-
DevToolsService::DevToolsService(mojo::ApplicationImpl* application)
: application_(application) {
DCHECK(application_);
}
DevToolsService::~DevToolsService() {
- STLDeleteElements(&connections_);
-}
-
-void DevToolsService::BindToRegistryRequest(
- mojo::InterfaceRequest<DevToolsRegistry> request) {
- if (!IsInitialized()) {
- // Ignore the request if remote debugging is not needed.
- return;
- }
-
- // TODO(yzshen): Implement it.
- NOTIMPLEMENTED();
}
void DevToolsService::BindToCoordinatorRequest(
@@ -91,91 +32,8 @@ void DevToolsService::Initialize(uint16_t remote_debugging_port) {
return;
}
- VLOG(1) << "Remote debugging HTTP server is started on port "
- << remote_debugging_port << ".";
- mojo::NetworkServicePtr network_service;
- mojo::URLRequestPtr request(mojo::URLRequest::New());
- request->url = "mojo:network_service";
- application_->ConnectToService(request.Pass(), &network_service);
-
- mojo::NetAddressPtr local_address(mojo::NetAddress::New());
- local_address->family = mojo::NET_ADDRESS_FAMILY_IPV4;
- local_address->ipv4 = mojo::NetAddressIPv4::New();
- local_address->ipv4->port = remote_debugging_port;
- local_address->ipv4->addr.resize(4);
- local_address->ipv4->addr[0] = 127;
- local_address->ipv4->addr[1] = 0;
- local_address->ipv4->addr[2] = 0;
- local_address->ipv4->addr[3] = 1;
-
- mojo::HttpServerDelegatePtr http_server_delegate;
- http_server_delegate_binding_.reset(
- new mojo::Binding<mojo::HttpServerDelegate>(this, &http_server_delegate));
- network_service->CreateHttpServer(
- local_address.Pass(), http_server_delegate.Pass(),
- mojo::NetworkService::CreateHttpServerCallback());
-}
-
-void DevToolsService::RegisterAgent(DevToolsAgentPtr agent) {
- // TODO(yzshen): Implement it.
- NOTIMPLEMENTED();
-}
-
-void DevToolsService::OnConnected(
- mojo::HttpConnectionPtr connection,
- mojo::InterfaceRequest<mojo::HttpConnectionDelegate> delegate) {
- connections_.insert(
- new HttpConnectionDelegateImpl(this, connection.Pass(), delegate.Pass()));
-}
-
-void DevToolsService::OnReceivedRequest(
- HttpConnectionDelegateImpl* connection,
- mojo::HttpRequestPtr request,
- const OnReceivedRequestCallback& callback) {
- DCHECK(connections_.find(connection) != connections_.end());
-
- // TODO(yzshen): Implement it.
- static const char kNotImplemented[] = "Not implemented yet!";
- mojo::HttpResponsePtr response(mojo::HttpResponse::New());
- response->headers.resize(2);
- response->headers[0] = mojo::HttpHeader::New();
- response->headers[0]->name = "Content-Length";
- response->headers[0]->value = base::StringPrintf(
- "%lu", static_cast<unsigned long>(sizeof(kNotImplemented)));
- response->headers[1] = mojo::HttpHeader::New();
- response->headers[1]->name = "Content-Type";
- response->headers[1]->value = "text/html";
-
- uint32_t num_bytes = sizeof(kNotImplemented);
- MojoCreateDataPipeOptions options;
- options.struct_size = sizeof(MojoCreateDataPipeOptions);
- options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE;
- options.element_num_bytes = 1;
- options.capacity_num_bytes = num_bytes;
- mojo::DataPipe data_pipe(options);
- response->body = data_pipe.consumer_handle.Pass();
- WriteDataRaw(data_pipe.producer_handle.get(), kNotImplemented, &num_bytes,
- MOJO_WRITE_DATA_FLAG_ALL_OR_NONE);
-
- callback.Run(response.Pass());
-}
-
-void DevToolsService::OnReceivedWebSocketRequest(
- HttpConnectionDelegateImpl* connection,
- mojo::HttpRequestPtr request,
- const OnReceivedWebSocketRequestCallback& callback) {
- DCHECK(connections_.find(connection) != connections_.end());
-
- // TODO(yzshen): Implement it.
- NOTIMPLEMENTED();
-}
-
-void DevToolsService::OnConnectionClosed(
- HttpConnectionDelegateImpl* connection) {
- DCHECK(connections_.find(connection) != connections_.end());
-
- delete connection;
- connections_.erase(connection);
+ http_server_.reset(new DevToolsHttpServer(this, remote_debugging_port));
+ registry_.reset(new DevToolsRegistryImpl(this));
}
} // namespace devtools_service
diff --git a/components/devtools_service/devtools_service.h b/components/devtools_service/devtools_service.h
index 9234848..a1385a6 100644
--- a/components/devtools_service/devtools_service.h
+++ b/components/devtools_service/devtools_service.h
@@ -5,14 +5,10 @@
#ifndef COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_SERVICE_H_
#define COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_SERVICE_H_
-#include <set>
-
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "components/devtools_service/public/interfaces/devtools_service.mojom.h"
#include "mojo/common/weak_binding_set.h"
-#include "mojo/services/network/public/interfaces/http_connection.mojom.h"
-#include "mojo/services/network/public/interfaces/http_server.mojom.h"
namespace mojo {
class ApplicationImpl;
@@ -20,63 +16,39 @@ class ApplicationImpl;
namespace devtools_service {
+class DevToolsHttpServer;
+class DevToolsRegistryImpl;
+
// DevToolsService is the central control. It manages the communication with
// DevTools agents (e.g., Web page renderers). It also starts an HTTP server to
// speak the Chrome remote debugging protocol.
-class DevToolsService : public DevToolsRegistry,
- public DevToolsCoordinator,
- public mojo::HttpServerDelegate {
+class DevToolsService : public DevToolsCoordinator {
public:
// Doesn't take ownership of |application|, which must outlive this object.
explicit DevToolsService(mojo::ApplicationImpl* application);
~DevToolsService() override;
- void BindToRegistryRequest(mojo::InterfaceRequest<DevToolsRegistry> request);
void BindToCoordinatorRequest(
mojo::InterfaceRequest<DevToolsCoordinator> request);
- private:
- class HttpConnectionDelegateImpl;
-
- // DevToolsCoordinator implementation.
- void Initialize(uint16_t remote_debugging_port) override;
-
- // DevToolsRegistry implementation.
- void RegisterAgent(DevToolsAgentPtr agent) override;
+ mojo::ApplicationImpl* application() { return application_; }
- // mojo::HttpServerDelegate implementation.
- void OnConnected(
- mojo::HttpConnectionPtr connection,
- mojo::InterfaceRequest<mojo::HttpConnectionDelegate> delegate) override;
+ bool IsInitialized() const { return !!http_server_; }
- bool IsInitialized() const { return !!http_server_delegate_binding_; }
+ // Non-null if initialized.
+ DevToolsRegistryImpl* registry() { return registry_.get(); }
- // The following methods are called by HttpConnectionDelegateImpl.
- using OnReceivedRequestCallback =
- mojo::HttpConnectionDelegate::OnReceivedRequestCallback;
- void OnReceivedRequest(HttpConnectionDelegateImpl* connection,
- mojo::HttpRequestPtr request,
- const OnReceivedRequestCallback& callback);
-
- using OnReceivedWebSocketRequestCallback =
- mojo::HttpConnectionDelegate::OnReceivedWebSocketRequestCallback;
- void OnReceivedWebSocketRequest(
- HttpConnectionDelegateImpl* connection,
- mojo::HttpRequestPtr request,
- const OnReceivedWebSocketRequestCallback& callback);
-
- void OnConnectionClosed(HttpConnectionDelegateImpl* connection);
+ private:
+ // DevToolsCoordinator implementation.
+ void Initialize(uint16_t remote_debugging_port) override;
// Not owned by this object.
mojo::ApplicationImpl* const application_;
mojo::WeakBindingSet<DevToolsCoordinator> coordinator_bindings_;
- scoped_ptr<mojo::Binding<mojo::HttpServerDelegate>>
- http_server_delegate_binding_;
-
- // Owns the elements.
- std::set<HttpConnectionDelegateImpl*> connections_;
+ scoped_ptr<DevToolsHttpServer> http_server_;
+ scoped_ptr<DevToolsRegistryImpl> registry_;
DISALLOW_COPY_AND_ASSIGN(DevToolsService);
};
diff --git a/components/devtools_service/devtools_service_delegate.cc b/components/devtools_service/devtools_service_delegate.cc
index 7f0d230..137d06d 100644
--- a/components/devtools_service/devtools_service_delegate.cc
+++ b/components/devtools_service/devtools_service_delegate.cc
@@ -5,6 +5,7 @@
#include "components/devtools_service/devtools_service_delegate.h"
#include "base/logging.h"
+#include "components/devtools_service/devtools_registry_impl.h"
#include "components/devtools_service/devtools_service.h"
#include "mojo/application/public/cpp/application_connection.h"
#include "mojo/application/public/cpp/application_impl.h"
@@ -51,7 +52,8 @@ void DevToolsServiceDelegate::Quit() {
void DevToolsServiceDelegate::Create(
mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<DevToolsRegistry> request) {
- service_->BindToRegistryRequest(request.Pass());
+ if (service_->IsInitialized())
+ service_->registry()->BindToRegistryRequest(request.Pass());
}
void DevToolsServiceDelegate::Create(