| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 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. |
| 4 |
| 5 #include "chrome/service/service_process.h" |
| 6 |
| 7 #include "chrome/service/cloud_print/cloud_print_proxy.h" |
| 8 |
| 9 ServiceProcess* g_service_process = NULL; |
| 10 |
| 11 ServiceProcess::ServiceProcess() { |
| 12 DCHECK(!g_service_process); |
| 13 g_service_process = this; |
| 14 } |
| 15 |
| 16 bool ServiceProcess::Initialize() { |
| 17 base::Thread::Options options; |
| 18 options.message_loop_type = MessageLoop::TYPE_IO; |
| 19 io_thread_.reset(new base::Thread("ServiceProcess_IO")); |
| 20 file_thread_.reset(new base::Thread("ServiceProcess_File")); |
| 21 if (!io_thread_->StartWithOptions(options) || |
| 22 !file_thread_->StartWithOptions(options)) { |
| 23 NOTREACHED(); |
| 24 Teardown(); |
| 25 return false; |
| 26 } |
| 27 return true; |
| 28 } |
| 29 |
| 30 bool ServiceProcess::Teardown() { |
| 31 io_thread_.reset(); |
| 32 file_thread_.reset(); |
| 33 return true; |
| 34 } |
| 35 |
| 36 CloudPrintProxy* ServiceProcess::cloud_print_proxy() { |
| 37 if (!cloud_print_proxy_.get()) { |
| 38 cloud_print_proxy_.reset(new CloudPrintProxy()); |
| 39 cloud_print_proxy_->Initialize(); |
| 40 } |
| 41 return cloud_print_proxy_.get(); |
| 42 } |
| 43 |
| 44 ServiceProcess::~ServiceProcess() { |
| 45 Teardown(); |
| 46 g_service_process = NULL; |
| 47 } |
| 48 |
| OLD | NEW |