Chromium Code Reviews| 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 |
| 5 #include "mojo/shell/dynamic_application_loader.h" | 5 #include "mojo/shell/dynamic_application_loader.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/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/strings/utf_string_conversions.h" | |
| 14 #include "mojo/common/common_type_converters.h" | 15 #include "mojo/common/common_type_converters.h" |
| 15 #include "mojo/common/data_pipe_utils.h" | 16 #include "mojo/common/data_pipe_utils.h" |
| 16 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | 17 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
| 17 #include "mojo/shell/context.h" | 18 #include "mojo/shell/context.h" |
| 19 #include "mojo/shell/filename_util.h" | |
| 18 #include "mojo/shell/switches.h" | 20 #include "mojo/shell/switches.h" |
| 19 #include "net/base/filename_util.h" | |
| 20 | 21 |
| 21 namespace mojo { | 22 namespace mojo { |
| 22 namespace shell { | 23 namespace shell { |
| 23 | 24 |
| 24 // Encapsulates loading and running one individual application. | 25 // Encapsulates loading and running one individual application. |
| 25 // | 26 // |
| 26 // Loaders are owned by DynamicApplicationLoader. DynamicApplicationLoader must | 27 // Loaders are owned by DynamicApplicationLoader. DynamicApplicationLoader must |
| 27 // ensure that all the parameters passed to Loader subclasses stay valid through | 28 // ensure that all the parameters passed to Loader subclasses stay valid through |
| 28 // Loader's lifetime. | 29 // Loader's lifetime. |
| 29 // | 30 // |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 LocalLoader(const GURL& url, | 86 LocalLoader(const GURL& url, |
| 86 Context* context, | 87 Context* context, |
| 87 DynamicServiceRunnerFactory* runner_factory, | 88 DynamicServiceRunnerFactory* runner_factory, |
| 88 scoped_refptr<ApplicationLoader::LoadCallbacks> load_callbacks, | 89 scoped_refptr<ApplicationLoader::LoadCallbacks> load_callbacks, |
| 89 const LoaderCompleteCallback& loader_complete_callback) | 90 const LoaderCompleteCallback& loader_complete_callback) |
| 90 : Loader(context, | 91 : Loader(context, |
| 91 runner_factory, | 92 runner_factory, |
| 92 load_callbacks, | 93 load_callbacks, |
| 93 loader_complete_callback), | 94 loader_complete_callback), |
| 94 weak_ptr_factory_(this) { | 95 weak_ptr_factory_(this) { |
| 95 base::FilePath path; | 96 DCHECK(url.SchemeIsFile()); |
| 96 net::FileURLToFilePath(url, &path); | 97 #if defined(OS_WIN) |
| 98 base::FilePath path(base::ASCIIToUTF16(url.path())); | |
|
brettw
2014/10/09 22:26:29
This isn't correct, the path on Windows will be "/
| |
| 99 #else | |
| 100 base::FilePath path(url.path()); | |
| 101 #endif | |
| 97 | 102 |
| 98 // Async for consistency with network case. | 103 // Async for consistency with network case. |
| 99 base::MessageLoop::current()->PostTask( | 104 base::MessageLoop::current()->PostTask( |
| 100 FROM_HERE, | 105 FROM_HERE, |
| 101 base::Bind(&LocalLoader::RunLibrary, | 106 base::Bind(&LocalLoader::RunLibrary, |
| 102 weak_ptr_factory_.GetWeakPtr(), | 107 weak_ptr_factory_.GetWeakPtr(), |
| 103 path, | 108 path, |
| 104 base::PathExists(path))); | 109 base::PathExists(path))); |
| 105 } | 110 } |
| 106 | 111 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 // TODO(darin): What should we do about service errors? This implies that | 244 // TODO(darin): What should we do about service errors? This implies that |
| 240 // the app closed its handle to the service manager. Maybe we don't care? | 245 // the app closed its handle to the service manager. Maybe we don't care? |
| 241 } | 246 } |
| 242 | 247 |
| 243 void DynamicApplicationLoader::LoaderComplete(Loader* loader) { | 248 void DynamicApplicationLoader::LoaderComplete(Loader* loader) { |
| 244 loaders_.erase(std::find(loaders_.begin(), loaders_.end(), loader)); | 249 loaders_.erase(std::find(loaders_.begin(), loaders_.end(), loader)); |
| 245 } | 250 } |
| 246 | 251 |
| 247 } // namespace shell | 252 } // namespace shell |
| 248 } // namespace mojo | 253 } // namespace mojo |
| OLD | NEW |