OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ |
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 | 13 |
14 // Utility class for processing DevTools remote debugging messages. | 14 // Utility class for processing DevTools remote debugging messages. |
15 // This is a stripped down clone of content::DevTools which is not accessible | 15 // This is a stripped down clone of content::DevTools which is not accessible |
16 // from chrome component (see content/browser/devtools/devtools_protocol.*). | 16 // from chrome component (see content/browser/devtools/devtools_protocol.*). |
17 class DevToolsProtocol { | 17 class DevToolsProtocol { |
18 public: | 18 public: |
19 class Response; | 19 class Response; |
20 | 20 |
21 class Message { | 21 class Message { |
22 public: | 22 public: |
23 virtual ~Message(); | 23 virtual ~Message(); |
24 | 24 |
25 std::string method() { return method_; } | 25 std::string method() { return method_; } |
26 base::DictionaryValue* params() { return params_.get(); } | 26 base::DictionaryValue* params() { return params_.get(); } |
27 | 27 |
28 protected: | 28 protected: |
29 // Takes ownership of |params|. | |
30 Message(const std::string& method, base::DictionaryValue* params); | 29 Message(const std::string& method, base::DictionaryValue* params); |
31 | 30 |
32 std::string method_; | 31 std::string method_; |
33 scoped_ptr<base::DictionaryValue> params_; | 32 scoped_ptr<base::DictionaryValue> params_; |
34 | 33 |
35 private: | 34 private: |
36 DISALLOW_COPY_AND_ASSIGN(Message); | 35 DISALLOW_COPY_AND_ASSIGN(Message); |
37 }; | 36 }; |
38 | 37 |
39 class Command : public Message { | 38 class Command : public Message { |
40 public: | 39 public: |
41 // Takes ownership of |params|. | |
42 Command(int id, const std::string& method, base::DictionaryValue* params); | 40 Command(int id, const std::string& method, base::DictionaryValue* params); |
43 virtual ~Command(); | 41 virtual ~Command(); |
44 | 42 |
45 int id() { return id_; } | 43 int id() { return id_; } |
46 std::string Serialize(); | 44 std::string Serialize(); |
47 | 45 |
48 // Creates success response. Takes ownership of |result|. | 46 // Creates success response. Takes ownership of |result|. |
49 scoped_ptr<Response> SuccessResponse(base::DictionaryValue* result); | 47 scoped_ptr<Response> SuccessResponse(base::DictionaryValue* result); |
50 | 48 |
51 // Creates error response. | 49 // Creates error response. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // Result ownership is passed to the caller. | 101 // Result ownership is passed to the caller. |
104 static Response* ParseResponse(const std::string& json); | 102 static Response* ParseResponse(const std::string& json); |
105 | 103 |
106 private: | 104 private: |
107 | 105 |
108 DevToolsProtocol() {} | 106 DevToolsProtocol() {} |
109 ~DevToolsProtocol() {} | 107 ~DevToolsProtocol() {} |
110 }; | 108 }; |
111 | 109 |
112 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ | 110 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ |
OLD | NEW |