diff options
author | Zeno Albisser <zeno.albisser@digia.com> | 2013-08-15 21:46:11 +0200 |
---|---|---|
committer | Zeno Albisser <zeno.albisser@digia.com> | 2013-08-15 21:46:11 +0200 |
commit | 679147eead574d186ebf3069647b4c23e8ccace6 (patch) | |
tree | fc247a0ac8ff119f7c8550879ebb6d3dd8d1ff69 /chromium/content/browser/browser_process_sub_thread.cc | |
download | qtwebengine-chromium-679147eead574d186ebf3069647b4c23e8ccace6.tar.gz |
Initial import.
Diffstat (limited to 'chromium/content/browser/browser_process_sub_thread.cc')
-rw-r--r-- | chromium/content/browser/browser_process_sub_thread.cc | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/chromium/content/browser/browser_process_sub_thread.cc b/chromium/content/browser/browser_process_sub_thread.cc new file mode 100644 index 00000000000..9a5b78a9edb --- /dev/null +++ b/chromium/content/browser/browser_process_sub_thread.cc @@ -0,0 +1,75 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/browser_process_sub_thread.h" + +#include "base/debug/leak_tracker.h" +#include "base/threading/thread_restrictions.h" +#include "build/build_config.h" +#include "content/browser/browser_child_process_host_impl.h" +#include "content/browser/notification_service_impl.h" +#include "net/url_request/url_fetcher.h" +#include "net/url_request/url_request.h" + +#if defined(OS_WIN) +#include "base/win/scoped_com_initializer.h" +#endif + +namespace content { + +BrowserProcessSubThread::BrowserProcessSubThread(BrowserThread::ID identifier) + : BrowserThreadImpl(identifier) { +} + +BrowserProcessSubThread::~BrowserProcessSubThread() { + Stop(); +} + +void BrowserProcessSubThread::Init() { +#if defined(OS_WIN) + com_initializer_.reset(new base::win::ScopedCOMInitializer()); +#endif + + notification_service_.reset(new NotificationServiceImpl()); + + BrowserThreadImpl::Init(); + + if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { + // Though this thread is called the "IO" thread, it actually just routes + // messages around; it shouldn't be allowed to perform any blocking disk + // I/O. + base::ThreadRestrictions::SetIOAllowed(false); + base::ThreadRestrictions::DisallowWaiting(); + } +} + +void BrowserProcessSubThread::CleanUp() { + if (BrowserThread::CurrentlyOn(BrowserThread::IO)) + IOThreadPreCleanUp(); + + BrowserThreadImpl::CleanUp(); + + notification_service_.reset(); + +#if defined(OS_WIN) + com_initializer_.reset(); +#endif +} + +void BrowserProcessSubThread::IOThreadPreCleanUp() { + // Kill all things that might be holding onto + // net::URLRequest/net::URLRequestContexts. + + // Destroy all URLRequests started by URLFetchers. + net::URLFetcher::CancelAll(); + +#if !defined(OS_IOS) + // If any child processes are still running, terminate them and + // and delete the BrowserChildProcessHost instances to release whatever + // IO thread only resources they are referencing. + BrowserChildProcessHostImpl::TerminateAll(); +#endif // !defined(OS_IOS) +} + +} // namespace content |