Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: chrome/service/service_process.cc

Issue 9230002: Convert use of int ms to TimeDelta in chrome/service files. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Restrict CL to chrome/service files. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/service/cloud_print/print_system_cups.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/callback.h" 10 #include "base/callback.h"
(...skipping 25 matching lines...) Expand all
36 36
37 #if defined(TOOLKIT_USES_GTK) 37 #if defined(TOOLKIT_USES_GTK)
38 #include "ui/gfx/gtk_util.h" 38 #include "ui/gfx/gtk_util.h"
39 #include <gtk/gtk.h> 39 #include <gtk/gtk.h>
40 #endif 40 #endif
41 41
42 ServiceProcess* g_service_process = NULL; 42 ServiceProcess* g_service_process = NULL;
43 43
44 namespace { 44 namespace {
45 45
46 // Delay in millseconds after the last service is disabled before we attempt 46 // Delay in seconds after the last service is disabled before we attempt
47 // a shutdown. 47 // a shutdown.
48 const int64 kShutdownDelay = 60000; 48 const int kShutdownDelaySeconds = 60;
49 49
50 // Delay in milliseconds between launching a browser process to check the 50 // Delay in hours between launching a browser process to check the
51 // policy for us. 8 hours * 60 * 60 * 1000 51 // policy for us.
52 const int64 kPolicyCheckDelay = 28800000; 52 const int64 kPolicyCheckDelayHours = 8;
53 53
54 const char kDefaultServiceProcessLocale[] = "en-US"; 54 const char kDefaultServiceProcessLocale[] = "en-US";
55 55
56 class ServiceIOThread : public base::Thread { 56 class ServiceIOThread : public base::Thread {
57 public: 57 public:
58 explicit ServiceIOThread(const char* name); 58 explicit ServiceIOThread(const char* name);
59 virtual ~ServiceIOThread(); 59 virtual ~ServiceIOThread();
60 60
61 protected: 61 protected:
62 virtual void CleanUp(); 62 virtual void CleanUp();
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 349 }
350 // We will wait for some time to respond to IPCs before shutting down. 350 // We will wait for some time to respond to IPCs before shutting down.
351 ScheduleShutdownCheck(); 351 ScheduleShutdownCheck();
352 } 352 }
353 } 353 }
354 354
355 void ServiceProcess::ScheduleShutdownCheck() { 355 void ServiceProcess::ScheduleShutdownCheck() {
356 MessageLoop::current()->PostDelayedTask( 356 MessageLoop::current()->PostDelayedTask(
357 FROM_HERE, 357 FROM_HERE,
358 base::Bind(&ServiceProcess::ShutdownIfNeeded, base::Unretained(this)), 358 base::Bind(&ServiceProcess::ShutdownIfNeeded, base::Unretained(this)),
359 kShutdownDelay); 359 base::TimeDelta::FromSeconds(kShutdownDelaySeconds));
360 } 360 }
361 361
362 void ServiceProcess::ShutdownIfNeeded() { 362 void ServiceProcess::ShutdownIfNeeded() {
363 if (0 == enabled_services_) { 363 if (0 == enabled_services_) {
364 if (ipc_server_->is_client_connected()) { 364 if (ipc_server_->is_client_connected()) {
365 // If there is a client connected, we need to try again later. 365 // If there is a client connected, we need to try again later.
366 // Note that there is still a timing window here because a client may 366 // Note that there is still a timing window here because a client may
367 // decide to connect at this point. 367 // decide to connect at this point.
368 // TODO(sanjeevr): Fix this timing window. 368 // TODO(sanjeevr): Fix this timing window.
369 ScheduleShutdownCheck(); 369 ScheduleShutdownCheck();
370 } else { 370 } else {
371 Shutdown(); 371 Shutdown();
372 } 372 }
373 } 373 }
374 } 374 }
375 375
376 void ServiceProcess::ScheduleCloudPrintPolicyCheck() { 376 void ServiceProcess::ScheduleCloudPrintPolicyCheck() {
377 MessageLoop::current()->PostDelayedTask( 377 MessageLoop::current()->PostDelayedTask(
378 FROM_HERE, 378 FROM_HERE,
379 base::Bind(&ServiceProcess::CloudPrintPolicyCheckIfNeeded, 379 base::Bind(&ServiceProcess::CloudPrintPolicyCheckIfNeeded,
380 base::Unretained(this)), 380 base::Unretained(this)),
381 kPolicyCheckDelay); 381 base::TimeDelta::FromHours(kPolicyCheckDelayHours));
382 } 382 }
383 383
384 void ServiceProcess::CloudPrintPolicyCheckIfNeeded() { 384 void ServiceProcess::CloudPrintPolicyCheckIfNeeded() {
385 if (enabled_services_ && !ipc_server_->is_client_connected()) { 385 if (enabled_services_ && !ipc_server_->is_client_connected()) {
386 GetCloudPrintProxy()->CheckCloudPrintProxyPolicy(); 386 GetCloudPrintProxy()->CheckCloudPrintProxyPolicy();
387 } 387 }
388 ScheduleCloudPrintPolicyCheck(); 388 ScheduleCloudPrintPolicyCheck();
389 } 389 }
390 390
391 ServiceProcess::~ServiceProcess() { 391 ServiceProcess::~ServiceProcess() {
392 Teardown(); 392 Teardown();
393 g_service_process = NULL; 393 g_service_process = NULL;
394 } 394 }
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/print_system_cups.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698