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.
5 #include "content/browser/browser_process_sub_thread.h"
7 #include "base/debug/leak_tracker.h"
8 #include "base/threading/thread_restrictions.h"
9 #include "build/build_config.h"
10 #include "content/browser/browser_child_process_host_impl.h"
11 #include "content/browser/notification_service_impl.h"
12 #include "net/url_request/url_fetcher.h"
13 #include "net/url_request/url_request.h"
16 #include "base/win/scoped_com_initializer.h"
21 BrowserProcessSubThread::BrowserProcessSubThread(BrowserThread::ID identifier
)
22 : BrowserThreadImpl(identifier
) {
25 BrowserProcessSubThread::~BrowserProcessSubThread() {
29 void BrowserProcessSubThread::Init() {
31 com_initializer_
.reset(new base::win::ScopedCOMInitializer());
34 notification_service_
.reset(new NotificationServiceImpl());
36 BrowserThreadImpl::Init();
38 if (BrowserThread::CurrentlyOn(BrowserThread::IO
)) {
39 // Though this thread is called the "IO" thread, it actually just routes
40 // messages around; it shouldn't be allowed to perform any blocking disk
42 base::ThreadRestrictions::SetIOAllowed(false);
43 base::ThreadRestrictions::DisallowWaiting();
47 void BrowserProcessSubThread::CleanUp() {
48 if (BrowserThread::CurrentlyOn(BrowserThread::IO
))
51 BrowserThreadImpl::CleanUp();
53 notification_service_
.reset();
56 com_initializer_
.reset();
60 void BrowserProcessSubThread::IOThreadPreCleanUp() {
61 // Kill all things that might be holding onto
62 // net::URLRequest/net::URLRequestContexts.
64 // Destroy all URLRequests started by URLFetchers.
65 net::URLFetcher::CancelAll();
68 // If any child processes are still running, terminate them and
69 // and delete the BrowserChildProcessHost instances to release whatever
70 // IO thread only resources they are referencing.
71 BrowserChildProcessHostImpl::TerminateAll();
72 #endif // !defined(OS_IOS)
75 } // namespace content