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

Side by Side Diff: mojo/shell/run.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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/shell/run.h" 5 #include "mojo/shell/run.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/application_manager/application_manager.h" 8 #include "mojo/application_manager/application_manager.h"
9 #include "mojo/shell/context.h" 9 #include "mojo/shell/context.h"
10 #include "mojo/shell/keep_alive.h"
11 10
12 namespace mojo { 11 namespace mojo {
13 namespace shell { 12 namespace shell {
14 13
15 class StubServiceProvider : public InterfaceImpl<ServiceProvider> { 14 class StubServiceProvider : public InterfaceImpl<ServiceProvider> {
16 private: 15 private:
17 virtual void ConnectToService(const mojo::String& service_name, 16 virtual void ConnectToService(const mojo::String& service_name,
18 ScopedMessagePipeHandle client_handle) 17 ScopedMessagePipeHandle client_handle)
19 MOJO_OVERRIDE { 18 MOJO_OVERRIDE {
20 } 19 }
21 }; 20 };
22 21
23 22
24 void Run(Context* context, const std::vector<GURL>& app_urls) { 23 void Run(Context* context, const std::vector<GURL>& app_urls) {
25 KeepAlive keep_alive(context);
26
27 if (app_urls.empty()) { 24 if (app_urls.empty()) {
28 LOG(ERROR) << "No app path specified"; 25 LOG(ERROR) << "No app path specified";
29 return; 26 return;
30 } 27 }
31 28
32 for (std::vector<GURL>::const_iterator it = app_urls.begin(); 29 for (std::vector<GURL>::const_iterator it = app_urls.begin();
33 it != app_urls.end(); 30 it != app_urls.end();
34 ++it) { 31 ++it) {
35 // TODO(davemoore): These leak...need refs to them. 32 // TODO(davemoore): These leak...need refs to them.
36 StubServiceProvider* stub_sp = new StubServiceProvider; 33 StubServiceProvider* stub_sp = new StubServiceProvider;
37 ServiceProviderPtr spp; 34 ServiceProviderPtr spp;
38 BindToProxy(stub_sp, &spp); 35 BindToProxy(stub_sp, &spp);
39 36
40 context->application_manager()->ConnectToApplication( 37 context->application_manager()->ConnectToApplication(
41 *it, GURL(), spp.Pass()); 38 *it, GURL(), spp.Pass());
42 } 39 }
43 } 40 }
44 41
45 } // namespace shell 42 } // namespace shell
46 } // namespace mojo 43 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698