Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/application_instance.h" | 5 #include "mojo/shell/application_instance.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "mojo/application/public/interfaces/content_handler.mojom.h" | 9 #include "mojo/application/public/interfaces/content_handler.mojom.h" |
| 10 #include "mojo/common/common_type_converters.h" | 10 #include "mojo/common/common_type_converters.h" |
| 11 #include "mojo/common/url_type_converters.h" | 11 #include "mojo/common/url_type_converters.h" |
| 12 #include "mojo/shell/application_manager.h" | 12 #include "mojo/shell/application_manager.h" |
| 13 | 13 |
| 14 namespace mojo { | 14 namespace mojo { |
| 15 namespace shell { | 15 namespace shell { |
| 16 | 16 |
| 17 ApplicationInstance::QueuedClientRequest::QueuedClientRequest() { | 17 ApplicationInstance::QueuedClientRequest::QueuedClientRequest() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 ApplicationInstance::QueuedClientRequest::~QueuedClientRequest() { | 20 ApplicationInstance::QueuedClientRequest::~QueuedClientRequest() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 ApplicationInstance::ApplicationInstance( | 23 ApplicationInstance::ApplicationInstance( |
| 24 ApplicationPtr application, | 24 ApplicationPtr application, |
| 25 ApplicationManager* manager, | 25 ApplicationManager* manager, |
| 26 const Identity& originator_identity, | |
| 26 const Identity& identity, | 27 const Identity& identity, |
| 27 const CapabilityFilter& filter, | 28 const CapabilityFilter& filter, |
| 28 const base::Closure& on_application_end) | 29 const base::Closure& on_application_end) |
| 29 : manager_(manager), | 30 : manager_(manager), |
| 31 originator_identity_(originator_identity), | |
| 30 identity_(identity), | 32 identity_(identity), |
| 31 filter_(filter), | 33 filter_(filter), |
| 32 allow_any_application_(filter.size() == 1 && filter.count("*") == 1), | 34 allow_any_application_(filter.size() == 1 && filter.count("*") == 1), |
| 33 on_application_end_(on_application_end), | 35 on_application_end_(on_application_end), |
| 34 application_(application.Pass()), | 36 application_(application.Pass()), |
| 35 binding_(this), | 37 binding_(this), |
| 36 queue_requests_(false) { | 38 queue_requests_(false) { |
| 37 binding_.set_connection_error_handler([this]() { OnConnectionError(); }); | 39 binding_.set_connection_error_handler([this]() { OnConnectionError(); }); |
| 38 } | 40 } |
| 39 | 41 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 queued_client_requests_.swap(queued_client_requests); | 139 queued_client_requests_.swap(queued_client_requests); |
| 138 auto manager = manager_; | 140 auto manager = manager_; |
| 139 manager_->OnApplicationInstanceError(this); | 141 manager_->OnApplicationInstanceError(this); |
| 140 //|this| is deleted. | 142 //|this| is deleted. |
| 141 | 143 |
| 142 // If any queued requests came to shell during time it was shutting down, | 144 // If any queued requests came to shell during time it was shutting down, |
| 143 // start them now. | 145 // start them now. |
| 144 for (auto request : queued_client_requests) { | 146 for (auto request : queued_client_requests) { |
| 145 mojo::URLRequestPtr url(mojo::URLRequest::New()); | 147 mojo::URLRequestPtr url(mojo::URLRequest::New()); |
| 146 url->url = mojo::String::From(request->requested_url.spec()); | 148 url->url = mojo::String::From(request->requested_url.spec()); |
| 147 manager->ConnectToApplication(this, url.Pass(), std::string(), | 149 ApplicationInstance* originator = |
| 150 manager->GetApplicationInstance(originator_identity_); | |
|
Ben Goodger (Google)
2015/07/27 19:26:34
note to my future self: I am concerned that in its
| |
| 151 manager->ConnectToApplication(originator, url.Pass(), std::string(), | |
| 148 request->requestor_url, | 152 request->requestor_url, |
| 149 request->services.Pass(), | 153 request->services.Pass(), |
| 150 request->exposed_services.Pass(), | 154 request->exposed_services.Pass(), |
| 151 request->filter.Pass(), | 155 request->filter.Pass(), |
| 152 base::Closure()); | 156 base::Closure()); |
| 153 } | 157 } |
| 154 STLDeleteElements(&queued_client_requests); | 158 STLDeleteElements(&queued_client_requests); |
| 155 } | 159 } |
| 156 | 160 |
| 157 void ApplicationInstance::OnQuitRequestedResult(bool can_quit) { | 161 void ApplicationInstance::OnQuitRequestedResult(bool can_quit) { |
| 158 if (can_quit) | 162 if (can_quit) |
| 159 return; | 163 return; |
| 160 | 164 |
| 161 queue_requests_ = false; | 165 queue_requests_ = false; |
| 162 for (auto request : queued_client_requests_) { | 166 for (auto request : queued_client_requests_) { |
| 163 CallAcceptConnection(request->originator, | 167 CallAcceptConnection(request->originator, |
| 164 request->requestor_url, | 168 request->requestor_url, |
| 165 request->services.Pass(), | 169 request->services.Pass(), |
| 166 request->exposed_services.Pass(), | 170 request->exposed_services.Pass(), |
| 167 request->requested_url); | 171 request->requested_url); |
| 168 } | 172 } |
| 169 STLDeleteElements(&queued_client_requests_); | 173 STLDeleteElements(&queued_client_requests_); |
| 170 } | 174 } |
| 171 | 175 |
| 172 } // namespace shell | 176 } // namespace shell |
| 173 } // namespace mojo | 177 } // namespace mojo |
| OLD | NEW |