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

Side by Side Diff: components/devtools_service/devtools_agent_host.h

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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_AGENT_HOST_H_
6 #define COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_AGENT_HOST_H_
7
8 #include <string>
9
10 #include "base/macros.h"
11 #include "components/devtools_service/public/interfaces/devtools_service.mojom.h "
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
13 #include "third_party/mojo/src/mojo/public/cpp/bindings/callback.h"
14 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
15
16 namespace devtools_service {
17
18 // DevToolsAgentHost represents a DevTools agent at the service side.
19 class DevToolsAgentHost : public DevToolsAgentClient,
20 public mojo::ErrorHandler {
21 public:
22 class Delegate {
23 public:
24 virtual ~Delegate() {}
25
26 virtual void DispatchProtocolMessage(DevToolsAgentHost* agent_host,
27 const std::string& message) = 0;
28
29 // Notifies the delegate that |agent_host| is going away.
30 virtual void OnAgentHostClosed(DevToolsAgentHost* agent_host) = 0;
31 };
32
33 explicit DevToolsAgentHost(DevToolsAgentPtr agent);
34
35 ~DevToolsAgentHost() override;
36
37 void set_agent_connection_error_handler(const mojo::Closure& handler) {
38 agent_connection_error_handler_ = handler;
39 }
40
41 std::string id() const { return id_; }
42
43 // Doesn't take ownership of |delegate|. If |delegate| dies before this
44 // object, a new delegate or nullptr must be set so that this object doesn't
45 // hold an invalid pointer.
46 void SetDelegate(Delegate* delegate);
47
48 bool IsAttached() const { return !!delegate_; }
49
50 void SendProtocolMessageToAgent(const std::string& message);
51
52 private:
53 // DevToolsAgentClient implementation.
54 void DispatchProtocolMessage(const mojo::String& message) override;
55
56 // mojo::ErrorHandler implementation.
57 void OnConnectionError() override;
58
59 const std::string id_;
60
61 DevToolsAgentPtr agent_;
62 mojo::Closure agent_connection_error_handler_;
63
64 mojo::Binding<DevToolsAgentClient> binding_;
65
66 Delegate* delegate_;
67
68 DISALLOW_COPY_AND_ASSIGN(DevToolsAgentHost);
69 };
70
71 } // namespace devtools_service
72
73 #endif // COMPONENTS_DEVTOOLS_SERVICE_DEVTOOLS_AGENT_HOST_H_
OLDNEW
« no previous file with comments | « components/devtools_service/BUILD.gn ('k') | components/devtools_service/devtools_agent_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698