OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BROWSER_TARGET_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BROWSER_TARGET_H_ |
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BROWSER_TARGET_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BROWSER_TARGET_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 13 matching lines...) Expand all Loading... |
24 namespace net { | 24 namespace net { |
25 class HttpServer; | 25 class HttpServer; |
26 } // namespace net | 26 } // namespace net |
27 | 27 |
28 namespace content { | 28 namespace content { |
29 | 29 |
30 // This class handles the "Browser" target for remote debugging. | 30 // This class handles the "Browser" target for remote debugging. |
31 class DevToolsBrowserTarget | 31 class DevToolsBrowserTarget |
32 : public base::RefCountedThreadSafe<DevToolsBrowserTarget> { | 32 : public base::RefCountedThreadSafe<DevToolsBrowserTarget> { |
33 public: | 33 public: |
34 DevToolsBrowserTarget(net::HttpServer* server, int connection_id); | 34 DevToolsBrowserTarget(base::WeakPtr<net::HttpServer> server, |
| 35 int connection_id); |
35 | 36 |
36 int connection_id() const { return connection_id_; } | 37 int connection_id() const { return connection_id_; } |
37 | 38 |
38 // Takes ownership of |handler|. | 39 // Takes ownership of |handler|. |
39 void RegisterDomainHandler(const std::string& domain, | 40 void RegisterDomainHandler(const std::string& domain, |
40 DevToolsProtocol::Handler* handler, | 41 DevToolsProtocol::Handler* handler, |
41 bool handle_on_ui_thread); | 42 bool handle_on_ui_thread); |
42 | 43 |
43 void HandleMessage(const std::string& data); | 44 void HandleMessage(const std::string& data); |
44 | 45 |
45 void Detach(); | 46 void Detach(); |
46 | 47 |
47 private: | 48 private: |
48 friend class base::RefCountedThreadSafe<DevToolsBrowserTarget>; | 49 friend class base::RefCountedThreadSafe<DevToolsBrowserTarget>; |
49 ~DevToolsBrowserTarget(); | 50 ~DevToolsBrowserTarget(); |
50 | 51 |
51 void HandleCommandOnUIThread( | 52 void HandleCommandOnUIThread( |
52 DevToolsProtocol::Handler*, | 53 DevToolsProtocol::Handler*, |
53 scoped_refptr<DevToolsProtocol::Command> command); | 54 scoped_refptr<DevToolsProtocol::Command> command); |
54 | 55 |
55 void DeleteHandlersOnUIThread( | 56 void DeleteHandlersOnUIThread( |
56 std::vector<DevToolsProtocol::Handler*> handlers); | 57 std::vector<DevToolsProtocol::Handler*> handlers); |
57 | 58 |
58 void Respond(const std::string& message); | 59 void Respond(const std::string& message); |
59 void RespondFromUIThread(const std::string& message); | 60 void RespondFromUIThread(const std::string& message); |
60 | 61 |
61 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 62 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
62 net::HttpServer* http_server_; | 63 base::WeakPtr<net::HttpServer> http_server_; |
63 const int connection_id_; | 64 const int connection_id_; |
64 | 65 |
65 typedef std::map<std::string, DevToolsProtocol::Handler*> DomainHandlerMap; | 66 typedef std::map<std::string, DevToolsProtocol::Handler*> DomainHandlerMap; |
66 DomainHandlerMap handlers_; | 67 DomainHandlerMap handlers_; |
67 std::set<std::string> handle_on_ui_thread_; | 68 std::set<std::string> handle_on_ui_thread_; |
68 base::WeakPtrFactory<DevToolsBrowserTarget> weak_factory_; | 69 base::WeakPtrFactory<DevToolsBrowserTarget> weak_factory_; |
69 | 70 |
70 DISALLOW_COPY_AND_ASSIGN(DevToolsBrowserTarget); | 71 DISALLOW_COPY_AND_ASSIGN(DevToolsBrowserTarget); |
71 }; | 72 }; |
72 | 73 |
73 } // namespace content | 74 } // namespace content |
74 | 75 |
75 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BROWSER_TARGET_H_ | 76 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BROWSER_TARGET_H_ |
OLD | NEW |