| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 WEBKIT_SUPPORT_TEST_WEBIDBFACTORY_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_WEBIDBFACTORY_IMPL_H_ |
| 6 #define WEBKIT_SUPPORT_TEST_WEBIDBFACTORY_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_WEBIDBFACTORY_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/threading/thread_local.h" | |
| 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebIDBFactory.h" | 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebIDBFactory.h" |
| 11 | 10 |
| 12 // Wrap a WebKit::WebIDBFactory to rewrite the data directory to | 11 namespace content { |
| 13 // a scoped temp directory. In multiprocess Chromium this is rewritten | 12 |
| 14 // to a real profile directory during IPC. | 13 class IndexedDBFactory; |
| 15 class TestWebIDBFactory : public WebKit::WebIDBFactory { | 14 |
| 15 class WebIDBFactoryImpl : public WebKit::WebIDBFactory { |
| 16 public: | 16 public: |
| 17 TestWebIDBFactory(); | 17 WebIDBFactoryImpl(); |
| 18 virtual ~TestWebIDBFactory(); | 18 virtual ~WebIDBFactoryImpl(); |
| 19 | 19 |
| 20 // WebIDBFactory methods: | |
| 21 virtual void getDatabaseNames(WebKit::WebIDBCallbacks*, | 20 virtual void getDatabaseNames(WebKit::WebIDBCallbacks*, |
| 22 const WebKit::WebString& database_identifier, | 21 const WebKit::WebString& database_identifier, |
| 23 const WebKit::WebString& data_dir); | 22 const WebKit::WebString& data_dir); |
| 24 virtual void open(const WebKit::WebString& name, | 23 virtual void open(const WebKit::WebString& name, |
| 25 long long version, | 24 long long version, |
| 26 long long transaction_id, | 25 long long transaction_id, |
| 27 WebKit::WebIDBCallbacks*, | 26 WebKit::WebIDBCallbacks*, |
| 28 WebKit::WebIDBDatabaseCallbacks*, | 27 WebKit::WebIDBDatabaseCallbacks*, |
| 29 const WebKit::WebString& database_identifier, | 28 const WebKit::WebString& database_identifier, |
| 30 const WebKit::WebString& data_dir); | 29 const WebKit::WebString& data_dir); |
| 31 virtual void deleteDatabase(const WebKit::WebString& name, | 30 virtual void deleteDatabase(const WebKit::WebString& name, |
| 32 WebKit::WebIDBCallbacks*, | 31 WebKit::WebIDBCallbacks*, |
| 33 const WebKit::WebString& database_identifier, | 32 const WebKit::WebString& database_identifier, |
| 34 const WebKit::WebString& data_dir); | 33 const WebKit::WebString& data_dir); |
| 35 | 34 |
| 36 private: | 35 private: |
| 37 // Returns the WebIDBFactory implementation to use for the current thread. | 36 scoped_refptr<IndexedDBFactory> idb_factory_backend_; |
| 38 WebKit::WebIDBFactory* GetFactory(); | |
| 39 | |
| 40 // Returns the data directory to use. | |
| 41 WebKit::WebString GetDataDir() const; | |
| 42 | |
| 43 // We allocate a separate WebIDBFactory instance per thread since the | |
| 44 // implementation is not thread-safe. We also intentionally leak the | |
| 45 // factory instances to avoid shutdown races. TODO(darin): Can we | |
| 46 // avoid leaking these? | |
| 47 base::ThreadLocalPointer<WebKit::WebIDBFactory> factories_; | |
| 48 | |
| 49 base::ScopedTempDir indexed_db_dir_; | |
| 50 }; | 37 }; |
| 51 | 38 |
| 52 #endif // WEBKIT_SUPPORT_TEST_WEBIDBFACTORY_H_ | 39 } // namespace content |
| 40 |
| 41 #endif // CONTENT_BROWSER_INDEXED_DB_WEBIDBFACTORY_IMPL_H_ |
| OLD | NEW |