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

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: Update to ToT again Created 7 years, 6 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.cc ('k') | content/content_browser.gypi » ('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) 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 NOTREACHED();
87 return false;
86 } 88 }
87 89
88 void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) { 90 void ParamTraits<IndexedDBKey>::Log(const param_type& p, std::string* l) {
89 l->append("<IndexedDBKey>("); 91 l->append("<IndexedDBKey>(");
90 LogParam(int(p.type()), l); 92 LogParam(static_cast<int>(p.type()), l);
91 l->append(", "); 93 l->append(", ");
92 l->append("["); 94 l->append("[");
93 std::vector<IndexedDBKey>::const_iterator it = p.array().begin(); 95 std::vector<IndexedDBKey>::const_iterator it = p.array().begin();
94 while (it != p.array().end()) { 96 while (it != p.array().end()) {
95 Log(*it, l); 97 Log(*it, l);
96 ++it; 98 ++it;
97 if (it != p.array().end()) 99 if (it != p.array().end())
98 l->append(", "); 100 l->append(", ");
99 } 101 }
100 l->append("], "); 102 l->append("], ");
101 LogParam(p.string(), l); 103 LogParam(p.string(), l);
102 l->append(", "); 104 l->append(", ");
103 LogParam(p.date(), l); 105 LogParam(p.date(), l);
104 l->append(", "); 106 l->append(", ");
105 LogParam(p.number(), l); 107 LogParam(p.number(), l);
106 l->append(")"); 108 l->append(")");
107 } 109 }
108 110
109 void ParamTraits<IndexedDBKeyPath>::Write(Message* m, const param_type& p) { 111 void ParamTraits<IndexedDBKeyPath>::Write(Message* m, const param_type& p) {
110 WriteParam(m, int(p.type())); 112 WriteParam(m, static_cast<int>(p.type()));
111 switch (p.type()) { 113 switch (p.type()) {
112 case WebIDBKeyPath::ArrayType: 114 case WebIDBKeyPath::ArrayType:
113 WriteParam(m, p.array()); 115 WriteParam(m, p.array());
114 return; 116 return;
115 case WebIDBKeyPath::StringType: 117 case WebIDBKeyPath::StringType:
116 WriteParam(m, p.string()); 118 WriteParam(m, p.string());
117 return; 119 return;
118 case WebIDBKeyPath::NullType: 120 case WebIDBKeyPath::NullType:
119 return; 121 return;
120 } 122 }
(...skipping 25 matching lines...) Expand all
146 case WebIDBKeyPath::NullType: 148 case WebIDBKeyPath::NullType:
147 *r = IndexedDBKeyPath(); 149 *r = IndexedDBKeyPath();
148 return true; 150 return true;
149 } 151 }
150 NOTREACHED(); 152 NOTREACHED();
151 return false; 153 return false;
152 } 154 }
153 155
154 void ParamTraits<IndexedDBKeyPath>::Log(const param_type& p, std::string* l) { 156 void ParamTraits<IndexedDBKeyPath>::Log(const param_type& p, std::string* l) {
155 l->append("<IndexedDBKeyPath>("); 157 l->append("<IndexedDBKeyPath>(");
156 LogParam(int(p.type()), l); 158 LogParam(static_cast<int>(p.type()), l);
157 l->append(", "); 159 l->append(", ");
158 LogParam(p.string(), l); 160 LogParam(p.string(), l);
159 l->append(", "); 161 l->append(", ");
160 l->append("["); 162 l->append("[");
161 std::vector<string16>::const_iterator it = p.array().begin(); 163 std::vector<string16>::const_iterator it = p.array().begin();
162 while (it != p.array().end()) { 164 while (it != p.array().end()) {
163 LogParam(*it, l); 165 LogParam(*it, l);
164 ++it; 166 ++it;
165 if (it != p.array().end()) 167 if (it != p.array().end())
166 l->append(", "); 168 l->append(", ");
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 l->append(", upper="); 206 l->append(", upper=");
205 LogParam(p.upper(), l); 207 LogParam(p.upper(), l);
206 l->append(", lower_open="); 208 l->append(", lower_open=");
207 LogParam(p.lowerOpen(), l); 209 LogParam(p.lowerOpen(), l);
208 l->append(", upper_open="); 210 l->append(", upper_open=");
209 LogParam(p.upperOpen(), l); 211 LogParam(p.upperOpen(), l);
210 l->append(")"); 212 l->append(")");
211 } 213 }
212 214
213 } // namespace IPC 215 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/indexed_db/indexed_db_key.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698