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: content/common/indexed_db/indexed_db_param_traits.cc

Issue 19442002: Convert to new WebIDBTypes enums and accessors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix content/common/DEPS Created 7 years, 5 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 | « content/common/indexed_db/indexed_db_key_unittest.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/indexed_db/indexed_db_param_traits.h" 5 #include "content/common/indexed_db/indexed_db_param_traits.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 #include "content/common/indexed_db/indexed_db_key.h" 9 #include "content/common/indexed_db/indexed_db_key.h"
10 #include "content/common/indexed_db/indexed_db_key_path.h" 10 #include "content/common/indexed_db/indexed_db_key_path.h"
11 #include "content/common/indexed_db/indexed_db_key_range.h" 11 #include "content/common/indexed_db/indexed_db_key_range.h"
12 #include "ipc/ipc_message_utils.h" 12 #include "ipc/ipc_message_utils.h"
13 13
14 using content::IndexedDBKey; 14 using content::IndexedDBKey;
15 using content::IndexedDBKeyPath; 15 using content::IndexedDBKeyPath;
16 using content::IndexedDBKeyRange; 16 using content::IndexedDBKeyRange;
17 17
18 using WebKit::WebIDBKey; 18 using WebKit::WebIDBKeyPathTypeArray;
19 using WebKit::WebIDBKeyPath; 19 using WebKit::WebIDBKeyPathTypeNull;
20 using WebKit::WebIDBKeyPathTypeString;
21 using WebKit::WebIDBKeyType;
22 using WebKit::WebIDBKeyTypeArray;
23 using WebKit::WebIDBKeyTypeDate;
24 using WebKit::WebIDBKeyTypeInvalid;
25 using WebKit::WebIDBKeyTypeMin;
26 using WebKit::WebIDBKeyTypeNull;
27 using WebKit::WebIDBKeyTypeNumber;
28 using WebKit::WebIDBKeyTypeString;
20 29
21 namespace IPC { 30 namespace IPC {
22 31
23 void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) { 32 void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) {
24 WriteParam(m, static_cast<int>(p.type())); 33 WriteParam(m, static_cast<int>(p.type()));
25 switch (p.type()) { 34 switch (p.type()) {
26 case WebIDBKey::ArrayType: 35 case WebIDBKeyTypeArray:
27 WriteParam(m, p.array()); 36 WriteParam(m, p.array());
28 return; 37 return;
29 case WebIDBKey::StringType: 38 case WebIDBKeyTypeString:
30 WriteParam(m, p.string()); 39 WriteParam(m, p.string());
31 return; 40 return;
32 case WebIDBKey::DateType: 41 case WebIDBKeyTypeDate:
33 WriteParam(m, p.date()); 42 WriteParam(m, p.date());
34 return; 43 return;
35 case WebIDBKey::NumberType: 44 case WebIDBKeyTypeNumber:
36 WriteParam(m, p.number()); 45 WriteParam(m, p.number());
37 return; 46 return;
38 case WebIDBKey::InvalidType: 47 case WebIDBKeyTypeInvalid:
39 case WebIDBKey::NullType: 48 case WebIDBKeyTypeNull:
40 return; 49 return;
41 case WebIDBKey::MinType: 50 case WebIDBKeyTypeMin:
42 NOTREACHED(); 51 NOTREACHED();
43 return; 52 return;
44 } 53 }
45 } 54 }
46 55
47 bool ParamTraits<IndexedDBKey>::Read(const Message* m, 56 bool ParamTraits<IndexedDBKey>::Read(const Message* m,
48 PickleIterator* iter, 57 PickleIterator* iter,
49 param_type* r) { 58 param_type* r) {
50 int type; 59 int type;
51 if (!ReadParam(m, iter, &type)) 60 if (!ReadParam(m, iter, &type))
52 return false; 61 return false;
53 WebIDBKey::Type web_type = static_cast<WebIDBKey::Type>(type); 62 WebIDBKeyType web_type = static_cast<WebIDBKeyType>(type);
54 63
55 switch (web_type) { 64 switch (web_type) {
56 case WebIDBKey::ArrayType: { 65 case WebIDBKeyTypeArray: {
57 std::vector<IndexedDBKey> array; 66 std::vector<IndexedDBKey> array;
58 if (!ReadParam(m, iter, &array)) 67 if (!ReadParam(m, iter, &array))
59 return false; 68 return false;
60 *r = IndexedDBKey(array); 69 *r = IndexedDBKey(array);
61 return true; 70 return true;
62 } 71 }
63 case WebIDBKey::StringType: { 72 case WebIDBKeyTypeString: {
64 string16 string; 73 string16 string;
65 if (!ReadParam(m, iter, &string)) 74 if (!ReadParam(m, iter, &string))
66 return false; 75 return false;
67 *r = IndexedDBKey(string); 76 *r = IndexedDBKey(string);
68 return true; 77 return true;
69 } 78 }
70 case WebIDBKey::DateType: 79 case WebIDBKeyTypeDate:
71 case WebIDBKey::NumberType: { 80 case WebIDBKeyTypeNumber: {
72 double number; 81 double number;
73 if (!ReadParam(m, iter, &number)) 82 if (!ReadParam(m, iter, &number))
74 return false; 83 return false;
75 *r = IndexedDBKey(number, web_type); 84 *r = IndexedDBKey(number, web_type);
76 return true; 85 return true;
77 } 86 }
78 case WebIDBKey::InvalidType: 87 case WebIDBKeyTypeInvalid:
79 case WebIDBKey::NullType: 88 case WebIDBKeyTypeNull:
80 *r = IndexedDBKey(web_type); 89 *r = IndexedDBKey(web_type);
81 return true; 90 return true;
82 case WebIDBKey::MinType: 91 case WebIDBKeyTypeMin:
83 NOTREACHED(); 92 NOTREACHED();
84 return false; 93 return false;
85 } 94 }
86 NOTREACHED(); 95 NOTREACHED();
87 return false; 96 return false;
88 } 97 }
89 98
90 void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) { 99 void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) {
91 l->append("<IndexedDBKey>("); 100 l->append("<IndexedDBKey>(");
92 LogParam(static_cast<int>(p.type()), l); 101 LogParam(static_cast<int>(p.type()), l);
(...skipping 11 matching lines...) Expand all
104 l->append(", "); 113 l->append(", ");
105 LogParam(p.date(), l); 114 LogParam(p.date(), l);
106 l->append(", "); 115 l->append(", ");
107 LogParam(p.number(), l); 116 LogParam(p.number(), l);
108 l->append(")"); 117 l->append(")");
109 } 118 }
110 119
111 void ParamTraits<IndexedDBKeyPath>::Write(Message* m, const param_type& p) { 120 void ParamTraits<IndexedDBKeyPath>::Write(Message* m, const param_type& p) {
112 WriteParam(m, static_cast<int>(p.type())); 121 WriteParam(m, static_cast<int>(p.type()));
113 switch (p.type()) { 122 switch (p.type()) {
114 case WebIDBKeyPath::ArrayType: 123 case WebIDBKeyPathTypeArray:
115 WriteParam(m, p.array()); 124 WriteParam(m, p.array());
116 return; 125 return;
117 case WebIDBKeyPath::StringType: 126 case WebIDBKeyPathTypeString:
118 WriteParam(m, p.string()); 127 WriteParam(m, p.string());
119 return; 128 return;
120 case WebIDBKeyPath::NullType: 129 case WebIDBKeyPathTypeNull:
121 return; 130 return;
122 } 131 }
123 NOTREACHED(); 132 NOTREACHED();
124 } 133 }
125 134
126 bool ParamTraits<IndexedDBKeyPath>::Read(const Message* m, 135 bool ParamTraits<IndexedDBKeyPath>::Read(const Message* m,
127 PickleIterator* iter, 136 PickleIterator* iter,
128 param_type* r) { 137 param_type* r) {
129 int type; 138 int type;
130 if (!ReadParam(m, iter, &type)) 139 if (!ReadParam(m, iter, &type))
131 return false; 140 return false;
132 141
133 switch (type) { 142 switch (type) {
134 case WebIDBKeyPath::ArrayType: { 143 case WebIDBKeyPathTypeArray: {
135 std::vector<string16> array; 144 std::vector<string16> array;
136 if (!ReadParam(m, iter, &array)) 145 if (!ReadParam(m, iter, &array))
137 return false; 146 return false;
138 *r = IndexedDBKeyPath(array); 147 *r = IndexedDBKeyPath(array);
139 return true; 148 return true;
140 } 149 }
141 case WebIDBKeyPath::StringType: { 150 case WebIDBKeyPathTypeString: {
142 string16 string; 151 string16 string;
143 if (!ReadParam(m, iter, &string)) 152 if (!ReadParam(m, iter, &string))
144 return false; 153 return false;
145 *r = IndexedDBKeyPath(string); 154 *r = IndexedDBKeyPath(string);
146 return true; 155 return true;
147 } 156 }
148 case WebIDBKeyPath::NullType: 157 case WebIDBKeyPathTypeNull:
149 *r = IndexedDBKeyPath(); 158 *r = IndexedDBKeyPath();
150 return true; 159 return true;
151 } 160 }
152 NOTREACHED(); 161 NOTREACHED();
153 return false; 162 return false;
154 } 163 }
155 164
156 void ParamTraits<IndexedDBKeyPath>::Log(const param_type& p, std::string* l) { 165 void ParamTraits<IndexedDBKeyPath>::Log(const param_type& p, std::string* l) {
157 l->append("<IndexedDBKeyPath>("); 166 l->append("<IndexedDBKeyPath>(");
158 LogParam(static_cast<int>(p.type()), l); 167 LogParam(static_cast<int>(p.type()), l);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 l->append(", upper="); 215 l->append(", upper=");
207 LogParam(p.upper(), l); 216 LogParam(p.upper(), l);
208 l->append(", lower_open="); 217 l->append(", lower_open=");
209 LogParam(p.lowerOpen(), l); 218 LogParam(p.lowerOpen(), l);
210 l->append(", upper_open="); 219 l->append(", upper_open=");
211 LogParam(p.upperOpen(), l); 220 LogParam(p.upperOpen(), l);
212 l->append(")"); 221 l->append(")");
213 } 222 }
214 223
215 } // namespace IPC 224 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/indexed_db/indexed_db_key_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698