| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/service/service_process.h" | 5 #include "chrome/service/service_process.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 // After the IPC server has started we signal that the service process is | 212 // After the IPC server has started we signal that the service process is |
| 213 // ready. | 213 // ready. |
| 214 if (!state->SignalReady(io_thread_->message_loop_proxy(), | 214 if (!state->SignalReady(io_thread_->message_loop_proxy(), |
| 215 NewRunnableMethod(this, &ServiceProcess::Shutdown))) { | 215 NewRunnableMethod(this, &ServiceProcess::Shutdown))) { |
| 216 return false; | 216 return false; |
| 217 } | 217 } |
| 218 | 218 |
| 219 // See if we need to stay running. | 219 // See if we need to stay running. |
| 220 ScheduleShutdownCheck(); | 220 ScheduleShutdownCheck(); |
| 221 command_line_.reset(new CommandLine(command_line)); | |
| 222 | |
| 223 return true; | 221 return true; |
| 224 } | 222 } |
| 225 | 223 |
| 226 bool ServiceProcess::Teardown() { | 224 bool ServiceProcess::Teardown() { |
| 227 service_prefs_.reset(); | 225 service_prefs_.reset(); |
| 228 cloud_print_proxy_.reset(); | 226 cloud_print_proxy_.reset(); |
| 229 | 227 |
| 230 ipc_server_.reset(); | 228 ipc_server_.reset(); |
| 231 // Signal this event before shutting down the service process. That way all | 229 // Signal this event before shutting down the service process. That way all |
| 232 // background threads can cleanup. | 230 // background threads can cleanup. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 OnServiceEnabled(); | 300 OnServiceEnabled(); |
| 303 } | 301 } |
| 304 | 302 |
| 305 void ServiceProcess::OnChromotingHostDisabled() { | 303 void ServiceProcess::OnChromotingHostDisabled() { |
| 306 OnServiceDisabled(); | 304 OnServiceDisabled(); |
| 307 } | 305 } |
| 308 | 306 |
| 309 void ServiceProcess::OnServiceEnabled() { | 307 void ServiceProcess::OnServiceEnabled() { |
| 310 enabled_services_++; | 308 enabled_services_++; |
| 311 if (1 == enabled_services_) { | 309 if (1 == enabled_services_) { |
| 312 ServiceProcessState::GetInstance()->AddToAutoRun(command_line_.get()); | 310 ServiceProcessState::GetInstance()->AddToAutoRun(); |
| 313 } | 311 } |
| 314 } | 312 } |
| 315 | 313 |
| 316 void ServiceProcess::OnServiceDisabled() { | 314 void ServiceProcess::OnServiceDisabled() { |
| 317 DCHECK_NE(enabled_services_, 0); | 315 DCHECK_NE(enabled_services_, 0); |
| 318 enabled_services_--; | 316 enabled_services_--; |
| 319 if (0 == enabled_services_) { | 317 if (0 == enabled_services_) { |
| 320 ServiceProcessState::GetInstance()->RemoveFromAutoRun(); | 318 ServiceProcessState::GetInstance()->RemoveFromAutoRun(); |
| 321 // We will wait for some time to respond to IPCs before shutting down. | 319 // We will wait for some time to respond to IPCs before shutting down. |
| 322 ScheduleShutdownCheck(); | 320 ScheduleShutdownCheck(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 345 } | 343 } |
| 346 | 344 |
| 347 ServiceProcess::~ServiceProcess() { | 345 ServiceProcess::~ServiceProcess() { |
| 348 Teardown(); | 346 Teardown(); |
| 349 g_service_process = NULL; | 347 g_service_process = NULL; |
| 350 } | 348 } |
| 351 | 349 |
| 352 // Disable refcounting for runnable method because it is really not needed | 350 // Disable refcounting for runnable method because it is really not needed |
| 353 // when we post tasks on the main message loop. | 351 // when we post tasks on the main message loop. |
| 354 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); | 352 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); |
| OLD | NEW |