OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_BROWSER_TARGET_H_ | |
6 #define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_BROWSER_TARGET_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "base/basictypes.h" | |
12 | |
13 namespace base { | |
14 | |
15 class DictionaryValue; | |
16 class Value; | |
17 | |
18 } // namespace base | |
19 | |
20 namespace content { | |
21 | |
22 // This class handles the "Browser" target for remote debugging. | |
23 class DevToolsBrowserTarget { | |
24 public: | |
25 class Handler { | |
26 public: | |
27 virtual ~Handler() {} | |
28 | |
29 // Returns the domain name for this handler. | |
30 virtual std::string Domain() = 0; | |
31 | |
32 // |return_value| and |error_message_out| ownership is transferred to the | |
33 // caller. | |
34 virtual base::Value* OnProtocolCommand( | |
35 const std::string& method, | |
36 const base::DictionaryValue* params, | |
37 base::Value** error_message_out) = 0; | |
38 }; | |
39 | |
40 explicit DevToolsBrowserTarget(int connection_id); | |
41 ~DevToolsBrowserTarget(); | |
42 | |
43 int connection_id() const { return connection_id_; } | |
44 | |
45 // Takes ownership of |handler|. | |
46 void RegisterHandler(Handler* handler); | |
47 | |
48 std::string HandleMessage(const std::string& data); | |
49 | |
50 private: | |
51 const int connection_id_; | |
52 | |
53 typedef std::map<std::string, Handler*> HandlersMap; | |
54 HandlersMap handlers_; | |
55 | |
56 // Takes ownership of |error_object|. | |
57 std::string SerializeErrorResponse(int request_id, base::Value* error_object); | |
58 | |
59 base::Value* CreateErrorObject(int error_code, const std::string& message); | |
60 | |
61 std::string SerializeResponse(int request_id, base::Value* response); | |
62 | |
63 DISALLOW_COPY_AND_ASSIGN(DevToolsBrowserTarget); | |
64 }; | |
65 | |
66 } // namespace content | |
67 | |
68 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_BROWSER_TARGET_H_ | |
OLD | NEW |