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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <Objbase.h> | 8 #include <Objbase.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include "base/debug/leak_tracker.h" | 11 #include "base/debug/leak_tracker.h" |
| 12 #include "base/threading/thread_restrictions.h" |
12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
13 #include "content/browser/browser_child_process_host_impl.h" | 14 #include "content/browser/browser_child_process_host_impl.h" |
14 #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h" | 15 #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h" |
15 #include "content/browser/notification_service_impl.h" | 16 #include "content/browser/notification_service_impl.h" |
16 #include "content/public/common/url_fetcher.h" | 17 #include "content/public/common/url_fetcher.h" |
17 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 BrowserProcessSubThread::BrowserProcessSubThread(BrowserThread::ID identifier) | 22 BrowserProcessSubThread::BrowserProcessSubThread(BrowserThread::ID identifier) |
22 : BrowserThreadImpl(identifier), | 23 : BrowserThreadImpl(identifier), |
23 notification_service_(NULL) { | 24 notification_service_(NULL) { |
24 } | 25 } |
25 | 26 |
26 BrowserProcessSubThread::~BrowserProcessSubThread() { | 27 BrowserProcessSubThread::~BrowserProcessSubThread() { |
27 Stop(); | 28 Stop(); |
28 } | 29 } |
29 | 30 |
30 void BrowserProcessSubThread::Init() { | 31 void BrowserProcessSubThread::Init() { |
31 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
32 // Initializes the COM library on the current thread. | 33 // Initializes the COM library on the current thread. |
33 CoInitialize(NULL); | 34 CoInitialize(NULL); |
34 #endif | 35 #endif |
35 | 36 |
36 notification_service_ = new NotificationServiceImpl; | 37 notification_service_ = new NotificationServiceImpl; |
37 | 38 |
38 BrowserThreadImpl::Init(); | 39 BrowserThreadImpl::Init(); |
| 40 |
| 41 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 42 // Though this thread is called the "IO" thread, it actually just routes |
| 43 // messages around; it shouldn't be allowed to perform any blocking disk |
| 44 // I/O. |
| 45 base::ThreadRestrictions::SetIOAllowed(false); |
| 46 base::ThreadRestrictions::DisallowWaiting(); |
| 47 } |
39 } | 48 } |
40 | 49 |
41 void BrowserProcessSubThread::CleanUp() { | 50 void BrowserProcessSubThread::CleanUp() { |
42 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) | 51 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) |
43 IOThreadPreCleanUp(); | 52 IOThreadPreCleanUp(); |
44 | 53 |
45 BrowserThreadImpl::CleanUp(); | 54 BrowserThreadImpl::CleanUp(); |
46 | 55 |
47 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) | 56 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) |
48 IOThreadPostCleanUp(); | 57 IOThreadPostCleanUp(); |
(...skipping 22 matching lines...) Expand all Loading... |
71 // IO thread only resources they are referencing. | 80 // IO thread only resources they are referencing. |
72 BrowserChildProcessHostImpl::TerminateAll(); | 81 BrowserChildProcessHostImpl::TerminateAll(); |
73 } | 82 } |
74 | 83 |
75 void BrowserProcessSubThread::IOThreadPostCleanUp() { | 84 void BrowserProcessSubThread::IOThreadPostCleanUp() { |
76 // net::URLRequest instances must NOT outlive the IO thread. | 85 // net::URLRequest instances must NOT outlive the IO thread. |
77 base::debug::LeakTracker<net::URLRequest>::CheckForLeaks(); | 86 base::debug::LeakTracker<net::URLRequest>::CheckForLeaks(); |
78 } | 87 } |
79 | 88 |
80 } // namespace content | 89 } // namespace content |
OLD | NEW |