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

Side by Side Diff: chrome/browser/devtools/devtools_protocol.cc

Issue 2808923002: Revert of add a new set of commands to resize and position windows (patchset #35 id:680001 of https… (Closed)
Patch Set: Created 3 years, 8 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
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 #include "chrome/browser/devtools/devtools_protocol.h" 5 #include "chrome/browser/devtools/devtools_protocol.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 13
14 namespace { 14 namespace {
15 15
16 const char kErrorCodeParam[] = "code"; 16 const char kErrorCodeParam[] = "code";
17 const char kErrorParam[] = "error"; 17 const char kErrorParam[] = "error";
18 const char kErrorMessageParam[] = "message"; 18 const char kErrorMessageParam[] = "message";
19 const char kIdParam[] = "id"; 19 const char kIdParam[] = "id";
20 const char kMethodParam[] = "method"; 20 const char kMethodParam[] = "method";
21 const char kParamsParam[] = "params"; 21 const char kParamsParam[] = "params";
22 const char kResultParam[] = "result"; 22 const char kResultParam[] = "result";
23 23
24 // JSON RPC 2.0 spec: http://www.jsonrpc.org/specification#error_object 24 // JSON RPC 2.0 spec: http://www.jsonrpc.org/specification#error_object
25 enum Error { kErrorInvalidParams = -32602, kErrorServerError = -32000 }; 25 enum Error { kErrorInvalidParams = -32602 };
26 26
27 } // namespace 27 } // namespace
28 28
29 // static 29 // static
30 std::string DevToolsProtocol::SerializeCommand( 30 std::string DevToolsProtocol::SerializeCommand(
31 int command_id, 31 int command_id,
32 const std::string& method, 32 const std::string& method,
33 std::unique_ptr<base::DictionaryValue> params) { 33 std::unique_ptr<base::DictionaryValue> params) {
34 base::DictionaryValue command; 34 base::DictionaryValue command;
35 command.SetInteger(kIdParam, command_id); 35 command.SetInteger(kIdParam, command_id);
(...skipping 15 matching lines...) Expand all
51 auto error_object = base::MakeUnique<base::DictionaryValue>(); 51 auto error_object = base::MakeUnique<base::DictionaryValue>();
52 error_object->SetInteger(kErrorCodeParam, kErrorInvalidParams); 52 error_object->SetInteger(kErrorCodeParam, kErrorInvalidParams);
53 error_object->SetString(kErrorMessageParam, 53 error_object->SetString(kErrorMessageParam,
54 base::StringPrintf("Missing or invalid '%s' parameter", param.c_str())); 54 base::StringPrintf("Missing or invalid '%s' parameter", param.c_str()));
55 response->Set(kErrorParam, std::move(error_object)); 55 response->Set(kErrorParam, std::move(error_object));
56 56
57 return response; 57 return response;
58 } 58 }
59 59
60 // static 60 // static
61 std::unique_ptr<base::DictionaryValue> DevToolsProtocol::CreateErrorResponse(
62 int command_id,
63 const std::string& error_message) {
64 std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue());
65 response->SetInteger(kIdParam, command_id);
66 base::DictionaryValue* error_object = new base::DictionaryValue();
67 response->Set(kErrorParam, error_object);
68 error_object->SetInteger(kErrorCodeParam, kErrorServerError);
69 error_object->SetString(kErrorMessageParam, error_message);
70 return response;
71 }
72
73 // static
74 std::unique_ptr<base::DictionaryValue> DevToolsProtocol::CreateSuccessResponse( 61 std::unique_ptr<base::DictionaryValue> DevToolsProtocol::CreateSuccessResponse(
75 int command_id, 62 int command_id,
76 std::unique_ptr<base::DictionaryValue> result) { 63 std::unique_ptr<base::DictionaryValue> result) {
77 std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue()); 64 std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue());
78 response->SetInteger(kIdParam, command_id); 65 response->SetInteger(kIdParam, command_id);
79 response->Set(kResultParam, result 66 response->Set(kResultParam, result
80 ? std::move(result) 67 ? std::move(result)
81 : base::MakeUnique<base::DictionaryValue>()); 68 : base::MakeUnique<base::DictionaryValue>());
82 69
83 return response; 70 return response;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 126
140 if (!dict->GetInteger(kIdParam, command_id)) 127 if (!dict->GetInteger(kIdParam, command_id))
141 return false; 128 return false;
142 129
143 *error_code = 0; 130 *error_code = 0;
144 base::DictionaryValue* error_dict = nullptr; 131 base::DictionaryValue* error_dict = nullptr;
145 if (dict->GetDictionary(kErrorParam, &error_dict)) 132 if (dict->GetDictionary(kErrorParam, &error_dict))
146 error_dict->GetInteger(kErrorCodeParam, error_code); 133 error_dict->GetInteger(kErrorCodeParam, error_code);
147 return true; 134 return true;
148 } 135 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_protocol.h ('k') | chrome/browser/devtools/devtools_sanity_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698