1 // Copyright 2014 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_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_
8 #include "base/callback.h"
9 #include "base/values.h"
13 using DevToolsCommandId
= int;
14 class DevToolsProtocolHandler
;
15 class DevToolsProtocolDispatcher
;
17 class DevToolsProtocolClient
{
19 typedef base::Callback
<void(const std::string
& message
)>
21 static const DevToolsCommandId kNoId
;
25 static Response
FallThrough();
27 static Response
InvalidParams(const std::string
& param
);
28 static Response
InternalError(const std::string
& message
);
29 static Response
ServerError(const std::string
& message
);
32 const std::string
& message() const;
34 bool IsFallThrough() const;
37 friend class DevToolsProtocolHandler
;
39 explicit Response(int status
);
40 Response(int status
, const std::string
& message
);
46 bool SendError(DevToolsCommandId command_id
,
47 const Response
& response
);
49 // Sends message to client, the caller is presumed to properly
50 // format the message. Do not use unless you must.
51 void SendRawMessage(const std::string
& message
);
53 explicit DevToolsProtocolClient(
54 const RawMessageCallback
& raw_message_callback
);
55 virtual ~DevToolsProtocolClient();
58 void SendSuccess(DevToolsCommandId command_id
,
59 scoped_ptr
<base::DictionaryValue
> params
);
60 void SendNotification(const std::string
& method
,
61 scoped_ptr
<base::DictionaryValue
> params
);
64 friend class DevToolsProtocolDispatcher
;
66 void SendMessage(const base::DictionaryValue
& message
);
68 RawMessageCallback raw_message_callback_
;
69 DISALLOW_COPY_AND_ASSIGN(DevToolsProtocolClient
);
72 } // namespace content
74 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_