| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 FileData::FileData(const BalsaHeaders* headers, | 53 FileData::FileData(const BalsaHeaders* headers, |
| 54 const std::string& filename, | 54 const std::string& filename, |
| 55 const std::string& body) | 55 const std::string& body) |
| 56 : filename_(filename), body_(body) { | 56 : filename_(filename), body_(body) { |
| 57 if (headers) { | 57 if (headers) { |
| 58 headers_.reset(new BalsaHeaders); | 58 headers_.reset(new BalsaHeaders); |
| 59 headers_->CopyFrom(*headers); | 59 headers_->CopyFrom(*headers); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 | 62 |
| 63 FileData::FileData() {} | 63 FileData::FileData() { |
| 64 } |
| 64 | 65 |
| 65 FileData::~FileData() {} | 66 FileData::~FileData() { |
| 67 } |
| 66 | 68 |
| 67 MemoryCache::MemoryCache() : cwd_(FLAGS_cache_base_dir) {} | 69 MemoryCache::MemoryCache() : cwd_(FLAGS_cache_base_dir) { |
| 70 } |
| 68 | 71 |
| 69 MemoryCache::~MemoryCache() { ClearFiles(); } | 72 MemoryCache::~MemoryCache() { |
| 73 ClearFiles(); |
| 74 } |
| 70 | 75 |
| 71 void MemoryCache::CloneFrom(const MemoryCache& mc) { | 76 void MemoryCache::CloneFrom(const MemoryCache& mc) { |
| 72 DCHECK_NE(this, &mc); | 77 DCHECK_NE(this, &mc); |
| 73 ClearFiles(); | 78 ClearFiles(); |
| 74 files_ = mc.files_; | 79 files_ = mc.files_; |
| 75 cwd_ = mc.cwd_; | 80 cwd_ = mc.cwd_; |
| 76 } | 81 } |
| 77 | 82 |
| 78 void MemoryCache::AddFiles() { | 83 void MemoryCache::AddFiles() { |
| 79 std::deque<std::string> paths; | 84 std::deque<std::string> paths; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 248 } |
| 244 | 249 |
| 245 void MemoryCache::ClearFiles() { | 250 void MemoryCache::ClearFiles() { |
| 246 for (Files::const_iterator i = files_.begin(); i != files_.end(); ++i) { | 251 for (Files::const_iterator i = files_.begin(); i != files_.end(); ++i) { |
| 247 delete i->second; | 252 delete i->second; |
| 248 } | 253 } |
| 249 files_.clear(); | 254 files_.clear(); |
| 250 } | 255 } |
| 251 | 256 |
| 252 } // namespace net | 257 } // namespace net |
| OLD | NEW |