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/fetcher/local_fetcher.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <utility> | 10 #include <utility> |
8 | 11 |
9 #include "base/bind.h" | 12 #include "base/bind.h" |
10 #include "base/command_line.h" | 13 #include "base/command_line.h" |
11 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
12 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
13 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
14 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
16 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 GURL LocalFetcher::GetRedirectReferer() const { | 100 GURL LocalFetcher::GetRedirectReferer() const { |
98 return GURL::EmptyGURL(); | 101 return GURL::EmptyGURL(); |
99 } | 102 } |
100 | 103 |
101 URLResponsePtr LocalFetcher::AsURLResponse(base::TaskRunner* task_runner, | 104 URLResponsePtr LocalFetcher::AsURLResponse(base::TaskRunner* task_runner, |
102 uint32_t skip) { | 105 uint32_t skip) { |
103 URLResponsePtr response(URLResponse::New()); | 106 URLResponsePtr response(URLResponse::New()); |
104 response->url = String::From(url_); | 107 response->url = String::From(url_); |
105 DataPipe data_pipe; | 108 DataPipe data_pipe; |
106 response->body = std::move(data_pipe.consumer_handle); | 109 response->body = std::move(data_pipe.consumer_handle); |
107 int64 file_size; | 110 int64_t file_size; |
108 if (base::GetFileSize(path_, &file_size)) { | 111 if (base::GetFileSize(path_, &file_size)) { |
109 response->headers = Array<HttpHeaderPtr>(1); | 112 response->headers = Array<HttpHeaderPtr>(1); |
110 HttpHeaderPtr header = HttpHeader::New(); | 113 HttpHeaderPtr header = HttpHeader::New(); |
111 header->name = "Content-Length"; | 114 header->name = "Content-Length"; |
112 header->value = base::StringPrintf("%" PRId64, file_size); | 115 header->value = base::StringPrintf("%" PRId64, file_size); |
113 response->headers[0] = std::move(header); | 116 response->headers[0] = std::move(header); |
114 } | 117 } |
115 response->mime_type = String::From(MimeType()); | 118 response->mime_type = String::From(MimeType()); |
116 common::CopyFromFile(path_, std::move(data_pipe.producer_handle), skip, | 119 common::CopyFromFile(path_, std::move(data_pipe.producer_handle), skip, |
117 task_runner, base::Bind(&IgnoreResult)); | 120 task_runner, base::Bind(&IgnoreResult)); |
(...skipping 23 matching lines...) Expand all Loading... |
141 ReadFileToString(path_, &start_of_file, kMaxShebangLength); | 144 ReadFileToString(path_, &start_of_file, kMaxShebangLength); |
142 size_t return_position = start_of_file.find('\n'); | 145 size_t return_position = start_of_file.find('\n'); |
143 if (return_position == std::string::npos) | 146 if (return_position == std::string::npos) |
144 return false; | 147 return false; |
145 *line = start_of_file.substr(0, return_position + 1); | 148 *line = start_of_file.substr(0, return_position + 1); |
146 return true; | 149 return true; |
147 } | 150 } |
148 | 151 |
149 } // namespace fetcher | 152 } // namespace fetcher |
150 } // namespace mojo | 153 } // namespace mojo |
OLD | NEW |