Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: webkit/support/test_webidbfactory.h

Issue 12230054: Make TestWebIDBFactory allocate a separate WebIDBFactory per thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webkit/support/test_webidbfactory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/support/test_webidbfactory.h
diff --git a/webkit/support/test_webidbfactory.h b/webkit/support/test_webidbfactory.h
new file mode 100644
index 0000000000000000000000000000000000000000..e7b02b0767bbeb5e6ec5339b70b8986db2082b63
--- /dev/null
+++ b/webkit/support/test_webidbfactory.h
@@ -0,0 +1,55 @@
+// 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.
+
+#ifndef WEBKIT_SUPPORT_TEST_WEBIDBFACTORY_H_
+#define WEBKIT_SUPPORT_TEST_WEBIDBFACTORY_H_
+
+#include "base/files/scoped_temp_dir.h"
+#include "base/threading/thread_local.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h"
+
+// 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();
+ virtual ~TestWebIDBFactory();
+
+ // WebIDBFactory methods:
+ virtual void getDatabaseNames(WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebSecurityOrigin& origin,
+ WebKit::WebFrame* frame,
+ const WebKit::WebString& data_dir);
+ virtual void 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);
+ virtual void deleteDatabase(const WebKit::WebString& name,
+ WebKit::WebIDBCallbacks* callbacks,
+ const WebKit::WebSecurityOrigin& origin,
+ WebKit::WebFrame* frame,
+ const WebKit::WebString& data_dir);
+
+ private:
+ // Returns the WebIDBFactory implementation to use for the current thread.
+ WebKit::WebIDBFactory* GetFactory();
+
+ // Returns the data directory to use.
+ WebKit::WebString GetDataDir() const;
+
+ // We allocate a separate WebIDBFactory instance per thread since the
+ // implementation is not thread-safe. We also intentionally leak the
+ // factory instances to avoid shutdown races. TODO(darin): Can we
+ // avoid leaking these?
+ base::ThreadLocalPointer<WebKit::WebIDBFactory> factories_;
+
+ base::ScopedTempDir indexed_db_dir_;
+};
+
+#endif // WEBKIT_SUPPORT_TEST_WEBIDBFACTORY_H_
« no previous file with comments | « no previous file | webkit/support/test_webidbfactory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698