1ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved. 2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be 3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file. 4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 5c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "build/build_config.h" 6ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/browser/browser_process_sub_thread.h" 7ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "content/common/notification_service.h" 8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#if defined(OS_WIN) 10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <Objbase.h> 11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif 12c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 13731df977c0511bca2206b5f333555b1205ff1f43Iain MerrickBrowserProcessSubThread::BrowserProcessSubThread(BrowserThread::ID identifier) 14731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick : BrowserThread(identifier) {} 15c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 16c407dc5cd9bdc5668497f21b26b09d988ab439deBen MurdochBrowserProcessSubThread::~BrowserProcessSubThread() { 17c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // We cannot rely on our base class to stop the thread since we want our 18c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // CleanUp function to run. 19c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch Stop(); 20c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 21c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 22c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid BrowserProcessSubThread::Init() { 23c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#if defined(OS_WIN) 24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Initializes the COM library on the current thread. 25c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch CoInitialize(NULL); 26c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif 27c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 28c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch notification_service_ = new NotificationService; 29c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 30c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 31dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenvoid BrowserProcessSubThread::CleanUp() { 32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch delete notification_service_; 33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch notification_service_ = NULL; 34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 35c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#if defined(OS_WIN) 36c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Closes the COM library on the current thread. CoInitialize must 37c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // be balanced by a corresponding call to CoUninitialize. 38c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch CoUninitialize(); 39c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif 40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 41