Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / browser / devtools / devtools_browser_target.h
blob0dda59b2ad4fdc82ea879785dc36a38166162dbe
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BROWSER_TARGET_H_
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BROWSER_TARGET_H_
8 #include <map>
9 #include <set>
10 #include <string>
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h"
16 #include "content/browser/devtools/devtools_protocol.h"
18 namespace base {
19 class DictionaryValue;
20 class MessageLoopProxy;
21 class Value;
22 } // namespace base
24 namespace net {
25 class HttpServer;
26 } // namespace net
28 namespace content {
30 // This class handles the "Browser" target for remote debugging.
31 class DevToolsBrowserTarget
32 : public base::RefCountedThreadSafe<DevToolsBrowserTarget> {
33 public:
34 DevToolsBrowserTarget(net::HttpServer* server, int connection_id);
36 int connection_id() const { return connection_id_; }
38 // Takes ownership of |handler|.
39 void RegisterDomainHandler(const std::string& domain,
40 DevToolsProtocol::Handler* handler,
41 bool handle_on_ui_thread);
43 void HandleMessage(const std::string& data);
45 void Detach();
47 private:
48 friend class base::RefCountedThreadSafe<DevToolsBrowserTarget>;
49 ~DevToolsBrowserTarget();
51 void HandleCommandOnUIThread(
52 DevToolsProtocol::Handler*,
53 scoped_refptr<DevToolsProtocol::Command> command);
55 void DeleteHandlersOnUIThread(
56 std::vector<DevToolsProtocol::Handler*> handlers);
58 void Respond(const std::string& message);
59 void RespondFromUIThread(const std::string& message);
61 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
62 net::HttpServer* http_server_;
63 const int connection_id_;
65 typedef std::map<std::string, DevToolsProtocol::Handler*> DomainHandlerMap;
66 DomainHandlerMap handlers_;
67 std::set<std::string> handle_on_ui_thread_;
68 base::WeakPtrFactory<DevToolsBrowserTarget> weak_factory_;
70 DISALLOW_COPY_AND_ASSIGN(DevToolsBrowserTarget);
73 } // namespace content
75 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BROWSER_TARGET_H_