Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / browser_process_sub_thread.cc
blob9a5b78a9edb0096cf39c4b9160294ba85379b82e
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"
15 #if defined(OS_WIN)
16 #include "base/win/scoped_com_initializer.h"
17 #endif
19 namespace content {
21 BrowserProcessSubThread::BrowserProcessSubThread(BrowserThread::ID identifier)
22 : BrowserThreadImpl(identifier) {
25 BrowserProcessSubThread::~BrowserProcessSubThread() {
26 Stop();
29 void BrowserProcessSubThread::Init() {
30 #if defined(OS_WIN)
31 com_initializer_.reset(new base::win::ScopedCOMInitializer());
32 #endif
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
41 // I/O.
42 base::ThreadRestrictions::SetIOAllowed(false);
43 base::ThreadRestrictions::DisallowWaiting();
47 void BrowserProcessSubThread::CleanUp() {
48 if (BrowserThread::CurrentlyOn(BrowserThread::IO))
49 IOThreadPreCleanUp();
51 BrowserThreadImpl::CleanUp();
53 notification_service_.reset();
55 #if defined(OS_WIN)
56 com_initializer_.reset();
57 #endif
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();
67 #if !defined(OS_IOS)
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