OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/browser_process_sub_thread.h" | 5 #include "content/browser/browser_process_sub_thread.h" |
6 | 6 |
7 #include "build/build_config.h" | |
8 #include "content/browser/notification_service_impl.h" | |
9 | |
10 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
11 #include <Objbase.h> | 8 #include <Objbase.h> |
12 #endif | 9 #endif |
13 | 10 |
| 11 #include "base/debug/leak_tracker.h" |
| 12 #include "build/build_config.h" |
| 13 #include "content/browser/browser_child_process_host.h" |
| 14 #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h" |
| 15 #include "content/browser/notification_service_impl.h" |
| 16 #include "content/public/common/url_fetcher.h" |
| 17 #include "net/url_request/url_request.h" |
| 18 |
14 namespace content { | 19 namespace content { |
15 | 20 |
16 BrowserProcessSubThread::BrowserProcessSubThread(BrowserThread::ID identifier) | 21 BrowserProcessSubThread::BrowserProcessSubThread(BrowserThread::ID identifier) |
17 : BrowserThreadImpl(identifier), | 22 : BrowserThreadImpl(identifier), |
18 notification_service_(NULL) { | 23 notification_service_(NULL) { |
19 } | 24 } |
20 | 25 |
21 BrowserProcessSubThread::~BrowserProcessSubThread() { | 26 BrowserProcessSubThread::~BrowserProcessSubThread() { |
22 Stop(); | 27 Stop(); |
23 } | 28 } |
24 | 29 |
25 void BrowserProcessSubThread::Init() { | 30 void BrowserProcessSubThread::Init() { |
26 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
27 // Initializes the COM library on the current thread. | 32 // Initializes the COM library on the current thread. |
28 CoInitialize(NULL); | 33 CoInitialize(NULL); |
29 #endif | 34 #endif |
30 | 35 |
31 notification_service_ = new NotificationServiceImpl; | 36 notification_service_ = new NotificationServiceImpl; |
32 | 37 |
33 BrowserThreadImpl::Init(); | 38 BrowserThreadImpl::Init(); |
34 } | 39 } |
35 | 40 |
36 void BrowserProcessSubThread::CleanUp() { | 41 void BrowserProcessSubThread::CleanUp() { |
| 42 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) |
| 43 IOThreadPreCleanUp(); |
| 44 |
37 BrowserThreadImpl::CleanUp(); | 45 BrowserThreadImpl::CleanUp(); |
38 | 46 |
| 47 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) |
| 48 IOThreadPostCleanUp(); |
| 49 |
39 delete notification_service_; | 50 delete notification_service_; |
40 notification_service_ = NULL; | 51 notification_service_ = NULL; |
41 | 52 |
42 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
43 // Closes the COM library on the current thread. CoInitialize must | 54 // Closes the COM library on the current thread. CoInitialize must |
44 // be balanced by a corresponding call to CoUninitialize. | 55 // be balanced by a corresponding call to CoUninitialize. |
45 CoUninitialize(); | 56 CoUninitialize(); |
46 #endif | 57 #endif |
47 } | 58 } |
48 | 59 |
| 60 void BrowserProcessSubThread::IOThreadPreCleanUp() { |
| 61 // Kill all things that might be holding onto |
| 62 // net::URLRequest/net::URLRequestContexts. |
| 63 |
| 64 // Destroy all URLRequests started by URLFetchers. |
| 65 content::URLFetcher::CancelAll(); |
| 66 |
| 67 IndexedDBKeyUtilityClient::Shutdown(); |
| 68 |
| 69 // If any child processes are still running, terminate them and |
| 70 // and delete the BrowserChildProcessHost instances to release whatever |
| 71 // IO thread only resources they are referencing. |
| 72 BrowserChildProcessHost::TerminateAll(); |
| 73 } |
| 74 |
| 75 void BrowserProcessSubThread::IOThreadPostCleanUp() { |
| 76 // net::URLRequest instances must NOT outlive the IO thread. |
| 77 base::debug::LeakTracker<net::URLRequest>::CheckForLeaks(); |
| 78 } |
| 79 |
49 } // namespace content | 80 } // namespace content |
OLD | NEW |