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