| 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/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "mojo/common/common_type_converters.h" | 16 #include "mojo/common/common_type_converters.h" |
| 16 #include "mojo/common/data_pipe_utils.h" | 17 #include "mojo/common/data_pipe_utils.h" |
| 17 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | 18 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
| 18 #include "mojo/shell/context.h" | 19 #include "mojo/shell/context.h" |
| 19 #include "mojo/shell/data_pipe_peek.h" | 20 #include "mojo/shell/data_pipe_peek.h" |
| 20 #include "mojo/shell/filename_util.h" | 21 #include "mojo/shell/filename_util.h" |
| 21 #include "mojo/shell/switches.h" | 22 #include "mojo/shell/switches.h" |
| 22 #include "url/url_util.h" | 23 #include "url/url_util.h" |
| 23 | 24 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 load_callbacks, | 96 load_callbacks, |
| 96 loader_complete_callback), | 97 loader_complete_callback), |
| 97 weak_ptr_factory_(this) { | 98 weak_ptr_factory_(this) { |
| 98 DCHECK(url.SchemeIsFile()); | 99 DCHECK(url.SchemeIsFile()); |
| 99 url::RawCanonOutputW<1024> output; | 100 url::RawCanonOutputW<1024> output; |
| 100 url::DecodeURLEscapeSequences( | 101 url::DecodeURLEscapeSequences( |
| 101 url.path().data(), static_cast<int>(url.path().length()), &output); | 102 url.path().data(), static_cast<int>(url.path().length()), &output); |
| 102 base::string16 decoded_path = | 103 base::string16 decoded_path = |
| 103 base::string16(output.data(), output.length()); | 104 base::string16(output.data(), output.length()); |
| 104 #if defined(OS_WIN) | 105 #if defined(OS_WIN) |
| 106 base::TrimString(decoded_path, L"/", &decoded_path); |
| 105 base::FilePath path(decoded_path); | 107 base::FilePath path(decoded_path); |
| 106 #else | 108 #else |
| 107 base::FilePath path(base::UTF16ToUTF8(decoded_path)); | 109 base::FilePath path(base::UTF16ToUTF8(decoded_path)); |
| 108 #endif | 110 #endif |
| 109 | 111 |
| 110 // Async for consistency with network case. | 112 // Async for consistency with network case. |
| 111 base::MessageLoop::current()->PostTask( | 113 base::MessageLoop::current()->PostTask( |
| 112 FROM_HERE, | 114 FROM_HERE, |
| 113 base::Bind(&LocalLoader::RunLibrary, | 115 base::Bind(&LocalLoader::RunLibrary, |
| 114 weak_ptr_factory_.GetWeakPtr(), | 116 weak_ptr_factory_.GetWeakPtr(), |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 // TODO(darin): What should we do about service errors? This implies that | 299 // TODO(darin): What should we do about service errors? This implies that |
| 298 // the app closed its handle to the service manager. Maybe we don't care? | 300 // the app closed its handle to the service manager. Maybe we don't care? |
| 299 } | 301 } |
| 300 | 302 |
| 301 void DynamicApplicationLoader::LoaderComplete(Loader* loader) { | 303 void DynamicApplicationLoader::LoaderComplete(Loader* loader) { |
| 302 loaders_.erase(std::find(loaders_.begin(), loaders_.end(), loader)); | 304 loaders_.erase(std::find(loaders_.begin(), loaders_.end(), loader)); |
| 303 } | 305 } |
| 304 | 306 |
| 305 } // namespace shell | 307 } // namespace shell |
| 306 } // namespace mojo | 308 } // namespace mojo |
| OLD | NEW |