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 "shell/application_manager/local_fetcher.h" | 5 #include "shell/application_manager/local_fetcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 base::string16 decoded_path = base::string16(output.data(), output.length()); | 38 base::string16 decoded_path = base::string16(output.data(), output.length()); |
39 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
40 base::TrimString(decoded_path, L"/", &decoded_path); | 40 base::TrimString(decoded_path, L"/", &decoded_path); |
41 base::FilePath path(decoded_path); | 41 base::FilePath path(decoded_path); |
42 #else | 42 #else |
43 base::FilePath path(base::UTF16ToUTF8(decoded_path)); | 43 base::FilePath path(base::UTF16ToUTF8(decoded_path)); |
44 #endif | 44 #endif |
45 return path; | 45 return path; |
46 } | 46 } |
47 | 47 |
| 48 const GURL& LocalFetcher::GetURL() const { |
| 49 return url_; |
| 50 } |
| 51 |
| 52 GURL LocalFetcher::GetRedirectURL() const { |
| 53 return GURL::EmptyGURL(); |
| 54 } |
| 55 |
48 URLResponsePtr LocalFetcher::AsURLResponse(base::TaskRunner* task_runner, | 56 URLResponsePtr LocalFetcher::AsURLResponse(base::TaskRunner* task_runner, |
49 uint32_t skip) { | 57 uint32_t skip) { |
50 URLResponsePtr response(URLResponse::New()); | 58 URLResponsePtr response(URLResponse::New()); |
51 response->url = String::From(url_); | 59 response->url = String::From(url_); |
52 DataPipe data_pipe; | 60 DataPipe data_pipe; |
53 response->body = data_pipe.consumer_handle.Pass(); | 61 response->body = data_pipe.consumer_handle.Pass(); |
54 int64 file_size; | 62 int64 file_size; |
55 if (base::GetFileSize(path_, &file_size)) { | 63 if (base::GetFileSize(path_, &file_size)) { |
56 response->headers = Array<String>(1); | 64 response->headers = Array<String>(1); |
57 response->headers[0] = | 65 response->headers[0] = |
(...skipping 26 matching lines...) Expand all Loading... |
84 std::string start_of_file; | 92 std::string start_of_file; |
85 ReadFileToString(path_, &start_of_file, kMaxShebangLength); | 93 ReadFileToString(path_, &start_of_file, kMaxShebangLength); |
86 size_t return_position = start_of_file.find('\n'); | 94 size_t return_position = start_of_file.find('\n'); |
87 if (return_position == std::string::npos) | 95 if (return_position == std::string::npos) |
88 return false; | 96 return false; |
89 *line = start_of_file.substr(0, return_position + 1); | 97 *line = start_of_file.substr(0, return_position + 1); |
90 return true; | 98 return true; |
91 } | 99 } |
92 | 100 |
93 } // namespace mojo | 101 } // namespace mojo |
OLD | NEW |