diff options
author | levin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-01 22:12:18 +0000 |
---|---|---|
committer | levin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-01 22:12:18 +0000 |
commit | 0cef904cec62f1aa0191fd36980c6bd3e1e3e896 (patch) | |
tree | 8d3ec26fc924c85c22ee2958b09c77c8a0a24cfe | |
parent | 3c05547dc9fd08c0ca1089102b41e2d5254fd3e2 (diff) | |
download | chromium_src-0cef904cec62f1aa0191fd36980c6bd3e1e3e896.zip chromium_src-0cef904cec62f1aa0191fd36980c6bd3e1e3e896.tar.gz chromium_src-0cef904cec62f1aa0191fd36980c6bd3e1e3e896.tar.bz2 |
Make Index DB code that accesses WebKit initialize WebKit first.
BUG=None
TEST=InProcessBrowserTest,IDBKeyPathWithoutSandbox
after https://bugs.webkit.org/show_bug.cgi?id=64577 is landed.
Review URL: http://codereview.chromium.org/7483001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94991 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/idbbindingutilities_browsertest.cc | 20 | ||||
-rw-r--r-- | content/utility/utility_thread.cc | 6 | ||||
-rw-r--r-- | content/utility/utility_thread.h | 8 |
3 files changed, 32 insertions, 2 deletions
diff --git a/chrome/browser/idbbindingutilities_browsertest.cc b/chrome/browser/idbbindingutilities_browsertest.cc index c4ffc9b..327b723 100644 --- a/chrome/browser/idbbindingutilities_browsertest.cc +++ b/chrome/browser/idbbindingutilities_browsertest.cc @@ -13,14 +13,34 @@ #include "content/common/utility_messages.h" #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptValue.h" #include "webkit/glue/idb_bindings.h" #include "webkit/glue/web_io_operators.h" +#include "webkit/glue/webkitclient_impl.h" using WebKit::WebSerializedScriptValue; +// Enables calling WebKit::shutdown no matter where a "return" happens. +class ScopedShutdownWebKit { + public: + ScopedShutdownWebKit() { + } + + ~ScopedShutdownWebKit() { + WebKit::shutdown(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(ScopedShutdownWebKit); +}; + // Sanity test, check the function call directly outside the sandbox. TEST(IDBKeyPathWithoutSandbox, Value) { + webkit_glue::WebKitClientImpl webkit_client; + WebKit::initialize(&webkit_client); + ScopedShutdownWebKit shutdown_webkit; + char16 data[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b}; std::vector<WebSerializedScriptValue> serialized_values; serialized_values.push_back( diff --git a/content/utility/utility_thread.cc b/content/utility/utility_thread.cc index 52ad52a..10d49cf 100644 --- a/content/utility/utility_thread.cc +++ b/content/utility/utility_thread.cc @@ -11,8 +11,10 @@ #include "content/common/utility_messages.h" #include "content/utility/content_utility_client.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptValue.h" #include "webkit/glue/idb_bindings.h" +#include "webkit/glue/webkitclient_impl.h" namespace { @@ -25,14 +27,16 @@ void ConvertVector(const SRC& src, DEST* dest) { } // namespace - UtilityThread::UtilityThread() : batch_mode_(false) { ChildProcess::current()->AddRefProcess(); + webkit_client_.reset(new webkit_glue::WebKitClientImpl); + WebKit::initialize(webkit_client_.get()); content::GetContentClient()->utility()->UtilityThreadStarted(); } UtilityThread::~UtilityThread() { + WebKit::shutdown(); } bool UtilityThread::OnControlMessageReceived(const IPC::Message& msg) { diff --git a/content/utility/utility_thread.h b/content/utility/utility_thread.h index 53e637c..a6c0694 100644 --- a/content/utility/utility_thread.h +++ b/content/utility/utility_thread.h @@ -10,12 +10,16 @@ #include <vector> #include "base/basictypes.h" +#include "base/compiler_specific.h" #include "base/string16.h" #include "content/common/child_thread.h" class IndexedDBKey; class SerializedScriptValue; +namespace webkit_glue { +class WebKitClientImpl; +} // This class represents the background thread where the utility task runs. class UtilityThread : public ChildThread { @@ -33,7 +37,7 @@ class UtilityThread : public ChildThread { private: // ChildThread implementation. - virtual bool OnControlMessageReceived(const IPC::Message& msg); + virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE; // IPC message handlers. void OnIDBKeysFromValuesAndKeyPath( @@ -49,6 +53,8 @@ class UtilityThread : public ChildThread { // True when we're running in batch mode. bool batch_mode_; + scoped_ptr<webkit_glue::WebKitClientImpl> webkit_client_; + DISALLOW_COPY_AND_ASSIGN(UtilityThread); }; |