| OLD | NEW |
| 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 "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" | |
| 10 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize
dScriptValue.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize
dScriptValue.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 15 | 14 |
| 16 namespace webkit_glue { | 15 namespace webkit_glue { |
| 17 | 16 |
| 18 using WebKit::WebIDBKey; | 17 using WebKit::WebIDBKey; |
| 19 using WebKit::WebIDBKeyPath; | 18 using WebKit::WebIDBKeyPath; |
| 20 using WebKit::WebSerializedScriptValue; | 19 using WebKit::WebSerializedScriptValue; |
| 21 using WebKit::WebString; | 20 using WebKit::WebString; |
| 22 | 21 |
| 23 bool IDBKeysFromValuesAndKeyPath( | 22 void IDBKeysFromValuesAndKeyPath( |
| 24 const std::vector<WebSerializedScriptValue>& serialized_script_values, | 23 const std::vector<WebSerializedScriptValue>& serialized_script_values, |
| 25 const string16& idb_key_path, | 24 const WebIDBKeyPath& idb_key_path, |
| 26 std::vector<WebIDBKey>* values) { | 25 std::vector<WebIDBKey>* values) { |
| 27 // TODO(jsbell): Remove the explicit coercion to WebString. | |
| 28 // http://crbug.com/112308 | |
| 29 WebIDBKeyPath web_idb_key_path = | |
| 30 WebIDBKeyPath::create(WebString(idb_key_path)); | |
| 31 bool error = web_idb_key_path.parseError() != 0; | |
| 32 // When a parse error is encountered, no value is returned (null) | |
| 33 for (std::vector<WebSerializedScriptValue>::const_iterator i = | 26 for (std::vector<WebSerializedScriptValue>::const_iterator i = |
| 34 serialized_script_values.begin(); | 27 serialized_script_values.begin(); |
| 35 i != serialized_script_values.end(); ++i) { | 28 i != serialized_script_values.end(); ++i) { |
| 36 if (error) { | 29 values->push_back( |
| 37 values->push_back(WebIDBKey::createNull()); | 30 WebIDBKey::createFromValueAndKeyPath(*i, idb_key_path)); |
| 38 } else { | |
| 39 values->push_back( | |
| 40 WebIDBKey::createFromValueAndKeyPath(*i, web_idb_key_path)); | |
| 41 } | |
| 42 } | 31 } |
| 43 return error; | |
| 44 } | 32 } |
| 45 | 33 |
| 46 WebSerializedScriptValue InjectIDBKey( | 34 WebSerializedScriptValue InjectIDBKey( |
| 47 const WebIDBKey& key, | 35 const WebIDBKey& key, |
| 48 const WebSerializedScriptValue& value, | 36 const WebSerializedScriptValue& value, |
| 49 const string16& idb_key_path) { | 37 const WebIDBKeyPath& idb_key_path) { |
| 50 // TODO(jsbell): Remove the explicit coercion to WebString. | |
| 51 // http://crbug.com/112308 | |
| 52 return WebIDBKey::injectIDBKeyIntoSerializedValue( | 38 return WebIDBKey::injectIDBKeyIntoSerializedValue( |
| 53 key, value, WebIDBKeyPath::create(WebString(idb_key_path))); | 39 key, value, idb_key_path); |
| 54 } | 40 } |
| 55 | 41 |
| 56 } // namespace webkit_glue | 42 } // namespace webkit_glue |
| OLD | NEW |