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

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

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/chrome_common.gypi ('k') | chrome/common/indexed_db_param_traits.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_COMMON_INDEXED_DB_PARAM_TRAITS_H_ 5 #ifndef CHROME_COMMON_INDEXED_DB_PARAM_TRAITS_H_
6 #define CHROME_COMMON_INDEXED_DB_PARAM_TRAITS_H_ 6 #define CHROME_COMMON_INDEXED_DB_PARAM_TRAITS_H_
7 #pragma once 7 #pragma once
8 8
9 #include "chrome/common/indexed_db_key.h" 9 #include "ipc/ipc_message.h"
10 #include "chrome/common/serialized_script_value.h"
11 #include "ipc/ipc_param_traits.h" 10 #include "ipc/ipc_param_traits.h"
12 11
12 class IndexedDBKey;
13 class SerializedScriptValue;
14
13 namespace IPC { 15 namespace IPC {
14 16
15 // These datatypes are used by utility_messages.h and render_messages.h. 17 // These datatypes are used by utility_messages.h and render_messages.h.
16 // Unfortunately we can't move it to common: MSVC linker complains about 18 // Unfortunately we can't move it to common: MSVC linker complains about
17 // WebKit datatypes that are not linked on npchrome_frame (even though it's 19 // WebKit datatypes that are not linked on npchrome_frame (even though it's
18 // never actually used by that target). 20 // never actually used by that target).
19 21
20 template <> 22 template <>
21 struct ParamTraits<SerializedScriptValue> { 23 struct ParamTraits<SerializedScriptValue> {
22 typedef SerializedScriptValue param_type; 24 typedef SerializedScriptValue param_type;
23 static void Write(Message* m, const param_type& p) { 25 static void Write(Message* m, const param_type& p);
24 WriteParam(m, p.is_null()); 26 static bool Read(const Message* m, void** iter, param_type* r);
25 WriteParam(m, p.is_invalid()); 27 static void Log(const param_type& p, std::string* l);
26 WriteParam(m, p.data());
27 }
28 static bool Read(const Message* m, void** iter, param_type* r) {
29 bool is_null;
30 bool is_invalid;
31 string16 data;
32 bool ok =
33 ReadParam(m, iter, &is_null) &&
34 ReadParam(m, iter, &is_invalid) &&
35 ReadParam(m, iter, &data);
36 if (!ok)
37 return false;
38 r->set_is_null(is_null);
39 r->set_is_invalid(is_invalid);
40 r->set_data(data);
41 return true;
42 }
43 static void Log(const param_type& p, std::string* l) {
44 l->append("<SerializedScriptValue>(");
45 LogParam(p.is_null(), l);
46 l->append(", ");
47 LogParam(p.is_invalid(), l);
48 l->append(", ");
49 LogParam(p.data(), l);
50 l->append(")");
51 }
52 }; 28 };
53 29
54 template <> 30 template <>
55 struct ParamTraits<IndexedDBKey> { 31 struct ParamTraits<IndexedDBKey> {
56 typedef IndexedDBKey param_type; 32 typedef IndexedDBKey param_type;
57 static void Write(Message* m, const param_type& p) { 33 static void Write(Message* m, const param_type& p);
58 WriteParam(m, int(p.type())); 34 static bool Read(const Message* m, void** iter, param_type* r);
59 // TODO(jorlow): Technically, we only need to pack the type being used. 35 static void Log(const param_type& p, std::string* l);
60 WriteParam(m, p.string());
61 WriteParam(m, p.number());
62 }
63 static bool Read(const Message* m, void** iter, param_type* r) {
64 int type;
65 string16 string;
66 int32 number;
67 bool ok =
68 ReadParam(m, iter, &type) &&
69 ReadParam(m, iter, &string) &&
70 ReadParam(m, iter, &number);
71 if (!ok)
72 return false;
73 switch (type) {
74 case WebKit::WebIDBKey::NullType:
75 r->SetNull();
76 return true;
77 case WebKit::WebIDBKey::StringType:
78 r->Set(string);
79 return true;
80 case WebKit::WebIDBKey::NumberType:
81 r->Set(number);
82 return true;
83 case WebKit::WebIDBKey::InvalidType:
84 r->SetInvalid();
85 return true;
86 }
87 NOTREACHED();
88 return false;
89 }
90 static void Log(const param_type& p, std::string* l) {
91 l->append("<IndexedDBKey>(");
92 LogParam(int(p.type()), l);
93 l->append(", ");
94 LogParam(p.string(), l);
95 l->append(", ");
96 LogParam(p.number(), l);
97 l->append(")");
98 }
99 }; 36 };
100 37
101 } // namespace IPC 38 } // namespace IPC
102 39
103 #endif // CHROME_COMMON_INDEXED_DB_PARAM_TRAITS_H_ 40 #endif // CHROME_COMMON_INDEXED_DB_PARAM_TRAITS_H_
OLDNEW
« no previous file with comments | « chrome/chrome_common.gypi ('k') | chrome/common/indexed_db_param_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698