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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_cache_metadata.cc

Issue 10581038: chromeos: Stop returning scoped_ptr from GDataCache::GetCacheEntry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: _ Created 8 years, 6 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/gdata/gdata_cache_metadata.h" 5 #include "chrome/browser/chromeos/gdata/gdata_cache_metadata.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "chrome/browser/chromeos/gdata/gdata_util.h" 8 #include "chrome/browser/chromeos/gdata/gdata_util.h"
9 9
10 namespace gdata { 10 namespace gdata {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 void GDataCacheMetadataMap::RemoveFromCache(const std::string& resource_id) { 147 void GDataCacheMetadataMap::RemoveFromCache(const std::string& resource_id) {
148 AssertOnSequencedWorkerPool(); 148 AssertOnSequencedWorkerPool();
149 149
150 CacheMap::iterator iter = cache_map_.find(resource_id); 150 CacheMap::iterator iter = cache_map_.find(resource_id);
151 if (iter != cache_map_.end()) { 151 if (iter != cache_map_.end()) {
152 // Delete the CacheEntry and remove it from the map. 152 // Delete the CacheEntry and remove it from the map.
153 cache_map_.erase(iter); 153 cache_map_.erase(iter);
154 } 154 }
155 } 155 }
156 156
157 scoped_ptr<GDataCache::CacheEntry> GDataCacheMetadataMap::GetCacheEntry( 157 bool GDataCacheMetadataMap::GetCacheEntry(const std::string& resource_id,
158 const std::string& resource_id, 158 const std::string& md5,
159 const std::string& md5) { 159 GDataCache::CacheEntry* entry) {
satorux1 2012/06/20 15:29:23 add DCHECK(entry); ?
hashimoto 2012/07/11 12:01:56 Done.
160 AssertOnSequencedWorkerPool(); 160 AssertOnSequencedWorkerPool();
161 161
162 CacheMap::iterator iter = cache_map_.find(resource_id); 162 CacheMap::iterator iter = cache_map_.find(resource_id);
163 if (iter == cache_map_.end()) { 163 if (iter == cache_map_.end()) {
164 DVLOG(1) << "Can't find " << resource_id << " in cache map"; 164 DVLOG(1) << "Can't find " << resource_id << " in cache map";
165 return scoped_ptr<GDataCache::CacheEntry>(); 165 return false;
166 } 166 }
167 167
168 scoped_ptr<GDataCache::CacheEntry> cache_entry( 168 GDataCache::CacheEntry cache_entry(iter->second);
satorux1 2012/06/20 15:29:23 *entry = iter->second ? then, you don't have to co
hashimoto 2012/06/20 15:38:35 I'd like to keep this copying code since I think i
satorux1 2012/06/20 15:41:20 Good point. Then, you might want to make it a cons
hashimoto 2012/06/20 15:45:30 Oh, I thought CacheEntry(iter->second) was doing s
hashimoto 2012/07/11 12:01:56 Done.
169 new GDataCache::CacheEntry(iter->second));
170 169
171 if (!CheckIfMd5Matches(md5, *cache_entry)) { 170 if (!CheckIfMd5Matches(md5, cache_entry)) {
172 DVLOG(1) << "Non-matching md5: want=" << md5 171 DVLOG(1) << "Non-matching md5: want=" << md5
173 << ", found=[res_id=" << resource_id 172 << ", found=[res_id=" << resource_id
174 << ", " << cache_entry->ToString() 173 << ", " << cache_entry.ToString()
175 << "]"; 174 << "]";
176 return scoped_ptr<GDataCache::CacheEntry>(); 175 return false;
177 } 176 }
178 177
179 DVLOG(1) << "Found entry for res_id=" << resource_id 178 DVLOG(1) << "Found entry for res_id=" << resource_id
180 << ", " << cache_entry->ToString(); 179 << ", " << cache_entry.ToString();
181 180
182 return cache_entry.Pass(); 181 *entry = cache_entry;
182 return true;
183 } 183 }
184 184
185 void GDataCacheMetadataMap::RemoveTemporaryFiles() { 185 void GDataCacheMetadataMap::RemoveTemporaryFiles() {
186 AssertOnSequencedWorkerPool(); 186 AssertOnSequencedWorkerPool();
187 187
188 CacheMap::iterator iter = cache_map_.begin(); 188 CacheMap::iterator iter = cache_map_.begin();
189 while (iter != cache_map_.end()) { 189 while (iter != cache_map_.end()) {
190 if (iter->second.sub_dir_type == GDataCache::CACHE_TYPE_TMP) { 190 if (iter->second.sub_dir_type == GDataCache::CACHE_TYPE_TMP) {
191 // Post-increment the iterator to avoid iterator invalidation. 191 // Post-increment the iterator to avoid iterator invalidation.
192 cache_map_.erase(iter++); 192 cache_map_.erase(iter++);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 // If the MD5 matching is not requested, don't check MD5. 287 // If the MD5 matching is not requested, don't check MD5.
288 return true; 288 return true;
289 } else if (md5 == cache_entry.md5) { 289 } else if (md5 == cache_entry.md5) {
290 // Otherwise, compare the MD5. 290 // Otherwise, compare the MD5.
291 return true; 291 return true;
292 } 292 }
293 return false; 293 return false;
294 } 294 }
295 295
296 } // namespace gdata 296 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698