summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgavinp@chromium.org <gavinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-05 19:44:59 +0000
committergavinp@chromium.org <gavinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-05 19:44:59 +0000
commit185c0345eceb16301eac0b2a129382517f6acf04 (patch)
tree7d43aced08060183776f57d47712ea41e8fa820a
parent85218fc6b6df32eb654c0c8a3d0385286e117fa5 (diff)
downloadchromium_src-185c0345eceb16301eac0b2a129382517f6acf04.zip
chromium_src-185c0345eceb16301eac0b2a129382517f6acf04.tar.gz
chromium_src-185c0345eceb16301eac0b2a129382517f6acf04.tar.bz2
Revert 180583
> 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 TBR=darin@chromium.org,mpcomplete@chromium.org BUG=174408 Review URL: https://codereview.chromium.org/12211018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180758 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/support/test_webidbfactory.cc64
-rw-r--r--webkit/support/test_webidbfactory.h53
-rw-r--r--webkit/support/test_webkit_platform_support.cc67
-rw-r--r--webkit/support/test_webkit_platform_support.h3
-rw-r--r--webkit/support/webkit_support.cc17
-rw-r--r--webkit/support/webkit_support.gypi2
-rw-r--r--webkit/support/webkit_support.h1
7 files changed, 84 insertions, 123 deletions
diff --git a/webkit/support/test_webidbfactory.cc b/webkit/support/test_webidbfactory.cc
deleted file mode 100644
index faabfa5..0000000
--- a/webkit/support/test_webidbfactory.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-// 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;
-}
diff --git a/webkit/support/test_webidbfactory.h b/webkit/support/test_webidbfactory.h
deleted file mode 100644
index 57da5c8..0000000
--- a/webkit/support/test_webidbfactory.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// 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();
-
- // 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_;
- WebKit::WebString data_dir_;
-};
-
-#endif // WEBKIT_SUPPORT_TEST_WEBIDBFACTORY_H_
diff --git a/webkit/support/test_webkit_platform_support.cc b/webkit/support/test_webkit_platform_support.cc
index e6bf5ee..750b32b 100644
--- a/webkit/support/test_webkit_platform_support.cc
+++ b/webkit/support/test_webkit_platform_support.cc
@@ -341,6 +341,73 @@ 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() {
+ // 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());
+
+ // 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);
+ }
+
+ virtual void open(const WebString& name,
+ long long version,
+ long long transaction_id,
+ WebKit::WebIDBCallbacks* callbacks,
+ WebKit::WebIDBDatabaseCallbacks* databaseCallbacks,
+ const WebKit::WebSecurityOrigin& origin,
+ WebKit::WebFrame* frame,
+ const WebString& dataDir) {
+ EnsureFactory();
+ factory_->open(name, version, transaction_id, callbacks,
+ databaseCallbacks, 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) {
+ 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_;
+};
+
+WebKit::WebIDBFactory* TestWebKitPlatformSupport::idbFactory() {
+ return new TestWebIDBFactory();
+}
+
#if defined(OS_WIN) || defined(OS_MACOSX)
void TestWebKitPlatformSupport::SetThemeEngine(WebKit::WebThemeEngine* engine) {
active_theme_engine_ = engine ?
diff --git a/webkit/support/test_webkit_platform_support.h b/webkit/support/test_webkit_platform_support.h
index bb92e61..ec43ce5 100644
--- a/webkit/support/test_webkit_platform_support.h
+++ b/webkit/support/test_webkit_platform_support.h
@@ -8,6 +8,7 @@
#include "base/compiler_specific.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGamepads.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h"
#include "webkit/glue/webfileutilities_impl.h"
#include "webkit/glue/webkitplatformsupport_impl.h"
#include "webkit/support/simple_database_system.h"
@@ -74,6 +75,8 @@ class TestWebKitPlatformSupport :
virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
const WebKit::WebString& path, unsigned quota);
+ virtual WebKit::WebIDBFactory* idbFactory();
+
#if defined(OS_WIN) || defined(OS_MACOSX)
void SetThemeEngine(WebKit::WebThemeEngine* engine);
virtual WebKit::WebThemeEngine *themeEngine();
diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc
index 2274835..66b9831 100644
--- a/webkit/support/webkit_support.cc
+++ b/webkit/support/webkit_support.cc
@@ -72,7 +72,6 @@
#include "webkit/plugins/webplugininfo.h"
#include "webkit/support/platform_support.h"
#include "webkit/support/simple_database_system.h"
-#include "webkit/support/test_webidbfactory.h"
#include "webkit/support/test_webkit_platform_support.h"
#include "webkit/support/test_webplugin_page_delegate.h"
#include "webkit/tools/test_shell/simple_appcache_system.h"
@@ -172,8 +171,8 @@ class TestEnvironment {
new TestWebKitPlatformSupport(unit_test_mode,
shadow_platform_delegate));
- idb_factory_.reset(new TestWebIDBFactory());
- WebKit::setIDBFactory(idb_factory_.get());
+ // TODO(darin): Uncomment this once DRT calls ResetTestEnvironment().
+ //WebKit::setIDBFactory(webkit_platform_support_->idbFactory());
#if defined(OS_ANDROID)
// Make sure we have enough decoding resources for layout tests.
@@ -189,6 +188,13 @@ class TestEnvironment {
SimpleResourceLoaderBridge::Shutdown();
}
+ void Reset() {
+#if defined(OS_ANDROID)
+ media_player_manager_->ReleaseMediaResources();
+#endif
+ WebKit::setIDBFactory(webkit_platform_support_->idbFactory());
+ }
+
TestWebKitPlatformSupport* webkit_platform_support() const {
return webkit_platform_support_.get();
}
@@ -232,7 +238,6 @@ class TestEnvironment {
scoped_ptr<base::AtExitManager> at_exit_manager_;
scoped_ptr<MessageLoopType> main_message_loop_;
scoped_ptr<TestWebKitPlatformSupport> webkit_platform_support_;
- scoped_ptr<TestWebIDBFactory> idb_factory_;
#if defined(OS_ANDROID)
base::FilePath mock_current_directory_;
@@ -392,6 +397,10 @@ void TearDownTestEnvironment() {
logging::CloseLogFile();
}
+void ResetTestEnvironment() {
+ test_environment->Reset();
+}
+
WebKit::WebKitPlatformSupport* GetWebKitPlatformSupport() {
DCHECK(test_environment);
return test_environment->webkit_platform_support();
diff --git a/webkit/support/webkit_support.gypi b/webkit/support/webkit_support.gypi
index 759bc67..68587b9 100644
--- a/webkit/support/webkit_support.gypi
+++ b/webkit/support/webkit_support.gypi
@@ -54,8 +54,6 @@
'test_stream_texture_factory_android.h',
'test_webkit_platform_support.cc',
'test_webkit_platform_support.h',
- 'test_webidbfactory.cc',
- 'test_webidbfactory.h',
'test_webmessageportchannel.cc',
'test_webmessageportchannel.h',
'test_webplugin_page_delegate.cc',
diff --git a/webkit/support/webkit_support.h b/webkit/support/webkit_support.h
index 1b02567..5ff2558 100644
--- a/webkit/support/webkit_support.h
+++ b/webkit/support/webkit_support.h
@@ -76,6 +76,7 @@ void SetUpTestEnvironment(WebKit::Platform* shadow_platform_delegate);
void SetUpTestEnvironmentForUnitTests(
WebKit::Platform* shadow_platform_delegate);
void TearDownTestEnvironment();
+void ResetTestEnvironment();
// Returns a pointer to a WebKitPlatformSupport implementation for
// DumpRenderTree. Needs to call SetUpTestEnvironment() before this.