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

Unified Diff: mojo/application/public/cpp/lib/app_lifetime_helper.cc

Issue 1200323003: media: Quit MojoMediaApplication when no service is bound. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/application/public/cpp/application_impl.h ('k') | mojo/application/public/cpp/lib/application_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/application/public/cpp/lib/app_lifetime_helper.cc
diff --git a/mojo/application/public/cpp/lib/app_lifetime_helper.cc b/mojo/application/public/cpp/lib/app_lifetime_helper.cc
index 4d12339138056b4b39172699a7ca41074b9d816c..c3ed08534c9d897ffa88f4bb5c7ec4a80e4e8e91 100644
--- a/mojo/application/public/cpp/lib/app_lifetime_helper.cc
+++ b/mojo/application/public/cpp/lib/app_lifetime_helper.cc
@@ -12,8 +12,10 @@ namespace mojo {
AppRefCount::AppRefCount(
AppLifetimeHelper* app_lifetime_helper,
+ base::TimeDelta release_delay,
scoped_refptr<base::SingleThreadTaskRunner> app_task_runner)
: app_lifetime_helper_(app_lifetime_helper),
+ release_delay_(release_delay),
app_task_runner_(app_task_runner) {
}
@@ -27,6 +29,14 @@ AppRefCount::~AppRefCount() {
}
#endif
+ if (!release_delay_.is_zero()) {
+ app_task_runner_->PostDelayedTask(
+ FROM_HERE, base::Bind(&AppLifetimeHelper::Release,
+ base::Unretained(app_lifetime_helper_)),
+ release_delay_);
+ return;
+ }
+
if (app_task_runner_->BelongsToCurrentThread()) {
app_lifetime_helper_->Release();
return;
@@ -59,8 +69,8 @@ scoped_ptr<AppRefCount> AppRefCount::Clone() {
}
#endif
- return make_scoped_ptr(new AppRefCount(
- app_lifetime_helper_, app_task_runner_));
+ return make_scoped_ptr(
+ new AppRefCount(app_lifetime_helper_, release_delay_, app_task_runner_));
}
AppLifetimeHelper::AppLifetimeHelper(ApplicationImpl* app)
@@ -71,9 +81,14 @@ AppLifetimeHelper::~AppLifetimeHelper() {
}
scoped_ptr<AppRefCount> AppLifetimeHelper::CreateAppRefCount() {
+ return CreateAppRefCount(base::TimeDelta());
+}
+
+scoped_ptr<AppRefCount> AppLifetimeHelper::CreateAppRefCount(
+ base::TimeDelta release_delay) {
AddRef();
return make_scoped_ptr(new AppRefCount(
- this, base::MessageLoop::current()->task_runner()));
+ this, release_delay, base::MessageLoop::current()->task_runner()));
}
void AppLifetimeHelper::AddRef() {
« no previous file with comments | « mojo/application/public/cpp/application_impl.h ('k') | mojo/application/public/cpp/lib/application_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698