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/fetcher/network_fetcher.h" | 5 #include "mojo/fetcher/network_fetcher.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.h" | 9 #include "base/files/file.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // TODO(eseidel): All users of this log should move to using the map file. | 83 // TODO(eseidel): All users of this log should move to using the map file. |
84 VLOG(1) << "Caching mojo app " << url << " at " << path.value(); | 84 VLOG(1) << "Caching mojo app " << url << " at " << path.value(); |
85 | 85 |
86 base::FilePath temp_dir; | 86 base::FilePath temp_dir; |
87 base::GetTempDir(&temp_dir); | 87 base::GetTempDir(&temp_dir); |
88 base::ProcessId pid = base::Process::Current().Pid(); | 88 base::ProcessId pid = base::Process::Current().Pid(); |
89 std::string map_name = base::StringPrintf("mojo_shell.%d.maps", pid); | 89 std::string map_name = base::StringPrintf("mojo_shell.%d.maps", pid); |
90 base::FilePath map_path = temp_dir.AppendASCII(map_name); | 90 base::FilePath map_path = temp_dir.AppendASCII(map_name); |
91 | 91 |
92 // TODO(eseidel): Paths or URLs with spaces will need quoting. | 92 // TODO(eseidel): Paths or URLs with spaces will need quoting. |
| 93 #ifdef OS_WIN |
| 94 // FilePath::StringType is std::wstring on Windows |
| 95 std::string map_entry = |
| 96 base::StringPrintf("%ls %s\n", path.value().c_str(), url.spec().c_str()); |
| 97 #else |
93 std::string map_entry = | 98 std::string map_entry = |
94 base::StringPrintf("%s %s\n", path.value().c_str(), url.spec().c_str()); | 99 base::StringPrintf("%s %s\n", path.value().c_str(), url.spec().c_str()); |
| 100 #endif |
95 // TODO(eseidel): AppendToFile is missing O_CREAT, crbug.com/450696 | 101 // TODO(eseidel): AppendToFile is missing O_CREAT, crbug.com/450696 |
96 if (!PathExists(map_path)) { | 102 if (!PathExists(map_path)) { |
97 base::WriteFile(map_path, map_entry.data(), | 103 base::WriteFile(map_path, map_entry.data(), |
98 static_cast<int>(map_entry.length())); | 104 static_cast<int>(map_entry.length())); |
99 } else { | 105 } else { |
100 base::AppendToFile(map_path, map_entry.data(), | 106 base::AppendToFile(map_path, map_entry.data(), |
101 static_cast<int>(map_entry.length())); | 107 static_cast<int>(map_entry.length())); |
102 } | 108 } |
103 } | 109 } |
104 | 110 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 loader_callback_.Run(nullptr); | 247 loader_callback_.Run(nullptr); |
242 return; | 248 return; |
243 } | 249 } |
244 | 250 |
245 response_ = response.Pass(); | 251 response_ = response.Pass(); |
246 loader_callback_.Run(owner.Pass()); | 252 loader_callback_.Run(owner.Pass()); |
247 } | 253 } |
248 | 254 |
249 } // namespace fetcher | 255 } // namespace fetcher |
250 } // namespace mojo | 256 } // namespace mojo |
OLD | NEW |