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

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

Issue 9447084: Refactor Pickle Read methods to use higher performance PickleIterator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile (racing with incoming CLs) Created 8 years, 9 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 "content/common/indexed_db/indexed_db_key.h" 7 #include "content/common/indexed_db/indexed_db_key.h"
8 #include "content/common/indexed_db/indexed_db_key_range.h" 8 #include "content/common/indexed_db/indexed_db_key_range.h"
9 #include "content/public/common/serialized_script_value.h" 9 #include "content/public/common/serialized_script_value.h"
10 #include "ipc/ipc_message_utils.h" 10 #include "ipc/ipc_message_utils.h"
11 11
12 namespace IPC { 12 namespace IPC {
13 13
14 void ParamTraits<content::SerializedScriptValue>::Write(Message* m, 14 void ParamTraits<content::SerializedScriptValue>::Write(Message* m,
15 const param_type& p) { 15 const param_type& p) {
16 WriteParam(m, p.is_null()); 16 WriteParam(m, p.is_null());
17 WriteParam(m, p.is_invalid()); 17 WriteParam(m, p.is_invalid());
18 WriteParam(m, p.data()); 18 WriteParam(m, p.data());
19 } 19 }
20 20
21 bool ParamTraits<content::SerializedScriptValue>::Read(const Message* m, 21 bool ParamTraits<content::SerializedScriptValue>::Read(const Message* m,
22 void** iter, 22 PickleIterator* iter,
23 param_type* r) { 23 param_type* r) {
24 bool is_null; 24 bool is_null;
25 bool is_invalid; 25 bool is_invalid;
26 string16 data; 26 string16 data;
27 bool ok = 27 bool ok =
28 ReadParam(m, iter, &is_null) && 28 ReadParam(m, iter, &is_null) &&
29 ReadParam(m, iter, &is_invalid) && 29 ReadParam(m, iter, &is_invalid) &&
30 ReadParam(m, iter, &data); 30 ReadParam(m, iter, &data);
31 if (!ok) 31 if (!ok)
32 return false; 32 return false;
(...skipping 30 matching lines...) Expand all
63 WriteParam(m, p.number()); 63 WriteParam(m, p.number());
64 return; 64 return;
65 case WebKit::WebIDBKey::InvalidType: 65 case WebKit::WebIDBKey::InvalidType:
66 case WebKit::WebIDBKey::NullType: 66 case WebKit::WebIDBKey::NullType:
67 return; 67 return;
68 } 68 }
69 NOTREACHED(); 69 NOTREACHED();
70 } 70 }
71 71
72 bool ParamTraits<IndexedDBKey>::Read(const Message* m, 72 bool ParamTraits<IndexedDBKey>::Read(const Message* m,
73 void** iter, 73 PickleIterator* iter,
74 param_type* r) { 74 param_type* r) {
75 int type; 75 int type;
76 if (!ReadParam(m, iter, &type)) 76 if (!ReadParam(m, iter, &type))
77 return false; 77 return false;
78 78
79 switch (type) { 79 switch (type) {
80 case WebKit::WebIDBKey::ArrayType: 80 case WebKit::WebIDBKey::ArrayType:
81 { 81 {
82 std::vector<IndexedDBKey> array; 82 std::vector<IndexedDBKey> array;
83 if (!ReadParam(m, iter, &array)) 83 if (!ReadParam(m, iter, &array))
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 143
144 void ParamTraits<IndexedDBKeyRange>::Write(Message* m, const param_type& p) { 144 void ParamTraits<IndexedDBKeyRange>::Write(Message* m, const param_type& p) {
145 WriteParam(m, p.lower()); 145 WriteParam(m, p.lower());
146 WriteParam(m, p.upper()); 146 WriteParam(m, p.upper());
147 WriteParam(m, p.lowerOpen()); 147 WriteParam(m, p.lowerOpen());
148 WriteParam(m, p.upperOpen()); 148 WriteParam(m, p.upperOpen());
149 } 149 }
150 150
151 bool ParamTraits<IndexedDBKeyRange>::Read(const Message* m, 151 bool ParamTraits<IndexedDBKeyRange>::Read(const Message* m,
152 void** iter, 152 PickleIterator* iter,
153 param_type* r) { 153 param_type* r) {
154 154
155 IndexedDBKey lower; 155 IndexedDBKey lower;
156 if (!ReadParam(m, iter, &lower)) 156 if (!ReadParam(m, iter, &lower))
157 return false; 157 return false;
158 158
159 IndexedDBKey upper; 159 IndexedDBKey upper;
160 if (!ReadParam(m, iter, &upper)) 160 if (!ReadParam(m, iter, &upper))
161 return false; 161 return false;
162 162
(...skipping 15 matching lines...) Expand all
178 l->append(", upper="); 178 l->append(", upper=");
179 LogParam(p.upper(), l); 179 LogParam(p.upper(), l);
180 l->append(", lower_open="); 180 l->append(", lower_open=");
181 LogParam(p.lowerOpen(), l); 181 LogParam(p.lowerOpen(), l);
182 l->append(", upper_open="); 182 l->append(", upper_open=");
183 LogParam(p.upperOpen(), l); 183 LogParam(p.upperOpen(), l);
184 l->append(")"); 184 l->append(")");
185 } 185 }
186 186
187 } // namespace IPC 187 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/indexed_db/indexed_db_param_traits.h ('k') | content/common/mac/attributed_string_coder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698