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 #include <syslog.h> | |
Mark Mentovai
2011/03/11 20:13:52
?
| |
8 | 9 |
9 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/environment.h" | 12 #include "base/environment.h" |
12 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
13 #include "base/path_service.h" | 14 #include "base/path_service.h" |
14 #include "base/singleton.h" | 15 #include "base/singleton.h" |
15 #include "base/string16.h" | 16 #include "base/string16.h" |
16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 ServiceProcess::GetServiceURLRequestContextGetter() { | 314 ServiceProcess::GetServiceURLRequestContextGetter() { |
314 DCHECK(request_context_getter_.get()); | 315 DCHECK(request_context_getter_.get()); |
315 return request_context_getter_.get(); | 316 return request_context_getter_.get(); |
316 } | 317 } |
317 | 318 |
318 void ServiceProcess::OnServiceEnabled() { | 319 void ServiceProcess::OnServiceEnabled() { |
319 enabled_services_++; | 320 enabled_services_++; |
320 if ((1 == enabled_services_) && | 321 if ((1 == enabled_services_) && |
321 !CommandLine::ForCurrentProcess()->HasSwitch( | 322 !CommandLine::ForCurrentProcess()->HasSwitch( |
322 switches::kNoServiceAutorun)) { | 323 switches::kNoServiceAutorun)) { |
323 ServiceProcessState::GetInstance()->AddToAutoRun(); | 324 if (!ServiceProcessState::GetInstance()->AddToAutoRun()) { |
325 // TODO(scottbyer/sanjeevr/dmaclach): Handle error condition | |
326 LOG(ERROR) << "Unable to AddToAutoRun"; | |
327 } | |
324 } | 328 } |
325 } | 329 } |
326 | 330 |
327 void ServiceProcess::OnServiceDisabled() { | 331 void ServiceProcess::OnServiceDisabled() { |
328 DCHECK_NE(enabled_services_, 0); | 332 DCHECK_NE(enabled_services_, 0); |
329 enabled_services_--; | 333 enabled_services_--; |
330 if (0 == enabled_services_) { | 334 if (0 == enabled_services_) { |
331 ServiceProcessState::GetInstance()->RemoveFromAutoRun(); | 335 if (!ServiceProcessState::GetInstance()->RemoveFromAutoRun()) { |
336 // TODO(scottbyer/sanjeevr/dmaclach): Handle error condition | |
337 LOG(ERROR) << "Unable to RemoveFromAutoRun"; | |
338 } | |
332 // We will wait for some time to respond to IPCs before shutting down. | 339 // We will wait for some time to respond to IPCs before shutting down. |
333 ScheduleShutdownCheck(); | 340 ScheduleShutdownCheck(); |
334 } | 341 } |
335 } | 342 } |
336 | 343 |
337 void ServiceProcess::ScheduleShutdownCheck() { | 344 void ServiceProcess::ScheduleShutdownCheck() { |
338 MessageLoop::current()->PostDelayedTask( | 345 MessageLoop::current()->PostDelayedTask( |
339 FROM_HERE, | 346 FROM_HERE, |
340 NewRunnableMethod(this, &ServiceProcess::ShutdownIfNeeded), | 347 NewRunnableMethod(this, &ServiceProcess::ShutdownIfNeeded), |
341 kShutdownDelay); | 348 kShutdownDelay); |
(...skipping 14 matching lines...) Expand all Loading... | |
356 } | 363 } |
357 | 364 |
358 ServiceProcess::~ServiceProcess() { | 365 ServiceProcess::~ServiceProcess() { |
359 Teardown(); | 366 Teardown(); |
360 g_service_process = NULL; | 367 g_service_process = NULL; |
361 } | 368 } |
362 | 369 |
363 // Disable refcounting for runnable method because it is really not needed | 370 // Disable refcounting for runnable method because it is really not needed |
364 // when we post tasks on the main message loop. | 371 // when we post tasks on the main message loop. |
365 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); | 372 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); |
OLD | NEW |