| 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/shell/local_fetcher.h" | 5 #include "mojo/shell/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 } | 38 } |
| 39 | 39 |
| 40 const GURL& LocalFetcher::GetURL() const { | 40 const GURL& LocalFetcher::GetURL() const { |
| 41 return url_; | 41 return url_; |
| 42 } | 42 } |
| 43 | 43 |
| 44 GURL LocalFetcher::GetRedirectURL() const { | 44 GURL LocalFetcher::GetRedirectURL() const { |
| 45 return GURL::EmptyGURL(); | 45 return GURL::EmptyGURL(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 GURL LocalFetcher::GetRedirectReferer() const { |
| 49 return GURL::EmptyGURL(); |
| 50 } |
| 51 |
| 48 URLResponsePtr LocalFetcher::AsURLResponse(base::TaskRunner* task_runner, | 52 URLResponsePtr LocalFetcher::AsURLResponse(base::TaskRunner* task_runner, |
| 49 uint32_t skip) { | 53 uint32_t skip) { |
| 50 URLResponsePtr response(URLResponse::New()); | 54 URLResponsePtr response(URLResponse::New()); |
| 51 response->url = String::From(url_); | 55 response->url = String::From(url_); |
| 52 DataPipe data_pipe; | 56 DataPipe data_pipe; |
| 53 response->body = data_pipe.consumer_handle.Pass(); | 57 response->body = data_pipe.consumer_handle.Pass(); |
| 54 int64 file_size; | 58 int64 file_size; |
| 55 if (base::GetFileSize(path_, &file_size)) { | 59 if (base::GetFileSize(path_, &file_size)) { |
| 56 response->headers = Array<HttpHeaderPtr>(1); | 60 response->headers = Array<HttpHeaderPtr>(1); |
| 57 HttpHeaderPtr header = HttpHeader::New(); | 61 HttpHeaderPtr header = HttpHeader::New(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 87 ReadFileToString(path_, &start_of_file, kMaxShebangLength); | 91 ReadFileToString(path_, &start_of_file, kMaxShebangLength); |
| 88 size_t return_position = start_of_file.find('\n'); | 92 size_t return_position = start_of_file.find('\n'); |
| 89 if (return_position == std::string::npos) | 93 if (return_position == std::string::npos) |
| 90 return false; | 94 return false; |
| 91 *line = start_of_file.substr(0, return_position + 1); | 95 *line = start_of_file.substr(0, return_position + 1); |
| 92 return true; | 96 return true; |
| 93 } | 97 } |
| 94 | 98 |
| 95 } // namespace shell | 99 } // namespace shell |
| 96 } // namespace mojo | 100 } // namespace mojo |
| OLD | NEW |