OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "net/tools/flip_server/mem_cache.h" | 5 #include "net/tools/flip_server/mem_cache.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 size_t slash_pos = filename_stripped.find('/'); | 197 size_t slash_pos = filename_stripped.find('/'); |
198 if (slash_pos == std::string::npos) { | 198 if (slash_pos == std::string::npos) { |
199 slash_pos = filename_stripped.size(); | 199 slash_pos = filename_stripped.size(); |
200 } | 200 } |
201 InsertFile( | 201 InsertFile( |
202 &visitor.headers, filename_stripped.substr(0, slash_pos), visitor.body); | 202 &visitor.headers, filename_stripped.substr(0, slash_pos), visitor.body); |
203 } | 203 } |
204 | 204 |
205 FileData* MemoryCache::GetFileData(const std::string& filename) { | 205 FileData* MemoryCache::GetFileData(const std::string& filename) { |
206 Files::iterator fi = files_.end(); | 206 Files::iterator fi = files_.end(); |
207 if (EndsWith(filename, ".html", true)) { | 207 if (base::EndsWith(filename, ".html", true)) { |
208 fi = files_.find(filename.substr(0, filename.size() - 5) + ".http"); | 208 fi = files_.find(filename.substr(0, filename.size() - 5) + ".http"); |
209 } | 209 } |
210 if (fi == files_.end()) | 210 if (fi == files_.end()) |
211 fi = files_.find(filename); | 211 fi = files_.find(filename); |
212 | 212 |
213 if (fi == files_.end()) { | 213 if (fi == files_.end()) { |
214 return NULL; | 214 return NULL; |
215 } | 215 } |
216 return fi->second; | 216 return fi->second; |
217 } | 217 } |
(...skipping 25 matching lines...) Expand all Loading... |
243 } | 243 } |
244 | 244 |
245 void MemoryCache::ClearFiles() { | 245 void MemoryCache::ClearFiles() { |
246 for (Files::const_iterator i = files_.begin(); i != files_.end(); ++i) { | 246 for (Files::const_iterator i = files_.begin(); i != files_.end(); ++i) { |
247 delete i->second; | 247 delete i->second; |
248 } | 248 } |
249 files_.clear(); | 249 files_.clear(); |
250 } | 250 } |
251 | 251 |
252 } // namespace net | 252 } // namespace net |
OLD | NEW |