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 <sys/stat.h> | 7 #include <sys/stat.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 auto etag_header = mojo::HttpHeader::New(); | 74 auto etag_header = mojo::HttpHeader::New(); |
75 etag_header->name = "ETag"; | 75 etag_header->name = "ETag"; |
76 etag_header->value = base::StringPrintf( | 76 etag_header->value = base::StringPrintf( |
77 "\"%" PRId64 "-%" PRId64 "-%" PRId64 "\"", | 77 "\"%" PRId64 "-%" PRId64 "-%" PRId64 "\"", |
78 static_cast<uint64_t>(stat_result.st_dev), stat_result.st_ino, | 78 static_cast<uint64_t>(stat_result.st_dev), stat_result.st_ino, |
79 static_cast<uint64_t>(stat_result.st_mtime)); | 79 static_cast<uint64_t>(stat_result.st_mtime)); |
80 response->headers.push_back(etag_header.Pass()); | 80 response->headers.push_back(etag_header.Pass()); |
81 } | 81 } |
82 mojo::common::CopyFromFile(path_, data_pipe.producer_handle.Pass(), skip, | 82 mojo::common::CopyFromFile(path_, data_pipe.producer_handle.Pass(), skip, |
83 task_runner, base::Bind(&IgnoreResult)); | 83 task_runner, base::Bind(&IgnoreResult)); |
84 return response.Pass(); | 84 return response; |
85 } | 85 } |
86 | 86 |
87 void LocalFetcher::AsPath( | 87 void LocalFetcher::AsPath( |
88 base::TaskRunner* task_runner, | 88 base::TaskRunner* task_runner, |
89 base::Callback<void(const base::FilePath&, bool)> callback) { | 89 base::Callback<void(const base::FilePath&, bool)> callback) { |
90 // Async for consistency with network case. | 90 // Async for consistency with network case. |
91 base::MessageLoop::current()->PostTask( | 91 base::MessageLoop::current()->PostTask( |
92 FROM_HERE, base::Bind(callback, path_, base::PathExists(path_))); | 92 FROM_HERE, base::Bind(callback, path_, base::PathExists(path_))); |
93 } | 93 } |
94 | 94 |
95 std::string LocalFetcher::MimeType() { | 95 std::string LocalFetcher::MimeType() { |
96 return ""; | 96 return ""; |
97 } | 97 } |
98 | 98 |
99 bool LocalFetcher::HasMojoMagic() { | 99 bool LocalFetcher::HasMojoMagic() { |
100 return Fetcher::HasMojoMagic(path_); | 100 return Fetcher::HasMojoMagic(path_); |
101 } | 101 } |
102 | 102 |
103 bool LocalFetcher::PeekFirstLine(std::string* line) { | 103 bool LocalFetcher::PeekFirstLine(std::string* line) { |
104 return Fetcher::PeekFirstLine(path_, line); | 104 return Fetcher::PeekFirstLine(path_, line); |
105 } | 105 } |
106 | 106 |
107 } // namespace shell | 107 } // namespace shell |
OLD | NEW |