| Index: content/browser/in_process_webkit/webkit_thread.cc
|
| diff --git a/content/browser/in_process_webkit/webkit_thread.cc b/content/browser/in_process_webkit/webkit_thread.cc
|
| index 072a1bb2f83a855dd7aba748738988fe3f35a282..26b8751966bdbd03245511e59221ea9b5e4d9c59 100644
|
| --- a/content/browser/in_process_webkit/webkit_thread.cc
|
| +++ b/content/browser/in_process_webkit/webkit_thread.cc
|
| @@ -13,6 +13,27 @@
|
|
|
| using content::BrowserThread;
|
|
|
| +// Must be private so that we can carefully control its lifetime. Cannot be
|
| +// anonymous as it is forward-declared in the .h.
|
| +class InternalWebKitThread : public content::BrowserThreadImpl {
|
| + public:
|
| + InternalWebKitThread();
|
| + virtual ~InternalWebKitThread();
|
| + // Does the actual initialization and shutdown of WebKit.
|
| + void AsyncInit();
|
| +
|
| + virtual void Init();
|
| + virtual void CleanUp();
|
| +
|
| + private:
|
| + // The WebKitPlatformSupport implementation. Only access on WebKit thread.
|
| + scoped_ptr<BrowserWebKitPlatformSupportImpl> webkit_platform_support_;
|
| +};
|
| +
|
| +// Only used as a parameter in a task sent to itself, so ref-counting
|
| +// is not needed.
|
| +DISABLE_RUNNABLE_METHOD_REFCOUNT(InternalWebKitThread);
|
| +
|
| WebKitThread::WebKitThread() {
|
| }
|
|
|
| @@ -36,17 +57,20 @@ void WebKitThread::Initialize() {
|
| webkit_thread_.reset(new InternalWebKitThread);
|
| bool started = webkit_thread_->Start();
|
| DCHECK(started);
|
| + BrowserThread::PostTask(BrowserThread::WEBKIT, FROM_HERE, NewRunnableMethod(
|
| + webkit_thread_.get(),
|
| + &InternalWebKitThread::AsyncInit));
|
| }
|
|
|
| -WebKitThread::InternalWebKitThread::InternalWebKitThread()
|
| +InternalWebKitThread::InternalWebKitThread()
|
| : content::BrowserThreadImpl(BrowserThread::WEBKIT) {
|
| }
|
|
|
| -WebKitThread::InternalWebKitThread::~InternalWebKitThread() {
|
| +InternalWebKitThread::~InternalWebKitThread() {
|
| Stop();
|
| }
|
|
|
| -void WebKitThread::InternalWebKitThread::Init() {
|
| +void InternalWebKitThread::AsyncInit() {
|
| DCHECK(!webkit_platform_support_.get());
|
| webkit_platform_support_.reset(new BrowserWebKitPlatformSupportImpl);
|
| WebKit::initializeWithoutV8(webkit_platform_support_.get());
|
| @@ -57,12 +81,14 @@ void WebKitThread::InternalWebKitThread::Init() {
|
| // TODO(michaeln): remove this when the following is landed.
|
| // https://bugs.webkit.org/show_bug.cgi?id=61145
|
| WebKit::WebSecurityOrigin::create(GURL("http://chromium.org"));
|
| +}
|
|
|
| - // If possible, post initialization tasks to this thread (rather than doing
|
| - // them now) so we don't block the UI thread any longer than we have to.
|
| +void InternalWebKitThread::Init() {
|
| + // Any work done here blocks the caller; as WebKit::initialize... takes time
|
| + // to complete we do it in the cutom async variant above instead.
|
| }
|
|
|
| -void WebKitThread::InternalWebKitThread::CleanUp() {
|
| +void InternalWebKitThread::CleanUp() {
|
| DCHECK(webkit_platform_support_.get());
|
| WebKit::shutdown();
|
| }
|
|
|