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

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

Issue 10796099: Introducing remoting::Stoppable helper base class implementing asynchronous shutdown on a specific t (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/base/shutdownable.h"
6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/message_loop.h"
10 #include "base/single_thread_task_runner.h"
11
12 namespace remoting {
13
14 Shutdownable::Shutdownable(
15 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
16 const Callback& done)
17 : task_runner_(task_runner),
18 done_(done),
19 state_(kRunning) {
20 }
21
22 Shutdownable::~Shutdownable() {
23 DCHECK_EQ(state_, kStopped);
24 }
25
26 void Shutdownable::Shutdown() {
27 if (state_ == kRunning) {
28 state_ = kShutdown;
29 DoShutdown();
30 }
31 }
32
33 void Shutdownable::CompleteShutdown() {
34 DCHECK_EQ(state_, kShutdown);
35
36 state_ = kStopped;
37 task_runner_->PostTask(FROM_HERE, base::Bind(done_, this));
38 }
39
40 void Shutdownable::DoShutdown() {
41 CompleteShutdown();
42 }
43
44 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698