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 "services/url_response_disk_cache/url_response_disk_cache_impl.h" | 5 #include "services/url_response_disk_cache/url_response_disk_cache_impl.h" |
6 | 6 |
7 #include <type_traits> | 7 #include <type_traits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } | 139 } |
140 | 140 |
141 // Returns the list of values for the given |header_name| in the given list of | 141 // Returns the list of values for the given |header_name| in the given list of |
142 // headers. | 142 // headers. |
143 template <typename HeaderType> | 143 template <typename HeaderType> |
144 std::vector<std::string> GetHeaderValues(const std::string& header_name, | 144 std::vector<std::string> GetHeaderValues(const std::string& header_name, |
145 const Array<HeaderType>& headers) { | 145 const Array<HeaderType>& headers) { |
146 std::vector<std::string> result; | 146 std::vector<std::string> result; |
147 for (size_t i = 0u; i < headers.size(); ++i) { | 147 for (size_t i = 0u; i < headers.size(); ++i) { |
148 std::string name = headers[i]->name; | 148 std::string name = headers[i]->name; |
149 if (LowerCaseEqualsASCII(name, header_name.c_str())) | 149 if (base::LowerCaseEqualsASCII(name, header_name.c_str())) |
150 result.push_back(headers[i]->value); | 150 result.push_back(headers[i]->value); |
151 } | 151 } |
152 return result; | 152 return result; |
153 } | 153 } |
154 | 154 |
155 // Returns whether the given directory |dir| constains a valid entry file for | 155 // Returns whether the given directory |dir| constains a valid entry file for |
156 // the given |response|. If this is the case and |output| is not |nullptr|, then | 156 // the given |response|. If this is the case and |output| is not |nullptr|, then |
157 // the deserialized entry is returned in |*output|. | 157 // the deserialized entry is returned in |*output|. |
158 bool IsCacheEntryValid(const base::FilePath& dir, | 158 bool IsCacheEntryValid(const base::FilePath& dir, |
159 URLResponse* response, | 159 URLResponse* response, |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 return; | 329 return; |
330 } | 330 } |
331 } | 331 } |
332 // We can ignore write error, as it will just force to clear the cache on the | 332 // We can ignore write error, as it will just force to clear the cache on the |
333 // next request. | 333 // next request. |
334 WriteFile(GetExtractedSentinel(base_dir), nullptr, 0); | 334 WriteFile(GetExtractedSentinel(base_dir), nullptr, 0); |
335 callback.Run(extracted_dir, cache_dir); | 335 callback.Run(extracted_dir, cache_dir); |
336 } | 336 } |
337 | 337 |
338 } // namespace mojo | 338 } // namespace mojo |
OLD | NEW |