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/package_manager/package_manager_impl.h" | 5 #include "mojo/package_manager/package_manager_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "mojo/application/public/interfaces/content_handler.mojom.h" | 8 #include "mojo/application/public/interfaces/content_handler.mojom.h" |
9 #include "mojo/fetcher/about_fetcher.h" | 9 #include "mojo/fetcher/about_fetcher.h" |
10 #include "mojo/fetcher/data_fetcher.h" | 10 #include "mojo/fetcher/data_fetcher.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace mojo { | 23 namespace mojo { |
24 namespace package_manager { | 24 namespace package_manager { |
25 | 25 |
26 PackageManagerImpl::PackageManagerImpl( | 26 PackageManagerImpl::PackageManagerImpl( |
27 const base::FilePath& shell_file_root, | 27 const base::FilePath& shell_file_root, |
28 base::TaskRunner* task_runner) | 28 base::TaskRunner* task_runner) |
29 : application_manager_(nullptr), | 29 : application_manager_(nullptr), |
30 disable_cache_(base::CommandLine::ForCurrentProcess()->HasSwitch( | 30 disable_cache_(base::CommandLine::ForCurrentProcess()->HasSwitch( |
31 switches::kDisableCache)), | 31 switches::kDisableCache)), |
32 content_handler_id_counter_(0u), | 32 content_handler_id_counter_(0u), |
33 task_runner_(task_runner) { | 33 task_runner_(task_runner), |
| 34 shell_file_root_(shell_file_root) { |
34 if (!shell_file_root.empty()) { | 35 if (!shell_file_root.empty()) { |
35 GURL mojo_root_file_url = | 36 GURL mojo_root_file_url = |
36 util::FilePathToFileURL(shell_file_root).Resolve(std::string()); | 37 util::FilePathToFileURL(shell_file_root).Resolve(std::string()); |
37 url_resolver_.reset(new fetcher::URLResolver(mojo_root_file_url)); | 38 url_resolver_.reset(new fetcher::URLResolver(mojo_root_file_url)); |
38 } | 39 } |
39 } | 40 } |
40 | 41 |
41 PackageManagerImpl::~PackageManagerImpl() { | 42 PackageManagerImpl::~PackageManagerImpl() { |
42 IdentityToContentHandlerMap identity_to_content_handler( | 43 IdentityToContentHandlerMap identity_to_content_handler( |
43 identity_to_content_handler_); | 44 identity_to_content_handler_); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // Skip this for mojo URLs to avoid recursively loading the network service. | 87 // Skip this for mojo URLs to avoid recursively loading the network service. |
87 if (!network_service_ && !url.SchemeIs("mojo") && !url.SchemeIs("exe")) { | 88 if (!network_service_ && !url.SchemeIs("mojo") && !url.SchemeIs("exe")) { |
88 shell::ConnectToService(application_manager_, | 89 shell::ConnectToService(application_manager_, |
89 GURL("mojo:network_service"), &network_service_); | 90 GURL("mojo:network_service"), &network_service_); |
90 } | 91 } |
91 // Ownership of this object is transferred to |loader_callback|. | 92 // Ownership of this object is transferred to |loader_callback|. |
92 // TODO(beng): this is eff'n weird. | 93 // TODO(beng): this is eff'n weird. |
93 new fetcher::LocalFetcher( | 94 new fetcher::LocalFetcher( |
94 network_service_.get(), resolved_url, | 95 network_service_.get(), resolved_url, |
95 shell::GetBaseURLAndQuery(resolved_url, nullptr), | 96 shell::GetBaseURLAndQuery(resolved_url, nullptr), |
96 loader_callback); | 97 shell_file_root_, loader_callback); |
97 return; | 98 return; |
98 } | 99 } |
99 | 100 |
100 #if 0 | 101 #if 0 |
101 // TODO(beng): figure out how this should be integrated now that mapped_url | 102 // TODO(beng): figure out how this should be integrated now that mapped_url |
102 // is toast. | 103 // is toast. |
103 // TODO(scottmg): to quote someone I know, if you liked this you shouldda put | 104 // TODO(scottmg): to quote someone I know, if you liked this you shouldda put |
104 // a test on it. | 105 // a test on it. |
105 if (url.SchemeIs("mojo") && | 106 if (url.SchemeIs("mojo") && |
106 base::CommandLine::ForCurrentProcess()->HasSwitch( | 107 base::CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 void PackageManagerImpl::OnContentHandlerConnectionClosed( | 233 void PackageManagerImpl::OnContentHandlerConnectionClosed( |
233 ContentHandlerConnection* connection) { | 234 ContentHandlerConnection* connection) { |
234 // Remove the mapping. | 235 // Remove the mapping. |
235 auto it = identity_to_content_handler_.find(connection->identity()); | 236 auto it = identity_to_content_handler_.find(connection->identity()); |
236 DCHECK(it != identity_to_content_handler_.end()); | 237 DCHECK(it != identity_to_content_handler_.end()); |
237 identity_to_content_handler_.erase(it); | 238 identity_to_content_handler_.erase(it); |
238 } | 239 } |
239 | 240 |
240 } // namespace package_manager | 241 } // namespace package_manager |
241 } // namespace mojo | 242 } // namespace mojo |
OLD | NEW |