OLD | NEW |
---|---|
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 |
ppi
2015/11/24 10:47:21
Is it possible to have an application_manager_unit
| |
5 #include "shell/application_manager/application_manager.h" | 5 #include "shell/application_manager/application_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
14 #include "mojo/public/cpp/bindings/binding.h" | 14 #include "mojo/public/cpp/bindings/binding.h" |
15 #include "mojo/services/authenticating_url_loader_interceptor/interfaces/authent icating_url_loader_interceptor_meta_factory.mojom.h" | 15 #include "mojo/services/authenticating_url_loader_interceptor/interfaces/authent icating_url_loader_interceptor_meta_factory.mojom.h" |
16 #include "mojo/services/authentication/interfaces/authentication.mojom.h" | 16 #include "mojo/services/authentication/interfaces/authentication.mojom.h" |
17 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" | 17 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" |
18 #include "shell/application_manager/fetcher.h" | 18 #include "shell/application_manager/fetcher.h" |
19 #include "shell/application_manager/local_fetcher.h" | 19 #include "shell/application_manager/local_fetcher.h" |
20 #include "shell/application_manager/network_fetcher.h" | 20 #include "shell/application_manager/network_fetcher.h" |
21 #include "shell/application_manager/query_util.h" | 21 #include "shell/application_manager/query_util.h" |
22 #include "shell/application_manager/shell_impl.h" | 22 #include "shell/application_manager/shell_impl.h" |
23 | 23 |
24 using mojo::Application; | 24 using mojo::Application; |
25 using mojo::ApplicationPtr; | 25 using mojo::ApplicationPtr; |
26 using mojo::InterfaceRequest; | 26 using mojo::InterfaceRequest; |
27 using mojo::ServiceProvider; | 27 using mojo::ServiceProvider; |
28 using mojo::ServiceProviderPtr; | 28 using mojo::ServiceProviderPtr; |
29 | 29 |
30 namespace shell { | 30 namespace shell { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 // Create identity that depends on the query. | |
35 const bool kWithQuery = true; | |
36 | |
34 // Used by TestAPI. | 37 // Used by TestAPI. |
35 bool has_created_instance = false; | 38 bool has_created_instance = false; |
36 | 39 |
37 std::vector<std::string> Concatenate(const std::vector<std::string>& v1, | 40 std::vector<std::string> Concatenate(const std::vector<std::string>& v1, |
38 const std::vector<std::string>& v2) { | 41 const std::vector<std::string>& v2) { |
39 if (!v1.size()) | 42 if (!v1.size()) |
40 return v2; | 43 return v2; |
41 if (!v2.size()) | 44 if (!v2.size()) |
42 return v1; | 45 return v1; |
43 std::vector<std::string> result(v1); | 46 std::vector<std::string> result(v1); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 if (!loader) | 254 if (!loader) |
252 return false; | 255 return false; |
253 | 256 |
254 loader->Load( | 257 loader->Load( |
255 resolved_url, | 258 resolved_url, |
256 RegisterShell(resolved_url, requestor_url, services->Pass(), | 259 RegisterShell(resolved_url, requestor_url, services->Pass(), |
257 exposed_services->Pass(), on_application_end, parameters)); | 260 exposed_services->Pass(), on_application_end, parameters)); |
258 return true; | 261 return true; |
259 } | 262 } |
260 | 263 |
261 Identity ApplicationManager::MakeApplicationIdentity(const GURL& resolved_url) { | 264 Identity ApplicationManager::MakeApplicationIdentity(const GURL& resolved_url, |
265 bool with_query) { | |
ppi
2015/11/24 10:47:21
Why parametrize if we don't call it with |with_que
qsr
2015/11/24 12:24:32
We do, we have a default value for the parameter.
| |
262 static uint64_t unique_id_number = 1; | 266 static uint64_t unique_id_number = 1; |
263 bool new_process_per_connection = | 267 bool new_process_per_connection = |
264 GetNativeApplicationOptionsForURL( | 268 GetNativeApplicationOptionsForURL( |
265 GetBaseURLAndQuery(resolved_url, nullptr)) | 269 GetBaseURLAndQuery(resolved_url, nullptr)) |
266 ->new_process_per_connection; | 270 ->new_process_per_connection; |
267 return new_process_per_connection | 271 return new_process_per_connection |
268 ? Identity(resolved_url, base::Uint64ToString(unique_id_number++)) | 272 ? Identity(resolved_url, base::Uint64ToString(unique_id_number++), |
269 : Identity(resolved_url); | 273 with_query) |
274 : Identity(resolved_url, with_query); | |
270 } | 275 } |
271 | 276 |
272 InterfaceRequest<Application> ApplicationManager::RegisterShell( | 277 InterfaceRequest<Application> ApplicationManager::RegisterShell( |
273 const GURL& resolved_url, | 278 const GURL& resolved_url, |
274 const GURL& requestor_url, | 279 const GURL& requestor_url, |
275 InterfaceRequest<ServiceProvider> services, | 280 InterfaceRequest<ServiceProvider> services, |
276 ServiceProviderPtr exposed_services, | 281 ServiceProviderPtr exposed_services, |
277 const base::Closure& on_application_end, | 282 const base::Closure& on_application_end, |
278 const std::vector<std::string>& parameters) { | 283 const std::vector<std::string>& parameters) { |
279 Identity app_identity = MakeApplicationIdentity(resolved_url); | 284 Identity app_identity = MakeApplicationIdentity(resolved_url); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 DCHECK(content_handler_url.is_valid()) | 427 DCHECK(content_handler_url.is_valid()) |
423 << "Content handler URL is invalid for mime type " << mime_type; | 428 << "Content handler URL is invalid for mime type " << mime_type; |
424 mime_type_to_url_[mime_type] = content_handler_url; | 429 mime_type_to_url_[mime_type] = content_handler_url; |
425 } | 430 } |
426 | 431 |
427 void ApplicationManager::LoadWithContentHandler( | 432 void ApplicationManager::LoadWithContentHandler( |
428 const GURL& content_handler_url, | 433 const GURL& content_handler_url, |
429 InterfaceRequest<Application> application_request, | 434 InterfaceRequest<Application> application_request, |
430 mojo::URLResponsePtr url_response) { | 435 mojo::URLResponsePtr url_response) { |
431 ContentHandlerConnection* connection = nullptr; | 436 ContentHandlerConnection* connection = nullptr; |
432 Identity content_handler_id = MakeApplicationIdentity(content_handler_url); | 437 Identity content_handler_id = |
438 MakeApplicationIdentity(content_handler_url, kWithQuery); | |
433 auto it = identity_to_content_handler_.find(content_handler_id); | 439 auto it = identity_to_content_handler_.find(content_handler_id); |
434 if (it != identity_to_content_handler_.end()) { | 440 if (it != identity_to_content_handler_.end()) { |
435 connection = it->second.get(); | 441 connection = it->second.get(); |
436 } else { | 442 } else { |
437 connection = new ContentHandlerConnection(this, content_handler_id); | 443 connection = new ContentHandlerConnection(this, content_handler_id); |
438 identity_to_content_handler_[content_handler_id] = | 444 identity_to_content_handler_[content_handler_id] = |
439 make_scoped_ptr(connection); | 445 make_scoped_ptr(connection); |
440 } | 446 } |
441 | 447 |
442 connection->content_handler()->StartApplication(application_request.Pass(), | 448 connection->content_handler()->StartApplication(application_request.Pass(), |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 return args_it->second; | 539 return args_it->second; |
534 return std::vector<std::string>(); | 540 return std::vector<std::string>(); |
535 } | 541 } |
536 | 542 |
537 void ApplicationManager::CleanupRunner(NativeRunner* runner) { | 543 void ApplicationManager::CleanupRunner(NativeRunner* runner) { |
538 native_runners_.erase( | 544 native_runners_.erase( |
539 std::find(native_runners_.begin(), native_runners_.end(), runner)); | 545 std::find(native_runners_.begin(), native_runners_.end(), runner)); |
540 } | 546 } |
541 | 547 |
542 } // namespace shell | 548 } // namespace shell |
OLD | NEW |