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

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

Issue 10855249: [Chromoting] The daemon process now starts the networking process and passes the host configuration… (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/bind.h"
7 #include "base/message_loop.h" 8 #include "base/message_loop.h"
8 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
9 10
10 namespace remoting { 11 namespace remoting {
11 12
12 Stoppable::Stoppable( 13 Stoppable::Stoppable(
13 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 14 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
14 const base::Closure& stopped_callback) 15 const base::Closure& stopped_callback)
15 : state_(kRunning), 16 : state_(kRunning),
16 stopped_callback_(stopped_callback), 17 stopped_callback_(stopped_callback),
17 task_runner_(task_runner) { 18 task_runner_(task_runner) {
18 } 19 }
19 20
20 Stoppable::~Stoppable() { 21 Stoppable::~Stoppable() {
21 CHECK_EQ(state_, kStopped); 22 CHECK_EQ(state_, kStopped);
22 } 23 }
23 24
24 void Stoppable::Stop() { 25 void Stoppable::Stop() {
25 DCHECK(task_runner_->BelongsToCurrentThread()); 26 if (!task_runner_->BelongsToCurrentThread()) {
27 task_runner_->PostTask(FROM_HERE, base::Bind(&Stoppable::Stop,
28 base::Unretained(this)));
Wez 2012/08/21 00:18:57 Using base::Unretained here means that multiple St
alexeypa (please no reviews) 2012/08/21 17:16:36 Indeed, your are right. Stop() should not be ever
29 return;
30 }
26 31
27 if (state_ == kRunning) { 32 if (state_ == kRunning) {
28 state_ = kStopping; 33 state_ = kStopping;
29 } 34 }
30 35
31 // DoStop() can be called multiple times. 36 // DoStop() can be called multiple times.
32 DoStop(); 37 DoStop();
33 } 38 }
34 39
35 void Stoppable::CompleteStopping() { 40 void Stoppable::CompleteStopping() {
36 DCHECK(task_runner_->BelongsToCurrentThread()); 41 DCHECK(task_runner_->BelongsToCurrentThread());
37 DCHECK_EQ(state_, kStopping); 42 DCHECK_EQ(state_, kStopping);
38 43
39 state_ = kStopped; 44 state_ = kStopped;
40 task_runner_->PostTask(FROM_HERE, stopped_callback_); 45 task_runner_->PostTask(FROM_HERE, stopped_callback_);
41 } 46 }
42 47
43 } // namespace remoting 48 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698