blob: 5aadda5ad1edc4c61595f24326eeee25b90209f2 [file] [log] [blame]
[email protected]ef2bf422012-05-11 03:27:091// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]0ac83682010-01-22 17:46:272// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]b0f146f2011-09-15 22:14:255#include "content/browser/browser_process_sub_thread.h"
6
[email protected]af669932012-01-17 19:26:587#include "base/debug/leak_tracker.h"
[email protected]3a7b66d2012-04-26 16:34:168#include "base/threading/thread_restrictions.h"
reveman84c4caf92015-05-01 20:10:229#include "base/trace_event/memory_dump_manager.h"
[email protected]af669932012-01-17 19:26:5810#include "build/build_config.h"
[email protected]4c01d4992012-01-23 23:33:0111#include "content/browser/browser_child_process_host_impl.h"
reveman84c4caf92015-05-01 20:10:2212#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
[email protected]af669932012-01-17 19:26:5813#include "content/browser/notification_service_impl.h"
[email protected]3dc1bc42012-06-19 08:20:5314#include "net/url_request/url_fetcher.h"
[email protected]af669932012-01-17 19:26:5815#include "net/url_request/url_request.h"
16
[email protected]451fd902012-10-03 17:14:4817#if defined(OS_WIN)
18#include "base/win/scoped_com_initializer.h"
19#endif
20
[email protected]c38831a12011-10-28 12:44:4921namespace content {
22
[email protected]d04e7662010-10-10 22:24:4823BrowserProcessSubThread::BrowserProcessSubThread(BrowserThread::ID identifier)
[email protected]435756b2012-10-01 21:19:3624 : BrowserThreadImpl(identifier) {
[email protected]5abe6302011-12-20 23:44:3225}
[email protected]0ac83682010-01-22 17:46:2726
27BrowserProcessSubThread::~BrowserProcessSubThread() {
[email protected]0ac83682010-01-22 17:46:2728 Stop();
29}
30
31void BrowserProcessSubThread::Init() {
32#if defined(OS_WIN)
[email protected]451fd902012-10-03 17:14:4833 com_initializer_.reset(new base::win::ScopedCOMInitializer());
[email protected]0ac83682010-01-22 17:46:2734#endif
35
[email protected]435756b2012-10-01 21:19:3636 notification_service_.reset(new NotificationServiceImpl());
[email protected]2e5b60a22011-11-28 15:56:4137
38 BrowserThreadImpl::Init();
[email protected]3a7b66d2012-04-26 16:34:1639
40 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) {
41 // Though this thread is called the "IO" thread, it actually just routes
42 // messages around; it shouldn't be allowed to perform any blocking disk
43 // I/O.
44 base::ThreadRestrictions::SetIOAllowed(false);
45 base::ThreadRestrictions::DisallowWaiting();
46 }
[email protected]0ac83682010-01-22 17:46:2747}
48
[email protected]569c7602011-03-03 20:40:3249void BrowserProcessSubThread::CleanUp() {
[email protected]af669932012-01-17 19:26:5850 if (BrowserThread::CurrentlyOn(BrowserThread::IO))
51 IOThreadPreCleanUp();
52
[email protected]2e5b60a22011-11-28 15:56:4153 BrowserThreadImpl::CleanUp();
54
[email protected]435756b2012-10-01 21:19:3655 notification_service_.reset();
[email protected]0ac83682010-01-22 17:46:2756
57#if defined(OS_WIN)
[email protected]451fd902012-10-03 17:14:4858 com_initializer_.reset();
[email protected]0ac83682010-01-22 17:46:2759#endif
60}
[email protected]c38831a12011-10-28 12:44:4961
[email protected]af669932012-01-17 19:26:5862void BrowserProcessSubThread::IOThreadPreCleanUp() {
63 // Kill all things that might be holding onto
64 // net::URLRequest/net::URLRequestContexts.
65
66 // Destroy all URLRequests started by URLFetchers.
[email protected]3dc1bc42012-06-19 08:20:5367 net::URLFetcher::CancelAll();
[email protected]af669932012-01-17 19:26:5868
[email protected]af669932012-01-17 19:26:5869 // 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.
[email protected]4c01d4992012-01-23 23:33:0172 BrowserChildProcessHostImpl::TerminateAll();
reveman84c4caf92015-05-01 20:10:2273
74 // Unregister GpuMemoryBuffer dump provider before IO thread is shut down.
75 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
76 BrowserGpuMemoryBufferManager::current());
[email protected]af669932012-01-17 19:26:5877}
78
[email protected]c38831a12011-10-28 12:44:4979} // namespace content