| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/browser_process_impl.h" | 5 #include "chrome/browser/browser_process_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/thread.h" | 9 #include "base/thread.h" |
| 10 #include "base/waitable_event.h" | 10 #include "base/waitable_event.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 // Cancel pending requests and prevent new requests. | 165 // Cancel pending requests and prevent new requests. |
| 166 resource_dispatcher_host()->Shutdown(); | 166 resource_dispatcher_host()->Shutdown(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 // Shutdown DNS prefetching now to ensure that network stack objects | 169 // Shutdown DNS prefetching now to ensure that network stack objects |
| 170 // living on the IO thread get destroyed before the IO thread goes away. | 170 // living on the IO thread get destroyed before the IO thread goes away. |
| 171 io_thread_->message_loop()->PostTask(FROM_HERE, | 171 io_thread_->message_loop()->PostTask(FROM_HERE, |
| 172 NewRunnableFunction(chrome_browser_net::EnsureDnsPrefetchShutdown)); | 172 NewRunnableFunction(chrome_browser_net::EnsureDnsPrefetchShutdown)); |
| 173 | 173 |
| 174 #if defined(OS_LINUX) |
| 175 // The IO thread must outlive the BACKGROUND_X11 thread. |
| 176 background_x11_thread_.reset(); |
| 177 #endif |
| 178 |
| 174 // Need to stop io_thread_ before resource_dispatcher_host_, since | 179 // Need to stop io_thread_ before resource_dispatcher_host_, since |
| 175 // io_thread_ may still deref ResourceDispatcherHost and handle resource | 180 // io_thread_ may still deref ResourceDispatcherHost and handle resource |
| 176 // request before going away. | 181 // request before going away. |
| 177 io_thread_.reset(); | 182 io_thread_.reset(); |
| 178 | 183 |
| 179 // Clean up state that lives on the file_thread_ before it goes away. | 184 // Clean up state that lives on the file_thread_ before it goes away. |
| 180 if (resource_dispatcher_host_.get()) { | 185 if (resource_dispatcher_host_.get()) { |
| 181 resource_dispatcher_host()->download_file_manager()->Shutdown(); | 186 resource_dispatcher_host()->download_file_manager()->Shutdown(); |
| 182 resource_dispatcher_host()->save_file_manager()->Shutdown(); | 187 resource_dispatcher_host()->save_file_manager()->Shutdown(); |
| 183 } | 188 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 void BrowserProcessImpl::CreateIOThread() { | 282 void BrowserProcessImpl::CreateIOThread() { |
| 278 DCHECK(!created_io_thread_ && io_thread_.get() == NULL); | 283 DCHECK(!created_io_thread_ && io_thread_.get() == NULL); |
| 279 created_io_thread_ = true; | 284 created_io_thread_ = true; |
| 280 | 285 |
| 281 // Prior to starting the io thread, we create the plugin service as | 286 // Prior to starting the io thread, we create the plugin service as |
| 282 // it is predominantly used from the io thread, but must be created | 287 // it is predominantly used from the io thread, but must be created |
| 283 // on the main thread. The service ctor is inexpensive and does not | 288 // on the main thread. The service ctor is inexpensive and does not |
| 284 // invoke the io_thread() accessor. | 289 // invoke the io_thread() accessor. |
| 285 PluginService::GetInstance(); | 290 PluginService::GetInstance(); |
| 286 | 291 |
| 292 #if defined(OS_LINUX) |
| 293 // The lifetime of the BACKGROUND_X11 thread is a subset of the IO thread so |
| 294 // we start it now. |
| 295 scoped_ptr<base::Thread> background_x11_thread( |
| 296 new BrowserProcessSubThread(ChromeThread::BACKGROUND_X11)); |
| 297 if (!background_x11_thread->Start()) |
| 298 return; |
| 299 background_x11_thread_.swap(background_x11_thread); |
| 300 #endif |
| 301 |
| 287 scoped_ptr<base::Thread> thread( | 302 scoped_ptr<base::Thread> thread( |
| 288 new BrowserProcessSubThread(ChromeThread::IO)); | 303 new BrowserProcessSubThread(ChromeThread::IO)); |
| 289 base::Thread::Options options; | 304 base::Thread::Options options; |
| 290 options.message_loop_type = MessageLoop::TYPE_IO; | 305 options.message_loop_type = MessageLoop::TYPE_IO; |
| 291 if (!thread->StartWithOptions(options)) | 306 if (!thread->StartWithOptions(options)) |
| 292 return; | 307 return; |
| 293 io_thread_.swap(thread); | 308 io_thread_.swap(thread); |
| 294 } | 309 } |
| 295 | 310 |
| 296 void BrowserProcessImpl::CreateFileThread() { | 311 void BrowserProcessImpl::CreateFileThread() { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 #else | 390 #else |
| 376 // TODO(port): remove this completely, it has no business being here. | 391 // TODO(port): remove this completely, it has no business being here. |
| 377 #endif | 392 #endif |
| 378 } | 393 } |
| 379 | 394 |
| 380 void BrowserProcessImpl::CreateGoogleURLTracker() { | 395 void BrowserProcessImpl::CreateGoogleURLTracker() { |
| 381 DCHECK(google_url_tracker_.get() == NULL); | 396 DCHECK(google_url_tracker_.get() == NULL); |
| 382 scoped_ptr<GoogleURLTracker> google_url_tracker(new GoogleURLTracker); | 397 scoped_ptr<GoogleURLTracker> google_url_tracker(new GoogleURLTracker); |
| 383 google_url_tracker_.swap(google_url_tracker); | 398 google_url_tracker_.swap(google_url_tracker); |
| 384 } | 399 } |
| OLD | NEW |