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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 if (base::EndsWith(filename, ".html", base::CompareCase::SENSITIVE)) { | 199 if (base::EndsWith(filename, ".html", base::CompareCase::SENSITIVE)) { |
200 fi = files_.find(filename.substr(0, filename.size() - 5) + ".http"); | 200 fi = files_.find(filename.substr(0, filename.size() - 5) + ".http"); |
201 } | 201 } |
202 if (fi == files_.end()) | 202 if (fi == files_.end()) |
203 fi = files_.find(filename); | 203 fi = files_.find(filename); |
204 | 204 |
205 if (fi == files_.end()) { | 205 if (fi == files_.end()) { |
206 return NULL; | 206 return NULL; |
207 } | 207 } |
208 return fi->second.get(); | 208 return fi->second.get(); |
209 ; | |
210 } | 209 } |
211 | 210 |
212 bool MemoryCache::AssignFileData(const std::string& filename, | 211 bool MemoryCache::AssignFileData(const std::string& filename, |
213 MemCacheIter* mci) { | 212 MemCacheIter* mci) { |
214 mci->file_data = GetFileData(filename); | 213 mci->file_data = GetFileData(filename); |
215 if (mci->file_data == NULL) { | 214 if (mci->file_data == NULL) { |
216 LOG(ERROR) << "Could not find file data for " << filename; | 215 LOG(ERROR) << "Could not find file data for " << filename; |
217 return false; | 216 return false; |
218 } | 217 } |
219 return true; | 218 return true; |
220 } | 219 } |
221 | 220 |
222 void MemoryCache::InsertFile(const BalsaHeaders* headers, | 221 void MemoryCache::InsertFile(const BalsaHeaders* headers, |
223 const std::string& filename, | 222 const std::string& filename, |
224 const std::string& body) { | 223 const std::string& body) { |
225 InsertFile(new FileData(headers, filename, body)); | 224 InsertFile(new FileData(headers, filename, body)); |
226 } | 225 } |
227 | 226 |
228 void MemoryCache::InsertFile(FileData* file_data) { | 227 void MemoryCache::InsertFile(FileData* file_data) { |
229 Files::iterator it = files_.find(file_data->filename()); | 228 Files::iterator it = files_.find(file_data->filename()); |
230 if (it != files_.end()) { | 229 if (it != files_.end()) { |
231 it->second.reset(file_data); | 230 it->second.reset(file_data); |
232 } else { | 231 } else { |
233 files_.insert( | 232 files_.insert( |
234 std::make_pair(file_data->filename(), make_scoped_ptr(file_data))); | 233 std::make_pair(file_data->filename(), make_scoped_ptr(file_data))); |
235 } | 234 } |
236 } | 235 } |
237 | 236 |
238 } // namespace net | 237 } // namespace net |
OLD | NEW |