summaryrefslogtreecommitdiffstats
path: root/webkit/support/test_webidbfactory.cc
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-05 00:41:58 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-05 00:41:58 +0000
commit4ea6de7e64205a2d897bc28aa2a05504174956b7 (patch)
treed92fff7e4b41f9ff114e8f8690beb8e87cfb739c /webkit/support/test_webidbfactory.cc
parentde0c4f55561ced93620c8c4bdc85f9fc73f1ac1e (diff)
downloadchromium_src-4ea6de7e64205a2d897bc28aa2a05504174956b7.zip
chromium_src-4ea6de7e64205a2d897bc28aa2a05504174956b7.tar.gz
chromium_src-4ea6de7e64205a2d897bc28aa2a05504174956b7.tar.bz2
Make TestWebIDBFactory allocate a separate WebIDBFactory per thread.
This allows the main WebKit thread and web worker threads to each get their own WebIDBFactory instance, which mimics the behavior when we let the WebIDBFactory be instantiated via the WebKitPlatformSupport::idbFactory() method. R=alecflett@chromium.org Review URL: https://chromiumcodereview.appspot.com/12181010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180583 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/support/test_webidbfactory.cc')
-rw-r--r--webkit/support/test_webidbfactory.cc64
1 files changed, 64 insertions, 0 deletions
diff --git a/webkit/support/test_webidbfactory.cc b/webkit/support/test_webidbfactory.cc
new file mode 100644
index 0000000..faabfa5
--- /dev/null
+++ b/webkit/support/test_webidbfactory.cc
@@ -0,0 +1,64 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/support/test_webidbfactory.h"
+
+#include "base/logging.h"
+#include "webkit/support/webkit_support.h"
+
+TestWebIDBFactory::TestWebIDBFactory() {
+ // 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());
+}
+
+TestWebIDBFactory::~TestWebIDBFactory() {
+}
+
+void TestWebIDBFactory::getDatabaseNames(
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebSecurityOrigin& origin,
+ WebKit::WebFrame* frame,
+ const WebKit::WebString& data_dir) {
+ GetFactory()->getDatabaseNames(callbacks, origin, frame,
+ data_dir.isEmpty() ? data_dir_ : data_dir);
+}
+
+void TestWebIDBFactory::open(
+ const WebKit::WebString& name,
+ long long version,
+ long long transaction_id,
+ WebKit::WebIDBCallbacks* callbacks,
+ WebKit::WebIDBDatabaseCallbacks* database_callbacks,
+ const WebKit::WebSecurityOrigin& origin,
+ WebKit::WebFrame* frame,
+ const WebKit::WebString& data_dir) {
+ GetFactory()->open(name, version, transaction_id, callbacks,
+ database_callbacks, origin, frame,
+ data_dir.isEmpty() ? data_dir_ : data_dir);
+}
+
+void TestWebIDBFactory::deleteDatabase(const WebKit::WebString& name,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebSecurityOrigin& origin,
+ WebKit::WebFrame* frame,
+ const WebKit::WebString& dataDir) {
+ GetFactory()->deleteDatabase(name, callbacks, origin, frame,
+ dataDir.isEmpty() ? data_dir_ : dataDir);
+}
+
+WebKit::WebIDBFactory* TestWebIDBFactory::GetFactory() {
+ WebKit::WebIDBFactory* factory = factories_.Get();
+ if (!factory) {
+ factory = WebKit::WebIDBFactory::create();
+ factories_.Set(factory);
+ }
+ return factory;
+}