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 #include "webkit/support/test_webidbfactory.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "webkit/support/webkit_support.h" |
| 9 |
| 10 TestWebIDBFactory::TestWebIDBFactory() { |
| 11 // Create a new temp directory for Indexed DB storage, specific to this |
| 12 // factory. If this fails, WebKit uses in-memory storage. |
| 13 if (!indexed_db_dir_.CreateUniqueTempDir()) { |
| 14 LOG(WARNING) << "Failed to create a temp dir for Indexed DB, " |
| 15 "using in-memory storage."; |
| 16 DCHECK(indexed_db_dir_.path().empty()); |
| 17 } |
| 18 data_dir_ = webkit_support::GetAbsoluteWebStringFromUTF8Path( |
| 19 indexed_db_dir_.path().AsUTF8Unsafe()); |
| 20 } |
| 21 |
| 22 TestWebIDBFactory::~TestWebIDBFactory() { |
| 23 } |
| 24 |
| 25 void TestWebIDBFactory::getDatabaseNames( |
| 26 WebKit::WebIDBCallbacks* callbacks, |
| 27 const WebKit::WebSecurityOrigin& origin, |
| 28 WebKit::WebFrame* frame, |
| 29 const WebKit::WebString& data_dir) { |
| 30 GetFactory()->getDatabaseNames(callbacks, origin, frame, |
| 31 data_dir.isEmpty() ? data_dir_ : data_dir); |
| 32 } |
| 33 |
| 34 void TestWebIDBFactory::open( |
| 35 const WebKit::WebString& name, |
| 36 long long version, |
| 37 long long transaction_id, |
| 38 WebKit::WebIDBCallbacks* callbacks, |
| 39 WebKit::WebIDBDatabaseCallbacks* database_callbacks, |
| 40 const WebKit::WebSecurityOrigin& origin, |
| 41 WebKit::WebFrame* frame, |
| 42 const WebKit::WebString& data_dir) { |
| 43 GetFactory()->open(name, version, transaction_id, callbacks, |
| 44 database_callbacks, origin, frame, |
| 45 data_dir.isEmpty() ? data_dir_ : data_dir); |
| 46 } |
| 47 |
| 48 void TestWebIDBFactory::deleteDatabase(const WebKit::WebString& name, |
| 49 WebKit::WebIDBCallbacks* callbacks, |
| 50 const WebKit::WebSecurityOrigin& origin, |
| 51 WebKit::WebFrame* frame, |
| 52 const WebKit::WebString& dataDir) { |
| 53 GetFactory()->deleteDatabase(name, callbacks, origin, frame, |
| 54 dataDir.isEmpty() ? data_dir_ : dataDir); |
| 55 } |
| 56 |
| 57 WebKit::WebIDBFactory* TestWebIDBFactory::GetFactory() { |
| 58 WebKit::WebIDBFactory* factory = factories_.Get(); |
| 59 if (!factory) { |
| 60 factory = WebKit::WebIDBFactory::create(); |
| 61 factories_.Set(factory); |
| 62 } |
| 63 return factory; |
| 64 } |
OLD | NEW |