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

Side by Side Diff: remoting/base/stoppable.cc

Issue 10828181: [Chromoting] Moving common logic responsible for launching child processes to WorkerProcessLauncher… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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 "remoting/base/stoppable.h" 5 #include "remoting/base/stoppable.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 9
10 namespace remoting { 10 namespace remoting {
11 11
12 Stoppable::Stoppable( 12 Stoppable::Stoppable(
13 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 13 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
14 const base::Closure& stopped_callback) 14 const base::Closure& stopped_callback)
15 : state_(kRunning), 15 : state_(kRunning),
16 stopped_callback_(stopped_callback), 16 stopped_callback_(stopped_callback),
17 task_runner_(task_runner) { 17 task_runner_(task_runner) {
18 } 18 }
19 19
20 Stoppable::~Stoppable() { 20 Stoppable::~Stoppable() {
21 DCHECK_EQ(state_, kStopped); 21 DCHECK_EQ(state_, kStopped);
22 } 22 }
23 23
24 void Stoppable::Stop() { 24 void Stoppable::Stop() {
25 DCHECK(task_runner_->BelongsToCurrentThread()); 25 DCHECK(task_runner_->BelongsToCurrentThread());
26 26
27 // DoStop() can be called multiple times. stoppable_state() can be queried
28 // to tell the first call from the follow up calls.
29 DoStop();
Wez 2012/08/08 20:13:41 Isn't there a risk that something in DoStop() trig
alexeypa (please no reviews) 2012/08/08 21:49:58 This is the intended behavior. :-)
alexeypa (please no reviews) 2012/08/10 16:18:44 It turned out that this breaks stoppable state val
30
27 if (state_ == kRunning) { 31 if (state_ == kRunning) {
28 state_ = kStopping; 32 state_ = kStopping;
29 DoStop();
30 } 33 }
31 } 34 }
32 35
33 void Stoppable::CompleteStopping() { 36 void Stoppable::CompleteStopping() {
34 DCHECK(task_runner_->BelongsToCurrentThread()); 37 DCHECK(task_runner_->BelongsToCurrentThread());
35 DCHECK_EQ(state_, kStopping); 38 DCHECK_EQ(state_, kStopping);
36 39
37 state_ = kStopped; 40 state_ = kStopped;
38 task_runner_->PostTask(FROM_HERE, stopped_callback_); 41 task_runner_->PostTask(FROM_HERE, stopped_callback_);
39 } 42 }
40 43
41 } // namespace remoting 44 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/host/win/launch_process_with_token.h » ('j') | remoting/host/win/launch_process_with_token.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698