OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef MOJO_SPY_SPY_H_ | 5 #ifndef MOJO_SPY_SPY_H_ |
6 #define MOJO_SPY_SPY_H_ | 6 #define MOJO_SPY_SPY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "mojo/public/cpp/system/message_pipe.h" |
| 12 #include "mojo/spy/common.h" |
| 13 #include "url/gurl.h" |
11 | 14 |
12 namespace base { | 15 namespace base { |
| 16 class Time; |
13 class Thread; | 17 class Thread; |
14 } | 18 } |
15 | 19 |
16 namespace mojo { | 20 namespace mojo { |
17 | 21 |
18 class ApplicationManager; | 22 class ApplicationManager; |
19 class SpyServerImpl; | 23 class SpyServerImpl; |
| 24 struct SpyOptions; |
20 | 25 |
21 // mojo::Spy is a troubleshooting and debugging aid. It helps tracking | 26 // mojo::Spy is a troubleshooting and debugging aid. It helps tracking |
22 // the mojo system core activities like messages, service creation, etc. | 27 // the mojo system core activities like messages, service creation, etc. |
23 // | 28 // |
24 // The |options| parameter in the constructor comes from the command | 29 // The |options| parameter in the constructor comes from the command |
25 // line of the mojo_shell. Which takes --spy=<options>. Each option is | 30 // line of the mojo_shell. Which takes --spy=<options>. Each option is |
26 // separated by ',' and each option is a key+ value pair separated by ':'. | 31 // separated by ',' and each option is a key+ value pair separated by ':'. |
27 // | 32 // |
28 // For example --spy=port:13333 | 33 // For example --spy=port:13333 |
29 // | 34 // |
30 class Spy { | 35 class Spy { |
31 public: | 36 public: |
| 37 // Interface for the shell-provided websocket server. |
| 38 class WebSocketDelegate { |
| 39 public: |
| 40 virtual void Start(int port, mojo::ScopedMessagePipeHandle server_pipe) = 0; |
| 41 virtual void OnMessage(mojo::MojoMessageData* data, |
| 42 const GURL& url, |
| 43 const base::Time& time) = 0; |
| 44 }; |
| 45 |
32 Spy(mojo::ApplicationManager* application_manager, | 46 Spy(mojo::ApplicationManager* application_manager, |
33 const std::string& options); | 47 const std::string& options); |
34 ~Spy(); | 48 ~Spy(); |
35 | 49 |
| 50 // non-owning reference to the websocket server. |
| 51 void SetWebSocketDelegate(WebSocketDelegate* websocket_delegate); |
| 52 |
36 private: | 53 private: |
37 scoped_refptr<SpyServerImpl> spy_server_; | 54 scoped_refptr<SpyServerImpl> spy_server_; |
38 // This thread runs the code that talks to the frontend. | 55 // This thread runs the code that talks to the frontend. |
39 scoped_ptr<base::Thread> control_thread_; | 56 scoped_ptr<base::Thread> control_thread_; |
| 57 // The delegate is in charge of talking to the html frontend. |
| 58 WebSocketDelegate* websocket_delegate_; |
| 59 ApplicationManager* application_manager_; |
| 60 SpyOptions* spy_options_; |
40 }; | 61 }; |
41 | 62 |
42 } // namespace mojo | 63 } // namespace mojo |
43 | 64 |
44 #endif // MOJO_SPY_SPY_H_ | 65 #endif // MOJO_SPY_SPY_H_ |
OLD | NEW |