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

Side by Side Diff: content/common/indexed_db/indexed_db_param_traits.cc

Issue 15564008: Migrate the IndexedDB backend from Blink to Chromium (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Coding style fixes Created 7 years, 7 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
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>
8 #include <vector>
7 #include "content/common/indexed_db/indexed_db_key.h" 9 #include "content/common/indexed_db/indexed_db_key.h"
8 #include "content/common/indexed_db/indexed_db_key_path.h" 10 #include "content/common/indexed_db/indexed_db_key_path.h"
9 #include "content/common/indexed_db/indexed_db_key_range.h" 11 #include "content/common/indexed_db/indexed_db_key_range.h"
10 #include "ipc/ipc_message_utils.h" 12 #include "ipc/ipc_message_utils.h"
11 13
12 using content::IndexedDBKey; 14 using content::IndexedDBKey;
13 using content::IndexedDBKeyPath; 15 using content::IndexedDBKeyPath;
14 using content::IndexedDBKeyRange; 16 using content::IndexedDBKeyRange;
15 17
16 using WebKit::WebIDBKey; 18 using WebKit::WebIDBKey;
17 using WebKit::WebIDBKeyPath; 19 using WebKit::WebIDBKeyPath;
18 20
19 namespace IPC { 21 namespace IPC {
20 22
21 void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) { 23 void ParamTraits<IndexedDBKey>::Write(Message* m, const param_type& p) {
22 WriteParam(m, int(p.type())); 24 WriteParam(m, static_cast<int>(p.type()));
23 switch (p.type()) { 25 switch (p.type()) {
24 case WebIDBKey::ArrayType: 26 case WebIDBKey::ArrayType:
25 WriteParam(m, p.array()); 27 WriteParam(m, p.array());
26 return; 28 return;
27 case WebIDBKey::StringType: 29 case WebIDBKey::StringType:
28 WriteParam(m, p.string()); 30 WriteParam(m, p.string());
29 return; 31 return;
30 case WebIDBKey::DateType: 32 case WebIDBKey::DateType:
31 WriteParam(m, p.date()); 33 WriteParam(m, p.date());
32 return; 34 return;
33 case WebIDBKey::NumberType: 35 case WebIDBKey::NumberType:
34 WriteParam(m, p.number()); 36 WriteParam(m, p.number());
35 return; 37 return;
36 case WebIDBKey::InvalidType: 38 case WebIDBKey::InvalidType:
37 case WebIDBKey::NullType: 39 case WebIDBKey::NullType:
38 return; 40 return;
39 default: 41 case WebIDBKey::MinType:
40 // This is a placeholder for WebKit::WebIDBKey::MinType
41 NOTREACHED(); 42 NOTREACHED();
42 return; 43 return;
43 } 44 }
44 } 45 }
45 46
46 bool ParamTraits<IndexedDBKey>::Read(const Message* m, 47 bool ParamTraits<IndexedDBKey>::Read(const Message* m,
47 PickleIterator* iter, 48 PickleIterator* iter,
48 param_type* r) { 49 param_type* r) {
49 int type; 50 int type;
50 if (!ReadParam(m, iter, &type)) 51 if (!ReadParam(m, iter, &type))
(...skipping 20 matching lines...) Expand all
71 double number; 72 double number;
72 if (!ReadParam(m, iter, &number)) 73 if (!ReadParam(m, iter, &number))
73 return false; 74 return false;
74 *r = IndexedDBKey(number, web_type); 75 *r = IndexedDBKey(number, web_type);
75 return true; 76 return true;
76 } 77 }
77 case WebIDBKey::InvalidType: 78 case WebIDBKey::InvalidType:
78 case WebIDBKey::NullType: 79 case WebIDBKey::NullType:
79 *r = IndexedDBKey(web_type); 80 *r = IndexedDBKey(web_type);
80 return true; 81 return true;
81 default: 82 case WebIDBKey::MinType:
82 // This is a placeholder for WebKit::WebIDBKey::MinType
83 NOTREACHED(); 83 NOTREACHED();
84 return false; 84 return false;
85 } 85 }
86 } 86 }
87 87
88 void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) { 88 void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) {
89 l->append("<IndexedDBKey>("); 89 l->append("<IndexedDBKey>(");
90 LogParam(int(p.type()), l); 90 LogParam(static_cast<int>(p.type()), l);
91 l->append(", "); 91 l->append(", ");
92 l->append("["); 92 l->append("[");
93 std::vector<IndexedDBKey>::const_iterator it = p.array().begin(); 93 std::vector<IndexedDBKey>::const_iterator it = p.array().begin();
94 while (it != p.array().end()) { 94 while (it != p.array().end()) {
95 Log(*it, l); 95 Log(*it, l);
96 ++it; 96 ++it;
97 if (it != p.array().end()) 97 if (it != p.array().end())
98 l->append(", "); 98 l->append(", ");
99 } 99 }
100 l->append("], "); 100 l->append("], ");
101 LogParam(p.string(), l); 101 LogParam(p.string(), l);
102 l->append(", "); 102 l->append(", ");
103 LogParam(p.date(), l); 103 LogParam(p.date(), l);
104 l->append(", "); 104 l->append(", ");
105 LogParam(p.number(), l); 105 LogParam(p.number(), l);
106 l->append(")"); 106 l->append(")");
107 } 107 }
108 108
109 void ParamTraits<IndexedDBKeyPath>::Write(Message* m, const param_type& p) { 109 void ParamTraits<IndexedDBKeyPath>::Write(Message* m, const param_type& p) {
110 WriteParam(m, int(p.type())); 110 WriteParam(m, static_cast<int>(p.type()));
111 switch (p.type()) { 111 switch (p.type()) {
112 case WebIDBKeyPath::ArrayType: 112 case WebIDBKeyPath::ArrayType:
113 WriteParam(m, p.array()); 113 WriteParam(m, p.array());
114 return; 114 return;
115 case WebIDBKeyPath::StringType: 115 case WebIDBKeyPath::StringType:
116 WriteParam(m, p.string()); 116 WriteParam(m, p.string());
117 return; 117 return;
118 case WebIDBKeyPath::NullType: 118 case WebIDBKeyPath::NullType:
119 return; 119 return;
120 } 120 }
(...skipping 25 matching lines...) Expand all
146 case WebIDBKeyPath::NullType: 146 case WebIDBKeyPath::NullType:
147 *r = IndexedDBKeyPath(); 147 *r = IndexedDBKeyPath();
148 return true; 148 return true;
149 } 149 }
150 NOTREACHED(); 150 NOTREACHED();
151 return false; 151 return false;
152 } 152 }
153 153
154 void ParamTraits<IndexedDBKeyPath>::Log(const param_type& p, std::string* l) { 154 void ParamTraits<IndexedDBKeyPath>::Log(const param_type& p, std::string* l) {
155 l->append("<IndexedDBKeyPath>("); 155 l->append("<IndexedDBKeyPath>(");
156 LogParam(int(p.type()), l); 156 LogParam(static_cast<int>(p.type()), l);
157 l->append(", "); 157 l->append(", ");
158 LogParam(p.string(), l); 158 LogParam(p.string(), l);
159 l->append(", "); 159 l->append(", ");
160 l->append("["); 160 l->append("[");
161 std::vector<string16>::const_iterator it = p.array().begin(); 161 std::vector<string16>::const_iterator it = p.array().begin();
162 while (it != p.array().end()) { 162 while (it != p.array().end()) {
163 LogParam(*it, l); 163 LogParam(*it, l);
164 ++it; 164 ++it;
165 if (it != p.array().end()) 165 if (it != p.array().end())
166 l->append(", "); 166 l->append(", ");
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 l->append(", upper="); 204 l->append(", upper=");
205 LogParam(p.upper(), l); 205 LogParam(p.upper(), l);
206 l->append(", lower_open="); 206 l->append(", lower_open=");
207 LogParam(p.lowerOpen(), l); 207 LogParam(p.lowerOpen(), l);
208 l->append(", upper_open="); 208 l->append(", upper_open=");
209 LogParam(p.upperOpen(), l); 209 LogParam(p.upperOpen(), l);
210 l->append(")"); 210 l->append(")");
211 } 211 }
212 212
213 } // namespace IPC 213 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698