android webview envsetup: Set android_ndk_root and android_sdk_version to dummy values.
[chromium-blink-merge.git] / mojo / shell / keep_alive.cc
blob710a88ed559a1609cc706495b5e572e93b9a5efd
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.
5 #include "mojo/shell/keep_alive.h"
7 #include "mojo/shell/context.h"
9 namespace mojo {
10 namespace shell {
12 KeepAlive::KeepAlive(Context* context) : context_(context) {
13 DCHECK(context_->task_runners()->ui_runner()->RunsTasksOnCurrentThread());
14 ++context_->keep_alive_counter()->count_;
17 KeepAlive::~KeepAlive() {
18 DCHECK(context_->task_runners()->ui_runner()->RunsTasksOnCurrentThread());
19 if (--context_->keep_alive_counter()->count_ == 0) {
20 base::MessageLoop::current()->PostTask(
21 FROM_HERE,
22 base::Bind(&KeepAlive::MaybeQuit, context_));
26 // static
27 void KeepAlive::MaybeQuit(Context* context) {
28 if (context->keep_alive_counter()->count_ == 0)
29 base::MessageLoop::current()->Quit();
32 } // namespace shell
33 } // namespace mojo