OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBKIT_SUPPORT_TEST_WEBIDBFACTORY_H_ |
| 6 #define WEBKIT_SUPPORT_TEST_WEBIDBFACTORY_H_ |
| 7 |
| 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/threading/thread_local.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" |
| 11 |
| 12 // Wrap a WebKit::WebIDBFactory to rewrite the data directory to |
| 13 // a scoped temp directory. In multiprocess Chromium this is rewritten |
| 14 // to a real profile directory during IPC. |
| 15 class TestWebIDBFactory : public WebKit::WebIDBFactory { |
| 16 public: |
| 17 TestWebIDBFactory(); |
| 18 virtual ~TestWebIDBFactory(); |
| 19 |
| 20 // WebIDBFactory methods: |
| 21 virtual void getDatabaseNames(WebKit::WebIDBCallbacks* callbacks, |
| 22 const WebKit::WebSecurityOrigin& origin, |
| 23 WebKit::WebFrame* frame, |
| 24 const WebKit::WebString& data_dir); |
| 25 virtual void open(const WebKit::WebString& name, |
| 26 long long version, |
| 27 long long transaction_id, |
| 28 WebKit::WebIDBCallbacks* callbacks, |
| 29 WebKit::WebIDBDatabaseCallbacks* database_callbacks, |
| 30 const WebKit::WebSecurityOrigin& origin, |
| 31 WebKit::WebFrame* frame, |
| 32 const WebKit::WebString& data_dir); |
| 33 virtual void deleteDatabase(const WebKit::WebString& name, |
| 34 WebKit::WebIDBCallbacks* callbacks, |
| 35 const WebKit::WebSecurityOrigin& origin, |
| 36 WebKit::WebFrame* frame, |
| 37 const WebKit::WebString& data_dir); |
| 38 |
| 39 private: |
| 40 // Returns the WebIDBFactory implementation to use for the current thread. |
| 41 WebKit::WebIDBFactory* GetFactory(); |
| 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 WebKit::WebString data_dir_; |
| 51 }; |
| 52 |
| 53 #endif // WEBKIT_SUPPORT_TEST_WEBIDBFACTORY_H_ |
OLD | NEW |