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

Side by Side Diff: webkit/glue/devtools/devtools_rpc.cc

Issue 173480: DevTools: Remove base/values dependency from devtools. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/devtools/devtools_rpc.h ('k') | webkit/glue/devtools/devtools_rpc_js.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 // TODO(pfeldman): Remove these once JSON is available in
6 // WebCore namespace.
7
8 #include "PlatformString.h"
9 #undef LOG
10
11 #include "base/json_reader.h"
12 #include "base/json_writer.h"
13 #include "base/values.h"
14 #include "webkit/glue/devtools/devtools_rpc.h"
15 #include "webkit/glue/glue_util.h"
16
17 DevToolsRpc::DevToolsRpc(Delegate* delegate) : delegate_(delegate) {
18 }
19
20 DevToolsRpc::~DevToolsRpc() {
21 }
22
23 void DevToolsRpc::SendValueMessage(const std::string& class_name,
24 const std::string& method_name,
25 const Value& value) {
26 delegate_->SendRpcMessage(class_name, method_name, Serialize(value));
27 }
28
29 // static
30 Value* DevToolsRpc::ParseMessage(const std::string& raw_msg) {
31 return JSONReader::Read(raw_msg, false);
32 }
33
34 // static
35 std::string DevToolsRpc::Serialize(const Value& value) {
36 std::string json;
37 // TODO(pfeldman): find out why faster way in no longer working.
38 // JSONWriter::WriteWithOptionalEscape(&value, false, false, &json);
39 JSONWriter::Write(&value, false, &json);
40 return json;
41 }
42
43 // static
44 void DevToolsRpc::GetListValue(
45 const ListValue& message,
46 int index,
47 bool* value) {
48 message.GetBoolean(index, value);
49 }
50
51 // static
52 void DevToolsRpc::GetListValue(
53 const ListValue& message,
54 int index,
55 int* value) {
56 message.GetInteger(index, value);
57 }
58
59 // static
60 void DevToolsRpc::GetListValue(
61 const ListValue& message,
62 int index,
63 String* value) {
64 std::string tmp;
65 message.GetString(index, &tmp);
66 *value = webkit_glue::StdStringToString(tmp);
67 }
68
69 // static
70 void DevToolsRpc::GetListValue(
71 const ListValue& message,
72 int index,
73 std::string* value) {
74 message.GetString(index, value);
75 }
76
77 // static
78 void DevToolsRpc::GetListValue(
79 const ListValue& message,
80 int index,
81 Value** value) {
82 message.Get(index, value);
83 }
84
85 // static
86 Value* DevToolsRpc::CreateValue(const String* value) {
87 return Value::CreateStringValue(
88 webkit_glue::StringToStdString(*value));
89 }
90
91 // static
92 Value* DevToolsRpc::CreateValue(const std::string* value) {
93 return Value::CreateStringValue(*value);
94 }
95
96 // static
97 Value* DevToolsRpc::CreateValue(int* value) {
98 return Value::CreateIntegerValue(*value);
99 }
100
101 // static
102 Value* DevToolsRpc::CreateValue(bool* value) {
103 return Value::CreateBooleanValue(*value);
104 }
105
106 // static
107 Value* DevToolsRpc::CreateValue(const Value* value) {
108 return value->DeepCopy();
109 }
OLDNEW
« no previous file with comments | « webkit/glue/devtools/devtools_rpc.h ('k') | webkit/glue/devtools/devtools_rpc_js.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698