Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: content/browser/devtools/protocol/devtools_protocol_client.cc

Issue 508973003: DevTools: Protocol handler generator for content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow command->params()==NULL Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "content/browser/devtools/protocol/devtools_protocol_client.h"
6
7 namespace content {
8
9 DevToolsProtocolClient::DevToolsProtocolClient(
10 const EventCallback& event_callback,
11 const ResponseCallback& response_callback)
12 : event_callback_(event_callback),
13 response_callback_(response_callback) {
14 }
15
16 DevToolsProtocolClient::~DevToolsProtocolClient() {
17 }
18
19 void DevToolsProtocolClient::SendNotification(const std::string& method,
20 base::DictionaryValue* params) {
21 event_callback_.Run(method, params);
22 }
23
24 void DevToolsProtocolClient::SendAsyncResponse(
25 scoped_refptr<DevToolsProtocol::Response> response) {
26 response_callback_.Run(response);
27 }
28
29 void DevToolsProtocolClient::SendInvalidParamsResponse(
30 scoped_refptr<DevToolsProtocol::Command> command,
31 const std::string& message) {
32 SendAsyncResponse(command->InvalidParamResponse(message));
33 }
34
35 void DevToolsProtocolClient::SendInternalErrorResponse(
36 scoped_refptr<DevToolsProtocol::Command> command,
37 const std::string& message) {
38 SendAsyncResponse(command->InternalErrorResponse(message));
39 }
40
41 void DevToolsProtocolClient::SendServerErrorResponse(
42 scoped_refptr<DevToolsProtocol::Command> command,
43 const std::string& message) {
44 SendAsyncResponse(command->ServerErrorResponse(message));
45 }
46
47 typedef DevToolsProtocolClient::Response Response;
48
49 Response Response::FallThrough() {
50 Response response;
51 response.status_ = ResponseStatus::RESPONSE_STATUS_FALLTHROUGH;
52 return response;
53 }
54
55 Response Response::OK() {
56 Response response;
57 response.status_ = ResponseStatus::RESPONSE_STATUS_OK;
58 return response;
59 }
60
61 Response Response::InvalidParams(const std::string& message) {
62 Response response;
63 response.status_ = ResponseStatus::RESPONSE_STATUS_INVALID_PARAMS;
64 response.message_ = message;
65 return response;
66 }
67
68 Response Response::InternalError(const std::string& message) {
69 Response response;
70 response.status_ = ResponseStatus::RESPONSE_STATUS_INTERNAL_ERROR;
71 response.message_ = message;
72 return response;
73 }
74
75 Response Response::ServerError(const std::string& message) {
76 Response response;
77 response.status_ = ResponseStatus::RESPONSE_STATUS_SERVER_ERROR;
78 response.message_ = message;
79 return response;
80 }
81
82 DevToolsProtocolClient::ResponseStatus Response::status() const {
83 return status_;
84 }
85
86 const std::string& Response::message() const {
87 return message_;
88 }
89
90 Response::Response() {
91 }
92
93 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698