summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-07 00:05:29 +0000
committerjsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-07 00:05:29 +0000
commitf2c46d653c858912f9d745281b9dd382a86b805a (patch)
treee1a85fe2fe8896310562a00decb65c9bdc61b76c
parent8159a1c2e591f98f9a7f5f32cf8c240c6e8e4f87 (diff)
downloadchromium_src-f2c46d653c858912f9d745281b9dd382a86b805a.zip
chromium_src-f2c46d653c858912f9d745281b9dd382a86b805a.tar.gz
chromium_src-f2c46d653c858912f9d745281b9dd382a86b805a.tar.bz2
Use a temp data dir for IDB tests so persistence can be verified.
WebCore::IDBFactory always generates specifies an empty string (indicating in-memory storage), and relies on intermediate methods before WebCore::IDBFactoryBackendImpl is reached to rewrite with a non-empty string to use on-disk storage. This patch inserts a test-specific implementation of WebIDBFactory into the middle of the call path to specify a data dir if one was not specified, mirroring what is done in multiprocess Chromium during IPC. Prep work for http://webkit.org/b/83074 Review URL: https://chromiumcodereview.appspot.com/10382180 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140892 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/support/test_webkit_platform_support.cc51
1 files changed, 50 insertions, 1 deletions
diff --git a/webkit/support/test_webkit_platform_support.cc b/webkit/support/test_webkit_platform_support.cc
index 505c13b..57fe67e 100644
--- a/webkit/support/test_webkit_platform_support.cc
+++ b/webkit/support/test_webkit_platform_support.cc
@@ -324,8 +324,57 @@ TestWebKitPlatformSupport::createLocalStorageNamespace(
return dom_storage_system_.CreateLocalStorageNamespace();
}
+// Wrap a WebKit::WebIDBFactory to rewrite the data directory to
+// a scoped temp directory. In multiprocess Chromium this is rewritten
+// to a real profile directory during IPC.
+class TestWebIDBFactory : public WebKit::WebIDBFactory {
+ public:
+ TestWebIDBFactory()
+ : factory_(WebKit::WebIDBFactory::create()) {
+ // Create a new temp directory for Indexed DB storage, specific to this
+ // factory. If this fails, WebKit uses in-memory storage.
+ if (!indexed_db_dir_.CreateUniqueTempDir()) {
+ LOG(WARNING) << "Failed to create a temp dir for Indexed DB, "
+ "using in-memory storage.";
+ DCHECK(indexed_db_dir_.path().empty());
+ }
+ data_dir_ = webkit_support::GetAbsoluteWebStringFromUTF8Path(
+ indexed_db_dir_.path().AsUTF8Unsafe());
+ }
+
+ virtual void getDatabaseNames(WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebSecurityOrigin& origin,
+ WebKit::WebFrame* frame,
+ const WebString& dataDir) {
+ factory_->getDatabaseNames(callbacks, origin, frame,
+ dataDir.isEmpty() ? data_dir_ : dataDir);
+ }
+
+ virtual void open(const WebString& name,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebSecurityOrigin& origin,
+ WebKit::WebFrame* frame,
+ const WebString& dataDir) {
+ factory_->open(name, callbacks, origin, frame,
+ dataDir.isEmpty() ? data_dir_ : dataDir);
+ }
+
+ virtual void deleteDatabase(const WebString& name,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebSecurityOrigin& origin,
+ WebKit::WebFrame* frame,
+ const WebString& dataDir) {
+ factory_->deleteDatabase(name, callbacks, origin, frame,
+ dataDir.isEmpty() ? data_dir_ : dataDir);
+ }
+ private:
+ scoped_ptr<WebIDBFactory> factory_;
+ ScopedTempDir indexed_db_dir_;
+ WebString data_dir_;
+};
+
WebKit::WebIDBFactory* TestWebKitPlatformSupport::idbFactory() {
- return WebKit::WebIDBFactory::create();
+ return new TestWebIDBFactory();
}
void TestWebKitPlatformSupport::createIDBKeysFromSerializedValuesAndKeyPath(