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/local_fetcher.h" | 5 #include "mojo/shell/fetcher/local_fetcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
20 #include "mojo/common/common_type_converters.h" | 20 #include "mojo/common/common_type_converters.h" |
21 #include "mojo/common/data_pipe_utils.h" | 21 #include "mojo/common/data_pipe_utils.h" |
22 #include "mojo/common/url_type_converters.h" | 22 #include "mojo/common/url_type_converters.h" |
23 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 23 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
24 #include "mojo/shell/switches.h" | 24 #include "mojo/shell/switches.h" |
25 #include "mojo/util/filename_util.h" | 25 #include "mojo/util/filename_util.h" |
26 #include "url/url_util.h" | 26 #include "url/url_util.h" |
27 | 27 |
28 namespace mojo { | 28 namespace mojo { |
29 namespace fetcher { | 29 namespace shell { |
30 | 30 |
31 namespace { | 31 namespace { |
32 void IgnoreResult(bool result) { | 32 void IgnoreResult(bool result) { |
33 } | 33 } |
34 | 34 |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 // A loader for local files. | 37 // A loader for local files. |
38 LocalFetcher::LocalFetcher(NetworkService* network_service, | 38 LocalFetcher::LocalFetcher(NetworkService* network_service, |
39 const GURL& url, | 39 const GURL& url, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 bool LocalFetcher::PeekFirstLine(std::string* line) { | 142 bool LocalFetcher::PeekFirstLine(std::string* line) { |
143 std::string start_of_file; | 143 std::string start_of_file; |
144 ReadFileToString(path_, &start_of_file, kMaxShebangLength); | 144 ReadFileToString(path_, &start_of_file, kMaxShebangLength); |
145 size_t return_position = start_of_file.find('\n'); | 145 size_t return_position = start_of_file.find('\n'); |
146 if (return_position == std::string::npos) | 146 if (return_position == std::string::npos) |
147 return false; | 147 return false; |
148 *line = start_of_file.substr(0, return_position + 1); | 148 *line = start_of_file.substr(0, return_position + 1); |
149 return true; | 149 return true; |
150 } | 150 } |
151 | 151 |
152 } // namespace fetcher | 152 } // namespace shell |
153 } // namespace mojo | 153 } // namespace mojo |
OLD | NEW |