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

Side by Side Diff: chrome/common/indexed_db_param_traits.cc

Issue 3297011: Removes indexed_db_param_traits.h depedencies on WebKit headers. (Closed)
Patch Set: Comments Created 10 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
« no previous file with comments | « chrome/common/indexed_db_param_traits.h ('k') | chrome/common/render_messages.cc » ('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) 2010 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 "chrome/common/indexed_db_param_traits.h"
6
7 #include "chrome/common/indexed_db_key.h"
8 #include "chrome/common/serialized_script_value.h"
9 #include "ipc/ipc_message_utils.h"
10
11 namespace IPC {
12
13 void ParamTraits<SerializedScriptValue>::Write(Message* m,
14 const param_type& p) {
15 WriteParam(m, p.is_null());
16 WriteParam(m, p.is_invalid());
17 WriteParam(m, p.data());
18 }
19
20 bool ParamTraits<SerializedScriptValue>::Read(const Message* m,
21 void** iter,
22 param_type* r) {
23 bool is_null;
24 bool is_invalid;
25 string16 data;
26 bool ok =
27 ReadParam(m, iter, &is_null) &&
28 ReadParam(m, iter, &is_invalid) &&
29 ReadParam(m, iter, &data);
30 if (!ok)
31 return false;
32 r->set_is_null(is_null);
33 r->set_is_invalid(is_invalid);
34 r->set_data(data);
35 return true;
36 }
37
38 void ParamTraits<SerializedScriptValue>::Log(const param_type& p,
39 std::string* l) {
40 l->append("<SerializedScriptValue>(");
41 LogParam(p.is_null(), l);
42 l->append(", ");
43 LogParam(p.is_invalid(), l);
44 l->append(", ");
45 LogParam(p.data(), l);
46 l->append(")");
47 }
48
49 void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) {
50 WriteParam(m, int(p.type()));
51 // TODO(jorlow): Technically, we only need to pack the type being used.
52 WriteParam(m, p.string());
53 WriteParam(m, p.number());
54 }
55
56 bool ParamTraits<IndexedDBKey>::Read(const Message* m,
57 void** iter,
58 param_type* r) {
59 int type;
60 string16 string;
61 int32 number;
62 bool ok =
63 ReadParam(m, iter, &type) &&
64 ReadParam(m, iter, &string) &&
65 ReadParam(m, iter, &number);
66 if (!ok)
67 return false;
68 switch (type) {
69 case WebKit::WebIDBKey::NullType:
70 r->SetNull();
71 return true;
72 case WebKit::WebIDBKey::StringType:
73 r->Set(string);
74 return true;
75 case WebKit::WebIDBKey::NumberType:
76 r->Set(number);
77 return true;
78 case WebKit::WebIDBKey::InvalidType:
79 r->SetInvalid();
80 return true;
81 }
82 NOTREACHED();
83 return false;
84 }
85
86 void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) {
87 l->append("<IndexedDBKey>(");
88 LogParam(int(p.type()), l);
89 l->append(", ");
90 LogParam(p.string(), l);
91 l->append(", ");
92 LogParam(p.number(), l);
93 l->append(")");
94 }
95
96 } // namespace IPC
OLDNEW
« no previous file with comments | « chrome/common/indexed_db_param_traits.h ('k') | chrome/common/render_messages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698