blob: 9a01eee531373b65e21b95d311a9e20905a2a55a [file] [log] [blame]
Ben Murdochbb1529c2013-08-08 10:24:53 +01001// 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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_
6#define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_
7
8#include <string>
9
10#include "base/basictypes.h"
11#include "base/compiler_specific.h"
12#include "base/values.h"
13
14// Utility class for processing DevTools remote debugging messages.
15// This is a stripped down clone of content::DevTools which is not accessible
16// from chrome component (see content/browser/devtools/devtools_protocol.*).
17class DevToolsProtocol {
18 public:
19 class Message {
20 public:
21 virtual ~Message();
22
23 std::string method() { return method_; }
24 base::DictionaryValue* params() { return params_.get(); }
25
26 protected:
27 // Takes ownership of |params|.
28 Message(const std::string& method, base::DictionaryValue* params);
29
30 std::string method_;
31 scoped_ptr<base::DictionaryValue> params_;
32
33 private:
34 DISALLOW_COPY_AND_ASSIGN(Message);
35 };
36
37 class Command : public Message {
38 public:
39 // Takes ownership of |params|.
40 Command(int id, const std::string& method, base::DictionaryValue* params);
41 virtual ~Command();
42
43 int id() { return id_; }
44 std::string Serialize();
45
46 private:
47 int id_;
48
49 DISALLOW_COPY_AND_ASSIGN(Command);
50 };
51
52 class Notification : public Message {
53 public:
54 virtual ~Notification();
55
56 private:
57 friend class DevToolsProtocol;
58
59 // Takes ownership of |params|.
60 Notification(const std::string& method,
61 base::DictionaryValue* params);
62
63 DISALLOW_COPY_AND_ASSIGN(Notification);
64 };
65
66 static Notification* ParseNotification(const std::string& json);
67
68 private:
69
70 DevToolsProtocol() {}
71 ~DevToolsProtocol() {}
72};
73
74#endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_