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

Unified Diff: services/shell/public/cpp/lib/service_runner.cc

Issue 2179023004: Make Service own ServiceContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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 | « services/shell/public/cpp/lib/service_context.cc ('k') | services/shell/public/cpp/lib/service_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/shell/public/cpp/lib/service_runner.cc
diff --git a/services/shell/public/cpp/lib/service_runner.cc b/services/shell/public/cpp/lib/service_runner.cc
index 65a4357a5112f446d64e12950ac6757da79796ab..bff97dbe4ec5d31c22417616ec9a4f81656ca532 100644
--- a/services/shell/public/cpp/lib/service_runner.cc
+++ b/services/shell/public/cpp/lib/service_runner.cc
@@ -51,12 +51,13 @@ MojoResult ServiceRunner::Run(MojoHandle service_request_handle,
std::unique_ptr<base::MessageLoop> loop;
loop.reset(new base::MessageLoop(message_loop_type_));
- context_.reset(new ServiceContext(
+ std::unique_ptr<ServiceContext> context(new ServiceContext(
service_.get(),
mojo::MakeRequest<mojom::Service>(mojo::MakeScopedHandle(
mojo::MessagePipeHandle(service_request_handle)))));
base::RunLoop run_loop;
- context_->SetConnectionLostClosure(run_loop.QuitClosure());
+ context->SetConnectionLostClosure(run_loop.QuitClosure());
+ service_->set_context(std::move(context));
run_loop.Run();
// It's very common for the service to cache the app and terminate on
// errors. If we don't delete the service before the app we run the risk of
@@ -66,7 +67,6 @@ MojoResult ServiceRunner::Run(MojoHandle service_request_handle,
// service.
loop.reset();
service_.reset();
- context_.reset();
}
return MOJO_RESULT_OK;
}
@@ -81,7 +81,7 @@ MojoResult ServiceRunner::Run(MojoHandle service_request_handle) {
}
void ServiceRunner::DestroyServiceContext() {
- context_.reset();
+ service_->set_context(std::unique_ptr<ServiceContext>());
}
void ServiceRunner::Quit() {
« no previous file with comments | « services/shell/public/cpp/lib/service_context.cc ('k') | services/shell/public/cpp/lib/service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698