| 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 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_KEY_UTILITY_CLIENT_H_ | 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_KEY_UTILITY_CLIENT_H_ |
| 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_KEY_UTILITY_CLIENT_H_ | 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_KEY_UTILITY_CLIENT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "content/common/content_export.h" |
| 13 | 14 |
| 14 class IndexedDBKey; | 15 class IndexedDBKey; |
| 15 class SerializedScriptValue; | 16 class SerializedScriptValue; |
| 16 class KeyUtilityClientImpl; | 17 class KeyUtilityClientImpl; |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 template <typename T> | 20 template <typename T> |
| 20 struct DefaultLazyInstanceTraits; | 21 struct DefaultLazyInstanceTraits; |
| 21 } // namespace base | 22 } // namespace base |
| 22 | 23 |
| 23 // Class for obtaining IndexedDBKeys from the SerializedScriptValues given | 24 // Class for obtaining IndexedDBKeys from the SerializedScriptValues given |
| 24 // an IDBKeyPath. This class is a thin singleton wrapper around the | 25 // an IDBKeyPath. This class is a thin singleton wrapper around the |
| 25 // KeyUtilityClientImpl, which does the real work. | 26 // KeyUtilityClientImpl, which does the real work. |
| 26 class IndexedDBKeyUtilityClient { | 27 class IndexedDBKeyUtilityClient { |
| 27 public: | 28 public: |
| 28 // Synchronously obtain the |keys| from |values| for the given |key_path|. | 29 // Synchronously obtain the |keys| from |values| for the given |key_path|. |
| 29 static void CreateIDBKeysFromSerializedValuesAndKeyPath( | 30 static void CreateIDBKeysFromSerializedValuesAndKeyPath( |
| 30 const std::vector<SerializedScriptValue>& values, | 31 const std::vector<SerializedScriptValue>& values, |
| 31 const string16& key_path, | 32 const string16& key_path, |
| 32 std::vector<IndexedDBKey>* keys); | 33 std::vector<IndexedDBKey>* keys); |
| 33 | 34 |
| 34 // Synchronously inject |key| into |value| using |key_path|. Returns the new | 35 // Synchronously inject |key| into |value| using |key_path|. Returns the new |
| 35 // value. | 36 // value. |
| 36 static SerializedScriptValue InjectIDBKeyIntoSerializedValue( | 37 static SerializedScriptValue InjectIDBKeyIntoSerializedValue( |
| 37 const IndexedDBKey& key, | 38 const IndexedDBKey& key, |
| 38 const SerializedScriptValue& value, | 39 const SerializedScriptValue& value, |
| 39 const string16& key_path); | 40 const string16& key_path); |
| 40 | 41 |
| 41 // Shut down the underlying implementation. Must be called on the IO thread. | 42 // Shut down the underlying implementation. Must be called on the IO thread. |
| 42 static void Shutdown(); | 43 CONTENT_EXPORT static void Shutdown(); |
| 43 | 44 |
| 44 private: | 45 private: |
| 45 friend struct base::DefaultLazyInstanceTraits<IndexedDBKeyUtilityClient>; | 46 friend struct base::DefaultLazyInstanceTraits<IndexedDBKeyUtilityClient>; |
| 46 IndexedDBKeyUtilityClient(); | 47 IndexedDBKeyUtilityClient(); |
| 47 ~IndexedDBKeyUtilityClient(); | 48 ~IndexedDBKeyUtilityClient(); |
| 48 | 49 |
| 49 bool is_shutdown_; | 50 bool is_shutdown_; |
| 50 | 51 |
| 51 // The real client; laziliy instantiated. | 52 // The real client; laziliy instantiated. |
| 52 scoped_refptr<KeyUtilityClientImpl> impl_; | 53 scoped_refptr<KeyUtilityClientImpl> impl_; |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_KEY_UTILITY_CLIENT_H_ | 56 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_KEY_UTILITY_CLIENT_H_ |
| OLD | NEW |