Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Unified Diff: net/tools/flip_server/mem_cache.cc

Issue 1548293002: Use scoped_ptr in Files-map and remove unused functions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« net/tools/flip_server/mem_cache.h ('K') | « net/tools/flip_server/mem_cache.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/flip_server/mem_cache.cc
diff --git a/net/tools/flip_server/mem_cache.cc b/net/tools/flip_server/mem_cache.cc
index 950a1a6056ed06dd6a0fd22b031e96ac3c6c0704..9dd71e359763d2f9cd79a0be864452ed7ea1d71b 100644
--- a/net/tools/flip_server/mem_cache.cc
+++ b/net/tools/flip_server/mem_cache.cc
@@ -65,15 +65,7 @@ FileData::FileData() {}
FileData::~FileData() {}
MemoryCache::MemoryCache() : cwd_(FLAGS_cache_base_dir) {}
-
-MemoryCache::~MemoryCache() { ClearFiles(); }
-
-void MemoryCache::CloneFrom(const MemoryCache& mc) {
- DCHECK_NE(this, &mc);
- ClearFiles();
- files_ = mc.files_;
- cwd_ = mc.cwd_;
-}
+MemoryCache::~MemoryCache() {}
void MemoryCache::AddFiles() {
std::deque<std::string> paths;
@@ -213,7 +205,8 @@ FileData* MemoryCache::GetFileData(const std::string& filename) {
if (fi == files_.end()) {
return NULL;
}
- return fi->second;
+ return fi->second.get();
+ ;
}
bool MemoryCache::AssignFileData(const std::string& filename,
@@ -235,18 +228,11 @@ void MemoryCache::InsertFile(const BalsaHeaders* headers,
void MemoryCache::InsertFile(FileData* file_data) {
Files::iterator it = files_.find(file_data->filename());
if (it != files_.end()) {
- delete it->second;
- it->second = file_data;
+ it->second.reset(file_data);
} else {
- files_.insert(std::make_pair(file_data->filename(), file_data));
- }
-}
-
-void MemoryCache::ClearFiles() {
- for (Files::const_iterator i = files_.begin(); i != files_.end(); ++i) {
- delete i->second;
+ files_.insert(
+ std::make_pair(file_data->filename(), make_scoped_ptr(file_data)));
}
- files_.clear();
}
} // namespace net
« net/tools/flip_server/mem_cache.h ('K') | « net/tools/flip_server/mem_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698