| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/in_process_webkit/webkit_thread.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "content/browser/in_process_webkit/browser_webkitplatformsupport_impl.h
" | |
| 9 #include "content/public/common/content_switches.h" | |
| 10 #include "third_party/WebKit/public/web/WebKit.h" | |
| 11 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | |
| 12 #include "webkit/glue/webkit_glue.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 WebKitThread::WebKitThread() { | |
| 17 } | |
| 18 | |
| 19 // This happens on the UI thread after the IO thread has been shut down. | |
| 20 WebKitThread::~WebKitThread() { | |
| 21 // We can't just check CurrentlyOn(BrowserThread::UI) because in unit tests, | |
| 22 // MessageLoop::Current is sometimes NULL and other times valid and there's | |
| 23 // no BrowserThread object. Can't check that CurrentlyOn is not IO since | |
| 24 // some unit tests set that BrowserThread for other checks. | |
| 25 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 26 } | |
| 27 | |
| 28 void WebKitThread::Initialize() { | |
| 29 DCHECK(!webkit_thread_.get()); | |
| 30 | |
| 31 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { | |
| 32 // TODO(joth): As this cannot work in single process mode use of the | |
| 33 // webkit thread is deprecated; see http://crbug.com/106839. | |
| 34 return; | |
| 35 } | |
| 36 | |
| 37 webkit_thread_.reset(new InternalWebKitThread); | |
| 38 bool started = webkit_thread_->Start(); | |
| 39 DCHECK(started); | |
| 40 } | |
| 41 | |
| 42 WebKitThread::InternalWebKitThread::InternalWebKitThread() | |
| 43 : BrowserThreadImpl(BrowserThread::WEBKIT_DEPRECATED) { | |
| 44 } | |
| 45 | |
| 46 WebKitThread::InternalWebKitThread::~InternalWebKitThread() { | |
| 47 Stop(); | |
| 48 } | |
| 49 | |
| 50 void WebKitThread::InternalWebKitThread::Init() { | |
| 51 DCHECK(!webkit_platform_support_.get()); | |
| 52 webkit_platform_support_.reset(new BrowserWebKitPlatformSupportImpl); | |
| 53 WebKit::initializeWithoutV8(webkit_platform_support_.get()); | |
| 54 webkit_glue::EnableWebCoreLogChannels( | |
| 55 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
| 56 switches::kWebCoreLogChannels)); | |
| 57 // Exercise WebSecurityOrigin to get its underlying statics initialized. | |
| 58 // TODO(michaeln): remove this when the following is landed. | |
| 59 // https://bugs.webkit.org/show_bug.cgi?id=61145 | |
| 60 WebKit::WebSecurityOrigin::create(GURL("http://chromium.org")); | |
| 61 | |
| 62 // If possible, post initialization tasks to this thread (rather than doing | |
| 63 // them now) so we don't block the UI thread any longer than we have to. | |
| 64 } | |
| 65 | |
| 66 void WebKitThread::InternalWebKitThread::CleanUp() { | |
| 67 DCHECK(webkit_platform_support_.get()); | |
| 68 WebKit::shutdownWithoutV8(); | |
| 69 // Delete BrowserWebKitPlatformSupportImpl now while on the same thread that | |
| 70 // constructed it. (This prevents the WebKit shared timer from being destroyed | |
| 71 // on a different thread than the one using it.) | |
| 72 webkit_platform_support_.reset(); | |
| 73 } | |
| 74 | |
| 75 } // namespace content | |
| OLD | NEW |