OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "chrome/browser/in_process_webkit/webkit_thread.h" | 5 #include "chrome/browser/in_process_webkit/webkit_thread.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/in_process_webkit/browser_webkitclient_impl.h" | 8 #include "chrome/browser/in_process_webkit/browser_webkitclient_impl.h" |
9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "webkit/api/public/WebKit.h" | 10 #include "webkit/api/public/WebKit.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 if (webkit_thread_.get()) | 28 if (webkit_thread_.get()) |
29 return; | 29 return; |
30 InitializeThread(); | 30 InitializeThread(); |
31 } | 31 } |
32 | 32 |
33 WebKitThread::InternalWebKitThread::InternalWebKitThread() | 33 WebKitThread::InternalWebKitThread::InternalWebKitThread() |
34 : ChromeThread(ChromeThread::WEBKIT) { | 34 : ChromeThread(ChromeThread::WEBKIT) { |
35 } | 35 } |
36 | 36 |
37 WebKitThread::InternalWebKitThread::~InternalWebKitThread() { | 37 WebKitThread::InternalWebKitThread::~InternalWebKitThread() { |
| 38 Stop(); |
38 } | 39 } |
39 | 40 |
40 void WebKitThread::InternalWebKitThread::Init() { | 41 void WebKitThread::InternalWebKitThread::Init() { |
41 DCHECK(!webkit_client_.get()); | 42 DCHECK(!webkit_client_.get()); |
42 webkit_client_.reset(new BrowserWebKitClientImpl); | 43 webkit_client_.reset(new BrowserWebKitClientImpl); |
43 WebKit::initialize(webkit_client_.get()); | 44 WebKit::initialize(webkit_client_.get()); |
44 // If possible, post initialization tasks to this thread (rather than doing | 45 // If possible, post initialization tasks to this thread (rather than doing |
45 // them now) so we don't block the IO thread any longer than we have to. | 46 // them now) so we don't block the IO thread any longer than we have to. |
46 } | 47 } |
47 | 48 |
48 void WebKitThread::InternalWebKitThread::CleanUp() { | 49 void WebKitThread::InternalWebKitThread::CleanUp() { |
49 DCHECK(webkit_client_.get()); | 50 DCHECK(webkit_client_.get()); |
50 WebKit::shutdown(); | 51 WebKit::shutdown(); |
51 } | 52 } |
52 | 53 |
53 MessageLoop* WebKitThread::InitializeThread() { | 54 MessageLoop* WebKitThread::InitializeThread() { |
54 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | 55 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) |
55 return NULL; | 56 return NULL; |
56 | 57 |
57 DCHECK(!webkit_thread_.get()); | 58 DCHECK(!webkit_thread_.get()); |
58 webkit_thread_.reset(new InternalWebKitThread); | 59 webkit_thread_.reset(new InternalWebKitThread); |
59 bool started = webkit_thread_->Start(); | 60 bool started = webkit_thread_->Start(); |
60 DCHECK(started); | 61 DCHECK(started); |
61 return webkit_thread_->message_loop(); | 62 return webkit_thread_->message_loop(); |
62 } | 63 } |
OLD | NEW |