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

Unified Diff: webkit/support/test_webkit_platform_support.cc

Issue 11946027: Instantiate the WebIDBFactoryImpl lazily, and call setIDBFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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/webkit_support.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/support/test_webkit_platform_support.cc
===================================================================
--- webkit/support/test_webkit_platform_support.cc (revision 177172)
+++ webkit/support/test_webkit_platform_support.cc (working copy)
@@ -346,8 +346,7 @@
// to a real profile directory during IPC.
class TestWebIDBFactory : public WebKit::WebIDBFactory {
public:
- TestWebIDBFactory()
- : factory_(WebKit::WebIDBFactory::create()) {
+ 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()) {
@@ -357,12 +356,16 @@
}
data_dir_ = webkit_support::GetAbsoluteWebStringFromUTF8Path(
indexed_db_dir_.path().AsUTF8Unsafe());
+
+ // Lazily construct factory_ so that it gets allocated on the thread where
+ // it will be used. TestWebIDBFactory gets allocated on the main thread.
}
virtual void getDatabaseNames(WebKit::WebIDBCallbacks* callbacks,
const WebKit::WebSecurityOrigin& origin,
WebKit::WebFrame* frame,
const WebString& dataDir) {
+ EnsureFactory();
factory_->getDatabaseNames(callbacks, origin, frame,
dataDir.isEmpty() ? data_dir_ : dataDir);
}
@@ -375,9 +378,10 @@
const WebKit::WebSecurityOrigin& origin,
WebKit::WebFrame* frame,
const WebString& dataDir) {
- factory_->open(name, version, transaction_id, callbacks,
- databaseCallbacks, origin, frame,
- dataDir.isEmpty() ? data_dir_ : dataDir);
+ EnsureFactory();
+ factory_->open(name, version, transaction_id, callbacks,
+ databaseCallbacks, origin, frame,
+ dataDir.isEmpty() ? data_dir_ : dataDir);
}
virtual void deleteDatabase(const WebString& name,
@@ -385,10 +389,16 @@
const WebKit::WebSecurityOrigin& origin,
WebKit::WebFrame* frame,
const WebString& dataDir) {
+ EnsureFactory();
factory_->deleteDatabase(name, callbacks, origin, frame,
dataDir.isEmpty() ? data_dir_ : dataDir);
}
private:
+ void EnsureFactory() {
+ if (!factory_)
+ factory_.reset(WebKit::WebIDBFactory::create());
+ }
+
scoped_ptr<WebIDBFactory> factory_;
base::ScopedTempDir indexed_db_dir_;
WebString data_dir_;
« no previous file with comments | « no previous file | webkit/support/webkit_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698