OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/glue/idb_bindings.h" | 5 #include "webkit/glue/idb_bindings.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize
dScriptValue.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize
dScriptValue.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
15 | 15 |
16 namespace webkit_glue { | 16 namespace webkit_glue { |
17 | 17 |
18 using WebKit::WebIDBKey; | 18 using WebKit::WebIDBKey; |
19 using WebKit::WebIDBKeyPath; | 19 using WebKit::WebIDBKeyPath; |
20 using WebKit::WebSerializedScriptValue; | 20 using WebKit::WebSerializedScriptValue; |
21 | 21 |
22 bool IDBKeysFromValuesAndKeyPath( | 22 bool IDBKeysFromValuesAndKeyPath( |
23 const std::vector<WebSerializedScriptValue>& serialized_script_values, | 23 const std::vector<WebSerializedScriptValue>& serialized_script_values, |
24 const string16& idb_key_path, | 24 const string16& idb_key_path, |
25 std::vector<WebIDBKey>* values) { | 25 std::vector<WebIDBKey>* values) { |
26 WebIDBKeyPath web_idb_key_path = WebIDBKeyPath::create(idb_key_path); | 26 WebIDBKeyPath web_idb_key_path = WebIDBKeyPath::create(idb_key_path); |
27 bool error = web_idb_key_path.parseError() != 0; | 27 bool error = web_idb_key_path.parseError() != 0; |
28 // TODO(bulach): what to do when we have a parse error? For now, setting | 28 // When a parse error is encountered, no value is returned (null) |
29 // all values back as invalid and returning a boolean. | |
30 for (std::vector<WebSerializedScriptValue>::const_iterator i = | 29 for (std::vector<WebSerializedScriptValue>::const_iterator i = |
31 serialized_script_values.begin(); | 30 serialized_script_values.begin(); |
32 i != serialized_script_values.end(); ++i) { | 31 i != serialized_script_values.end(); ++i) { |
33 if (error) { | 32 if (error) { |
34 values->push_back(WebIDBKey::createInvalid()); | 33 values->push_back(WebIDBKey::createNull()); |
35 } else { | 34 } else { |
36 values->push_back( | 35 values->push_back( |
37 WebIDBKey::createFromValueAndKeyPath(*i, web_idb_key_path)); | 36 WebIDBKey::createFromValueAndKeyPath(*i, web_idb_key_path)); |
38 } | 37 } |
39 } | 38 } |
40 return error; | 39 return error; |
41 } | 40 } |
42 | 41 |
43 WebSerializedScriptValue InjectIDBKey( | 42 WebSerializedScriptValue InjectIDBKey( |
44 const WebIDBKey& key, | 43 const WebIDBKey& key, |
45 const WebSerializedScriptValue& value, | 44 const WebSerializedScriptValue& value, |
46 const string16& idb_key_path) { | 45 const string16& idb_key_path) { |
47 return WebIDBKey::injectIDBKeyIntoSerializedValue( | 46 return WebIDBKey::injectIDBKeyIntoSerializedValue( |
48 key, value, WebIDBKeyPath::create(idb_key_path)); | 47 key, value, WebIDBKeyPath::create(idb_key_path)); |
49 } | 48 } |
50 | 49 |
51 } // namespace webkit_glue | 50 } // namespace webkit_glue |
OLD | NEW |