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

Side by Side Diff: mojo/shell/keep_alive.cc

Issue 491443005: Get rid of KeepAlive. Quit shell when all urls run directly by Context are closed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 6 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
(Empty)
1 // Copyright 2014 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 "mojo/shell/keep_alive.h"
6
7 #include "base/bind.h"
8 #include "mojo/shell/context.h"
9
10 namespace mojo {
11 namespace shell {
12
13 KeepAlive::KeepAlive(Context* context) : context_(context) {
14 DCHECK(context_->task_runners()->shell_runner()->RunsTasksOnCurrentThread());
15 ++context_->keep_alive_counter()->count_;
16 }
17
18 KeepAlive::~KeepAlive() {
19 DCHECK(context_->task_runners()->shell_runner()->RunsTasksOnCurrentThread());
20 if (--context_->keep_alive_counter()->count_ == 0) {
21 base::MessageLoop::current()->PostTask(
22 FROM_HERE,
23 base::Bind(&KeepAlive::MaybeQuit, context_));
24 }
25 }
26
27 // static
28 void KeepAlive::MaybeQuit(Context* context) {
29 if (context->keep_alive_counter()->count_ == 0)
30 base::MessageLoop::current()->Quit();
31 }
32
33 } // namespace shell
34 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698