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

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

Issue 8495039: NewRunnable* conversion to base::Bind for service process utils. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Could swear I build this on the Mac... Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/service_process_util_win.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) 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/callback.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/memory/singleton.h" 14 #include "base/memory/singleton.h"
14 #include "base/path_service.h" 15 #include "base/path_service.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"
18 #include "chrome/common/chrome_constants.h" 19 #include "chrome/common/chrome_constants.h"
19 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 204
204 VLOG(1) << "Starting Service Process IPC Server"; 205 VLOG(1) << "Starting Service Process IPC Server";
205 ipc_server_.reset(new ServiceIPCServer( 206 ipc_server_.reset(new ServiceIPCServer(
206 service_process_state_->GetServiceProcessChannel())); 207 service_process_state_->GetServiceProcessChannel()));
207 ipc_server_->Init(); 208 ipc_server_->Init();
208 209
209 // After the IPC server has started we signal that the service process is 210 // After the IPC server has started we signal that the service process is
210 // ready. 211 // ready.
211 if (!service_process_state_->SignalReady( 212 if (!service_process_state_->SignalReady(
212 io_thread_->message_loop_proxy(), 213 io_thread_->message_loop_proxy(),
213 NewRunnableMethod(this, &ServiceProcess::Terminate))) { 214 base::Bind(&ServiceProcess::Terminate, base::Unretained(this)))) {
214 return false; 215 return false;
215 } 216 }
216 217
217 // See if we need to stay running. 218 // See if we need to stay running.
218 ScheduleShutdownCheck(); 219 ScheduleShutdownCheck();
219 return true; 220 return true;
220 } 221 }
221 222
222 bool ServiceProcess::Teardown() { 223 bool ServiceProcess::Teardown() {
223 service_prefs_.reset(); 224 service_prefs_.reset();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 LOG(ERROR) << "Unable to RemoveFromAutoRun"; 339 LOG(ERROR) << "Unable to RemoveFromAutoRun";
339 } 340 }
340 // We will wait for some time to respond to IPCs before shutting down. 341 // We will wait for some time to respond to IPCs before shutting down.
341 ScheduleShutdownCheck(); 342 ScheduleShutdownCheck();
342 } 343 }
343 } 344 }
344 345
345 void ServiceProcess::ScheduleShutdownCheck() { 346 void ServiceProcess::ScheduleShutdownCheck() {
346 MessageLoop::current()->PostDelayedTask( 347 MessageLoop::current()->PostDelayedTask(
347 FROM_HERE, 348 FROM_HERE,
348 NewRunnableMethod(this, &ServiceProcess::ShutdownIfNeeded), 349 base::Bind(&ServiceProcess::ShutdownIfNeeded, base::Unretained(this)),
349 kShutdownDelay); 350 kShutdownDelay);
350 } 351 }
351 352
352 void ServiceProcess::ShutdownIfNeeded() { 353 void ServiceProcess::ShutdownIfNeeded() {
353 if (0 == enabled_services_) { 354 if (0 == enabled_services_) {
354 if (ipc_server_->is_client_connected()) { 355 if (ipc_server_->is_client_connected()) {
355 // If there is a client connected, we need to try again later. 356 // If there is a client connected, we need to try again later.
356 // Note that there is still a timing window here because a client may 357 // Note that there is still a timing window here because a client may
357 // decide to connect at this point. 358 // decide to connect at this point.
358 // TODO(sanjeevr): Fix this timing window. 359 // TODO(sanjeevr): Fix this timing window.
359 ScheduleShutdownCheck(); 360 ScheduleShutdownCheck();
360 } else { 361 } else {
361 Shutdown(); 362 Shutdown();
362 } 363 }
363 } 364 }
364 } 365 }
365 366
366 ServiceProcess::~ServiceProcess() { 367 ServiceProcess::~ServiceProcess() {
367 Teardown(); 368 Teardown();
368 g_service_process = NULL; 369 g_service_process = NULL;
369 } 370 }
OLDNEW
« no previous file with comments | « chrome/common/service_process_util_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698