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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 scoped_ptr<base::DictionaryValue> params_; | 31 scoped_ptr<base::DictionaryValue> params_; |
32 | 32 |
33 private: | 33 private: |
34 DISALLOW_COPY_AND_ASSIGN(Message); | 34 DISALLOW_COPY_AND_ASSIGN(Message); |
35 }; | 35 }; |
36 | 36 |
37 class Command : public Message { | 37 class Command : public Message { |
38 public: | 38 public: |
39 // Takes ownership of |params|. | 39 // Takes ownership of |params|. |
40 Command(int id, const std::string& method, base::DictionaryValue* params); | 40 Command(int id, const std::string& method, base::DictionaryValue* params); |
41 virtual ~Command(); | 41 virtual ~Command(); |
42 | 42 |
43 int id() { return id_; } | 43 int id() { return id_; } |
44 std::string Serialize(); | 44 std::string Serialize(); |
45 | 45 |
46 private: | 46 private: |
47 int id_; | 47 int id_; |
48 | 48 |
49 DISALLOW_COPY_AND_ASSIGN(Command); | 49 DISALLOW_COPY_AND_ASSIGN(Command); |
50 }; | 50 }; |
51 | 51 |
| 52 class Response { |
| 53 public: |
| 54 virtual ~Response(); |
| 55 |
| 56 int id() { return id_; } |
| 57 int error_code() { return error_code_; } |
| 58 |
| 59 private: |
| 60 friend class DevToolsProtocol; |
| 61 |
| 62 Response(int id, int error_code); |
| 63 int id_; |
| 64 int error_code_; |
| 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(Response); |
| 67 }; |
| 68 |
52 class Notification : public Message { | 69 class Notification : public Message { |
53 public: | 70 public: |
54 virtual ~Notification(); | 71 virtual ~Notification(); |
55 | 72 |
56 private: | 73 private: |
57 friend class DevToolsProtocol; | 74 friend class DevToolsProtocol; |
58 | 75 |
59 // Takes ownership of |params|. | 76 // Takes ownership of |params|. |
60 Notification(const std::string& method, | 77 Notification(const std::string& method, |
61 base::DictionaryValue* params); | 78 base::DictionaryValue* params); |
62 | 79 |
63 DISALLOW_COPY_AND_ASSIGN(Notification); | 80 DISALLOW_COPY_AND_ASSIGN(Notification); |
64 }; | 81 }; |
65 | 82 |
| 83 // Result ownership is passed to the caller. |
66 static Notification* ParseNotification(const std::string& json); | 84 static Notification* ParseNotification(const std::string& json); |
67 | 85 |
| 86 // Result ownership is passed to the caller. |
| 87 static Response* ParseResponse(const std::string& json); |
| 88 |
68 private: | 89 private: |
69 | 90 |
70 DevToolsProtocol() {} | 91 DevToolsProtocol() {} |
71 ~DevToolsProtocol() {} | 92 ~DevToolsProtocol() {} |
72 }; | 93 }; |
73 | 94 |
74 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ | 95 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ |
OLD | NEW |