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

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: 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
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "mojo/application/public/cpp/application_delegate.h" 9 #include "mojo/application/public/cpp/application_delegate.h"
10 #include "mojo/application/public/cpp/lib/service_registry.h" 10 #include "mojo/application/public/cpp/lib/service_registry.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 outgoing_service_registries_.clear(); 52 outgoing_service_registries_.clear();
53 } 53 }
54 54
55 ApplicationImpl::~ApplicationImpl() { 55 ApplicationImpl::~ApplicationImpl() {
56 ClearConnections(); 56 ClearConnections();
57 app_lifetime_helper_.ApplicationTerminated(); 57 app_lifetime_helper_.ApplicationTerminated();
58 } 58 }
59 59
60 ApplicationConnection* ApplicationImpl::ConnectToApplication( 60 ApplicationConnection* ApplicationImpl::ConnectToApplication(
61 mojo::URLRequestPtr request) { 61 mojo::URLRequestPtr request) {
62 return ConnectToApplication(request.Pass(), base::Bind(&base::DoNothing));
63 }
64
65 ApplicationConnection* ApplicationImpl::ConnectToApplication(
66 mojo::URLRequestPtr request,
67 const base::Closure& error_cb) {
62 MOJO_CHECK(shell_); 68 MOJO_CHECK(shell_);
63 ServiceProviderPtr local_services; 69 ServiceProviderPtr local_services;
64 InterfaceRequest<ServiceProvider> local_request = GetProxy(&local_services); 70 InterfaceRequest<ServiceProvider> local_request = GetProxy(&local_services);
65 ServiceProviderPtr remote_services; 71 ServiceProviderPtr remote_services;
66 std::string application_url = request->url.To<std::string>(); 72 std::string application_url = request->url.To<std::string>();
67 shell_->ConnectToApplication(request.Pass(), GetProxy(&remote_services), 73 shell_->ConnectToApplication(request.Pass(), GetProxy(&remote_services),
68 local_services.Pass()); 74 local_services.Pass());
75 remote_services.set_connection_error_handler(error_cb);
69 internal::ServiceRegistry* registry = new internal::ServiceRegistry( 76 internal::ServiceRegistry* registry = new internal::ServiceRegistry(
70 this, application_url, application_url, remote_services.Pass(), 77 this, application_url, application_url, remote_services.Pass(),
71 local_request.Pass()); 78 local_request.Pass());
72 if (!delegate_->ConfigureOutgoingConnection(registry)) { 79 if (!delegate_->ConfigureOutgoingConnection(registry)) {
73 delete registry; 80 delete registry;
74 return nullptr; 81 return nullptr;
75 } 82 }
76 outgoing_service_registries_.push_back(registry); 83 outgoing_service_registries_.push_back(registry);
77 return registry; 84 return registry;
78 } 85 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 149
143 void ApplicationImpl::OnConnectionError() { 150 void ApplicationImpl::OnConnectionError() {
144 base::WeakPtr<ApplicationImpl> ptr(weak_factory_.GetWeakPtr()); 151 base::WeakPtr<ApplicationImpl> ptr(weak_factory_.GetWeakPtr());
145 QuitNow(); 152 QuitNow();
146 if (!ptr) 153 if (!ptr)
147 return; 154 return;
148 shell_ = nullptr; 155 shell_ = nullptr;
149 } 156 }
150 157
151 } // namespace mojo 158 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698