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

Side by Side Diff: mojo/application/public/cpp/lib/application_impl.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 unified diff | Download patch
« no previous file with comments | « mojo/application/public/cpp/lib/app_lifetime_helper.cc ('k') | mojo/tools/data/apptests » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/application/public/cpp/application_impl.h" 5 #include "mojo/application/public/cpp/application_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 ApplicationImpl::~ApplicationImpl() { 59 ApplicationImpl::~ApplicationImpl() {
60 DCHECK(!in_destructor_); 60 DCHECK(!in_destructor_);
61 in_destructor_ = true; 61 in_destructor_ = true;
62 ClearConnections(); 62 ClearConnections();
63 app_lifetime_helper_.ApplicationTerminated(); 63 app_lifetime_helper_.ApplicationTerminated();
64 } 64 }
65 65
66 ApplicationConnection* ApplicationImpl::ConnectToApplication( 66 ApplicationConnection* ApplicationImpl::ConnectToApplication(
67 mojo::URLRequestPtr request) { 67 mojo::URLRequestPtr request) {
68 return ConnectToApplication(request.Pass(), base::Bind(&base::DoNothing));
69 }
70
71 ApplicationConnection* ApplicationImpl::ConnectToApplication(
72 mojo::URLRequestPtr request,
73 const base::Closure& terminate_cb) {
68 if (!shell_) 74 if (!shell_)
69 return nullptr; 75 return nullptr;
70 ServiceProviderPtr local_services; 76 ServiceProviderPtr local_services;
71 InterfaceRequest<ServiceProvider> local_request = GetProxy(&local_services); 77 InterfaceRequest<ServiceProvider> local_request = GetProxy(&local_services);
72 ServiceProviderPtr remote_services; 78 ServiceProviderPtr remote_services;
73 std::string application_url = request->url.To<std::string>(); 79 std::string application_url = request->url.To<std::string>();
74 shell_->ConnectToApplication(request.Pass(), GetProxy(&remote_services), 80 shell_->ConnectToApplication(request.Pass(), GetProxy(&remote_services),
75 local_services.Pass()); 81 local_services.Pass());
82 remote_services.set_connection_error_handler(terminate_cb);
76 internal::ServiceRegistry* registry = new internal::ServiceRegistry( 83 internal::ServiceRegistry* registry = new internal::ServiceRegistry(
77 this, application_url, application_url, remote_services.Pass(), 84 this, application_url, application_url, remote_services.Pass(),
78 local_request.Pass()); 85 local_request.Pass());
79 if (!delegate_->ConfigureOutgoingConnection(registry)) { 86 if (!delegate_->ConfigureOutgoingConnection(registry)) {
80 registry->CloseConnection(); 87 registry->CloseConnection();
81 return nullptr; 88 return nullptr;
82 } 89 }
83 outgoing_service_registries_.push_back(registry); 90 outgoing_service_registries_.push_back(registry);
84 return registry; 91 return registry;
85 } 92 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 173
167 void ApplicationImpl::OnConnectionError() { 174 void ApplicationImpl::OnConnectionError() {
168 base::WeakPtr<ApplicationImpl> ptr(weak_factory_.GetWeakPtr()); 175 base::WeakPtr<ApplicationImpl> ptr(weak_factory_.GetWeakPtr());
169 QuitNow(); 176 QuitNow();
170 if (!ptr) 177 if (!ptr)
171 return; 178 return;
172 shell_ = nullptr; 179 shell_ = nullptr;
173 } 180 }
174 181
175 } // namespace mojo 182 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/application/public/cpp/lib/app_lifetime_helper.cc ('k') | mojo/tools/data/apptests » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698