OLD | NEW |
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 const std::string& resource_id, | 178 const std::string& resource_id, |
179 const GDataCacheEntry& cache_entry) { | 179 const GDataCacheEntry& cache_entry) { |
180 AssertOnSequencedWorkerPool(); | 180 AssertOnSequencedWorkerPool(); |
181 | 181 |
182 CacheMap::iterator iter = cache_map_.find(resource_id); | 182 CacheMap::iterator iter = cache_map_.find(resource_id); |
183 if (iter == cache_map_.end()) { // New resource, create new entry. | 183 if (iter == cache_map_.end()) { // New resource, create new entry. |
184 cache_map_.insert(std::make_pair(resource_id, cache_entry)); | 184 cache_map_.insert(std::make_pair(resource_id, cache_entry)); |
185 DVLOG(1) << "Added resource_id=" << resource_id | 185 DVLOG(1) << "Added resource_id=" << resource_id |
186 << ", " << cache_entry.ToString(); | 186 << ", " << cache_entry.ToString(); |
187 } else { // Resource exists. | 187 } else { // Resource exists. |
188 iter->second.set_md5(cache_entry.md5()); | 188 cache_map_[resource_id] = cache_entry; |
189 iter->second.set_cache_state(cache_entry.cache_state()); | |
190 DVLOG(1) << "Updated resource_id=" << resource_id | 189 DVLOG(1) << "Updated resource_id=" << resource_id |
191 << ", " << iter->second.ToString(); | 190 << ", " << cache_entry.ToString(); |
192 } | 191 } |
193 } | 192 } |
194 | 193 |
195 void GDataCacheMetadataMap::RemoveCacheEntry(const std::string& resource_id) { | 194 void GDataCacheMetadataMap::RemoveCacheEntry(const std::string& resource_id) { |
196 AssertOnSequencedWorkerPool(); | 195 AssertOnSequencedWorkerPool(); |
197 | 196 |
198 CacheMap::iterator iter = cache_map_.find(resource_id); | 197 CacheMap::iterator iter = cache_map_.find(resource_id); |
199 if (iter != cache_map_.end()) { | 198 if (iter != cache_map_.end()) { |
200 // Delete the CacheEntry and remove it from the map. | 199 // Delete the CacheEntry and remove it from the map. |
201 cache_map_.erase(iter); | 200 cache_map_.erase(iter); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 // If the MD5 matching is not requested, don't check MD5. | 384 // If the MD5 matching is not requested, don't check MD5. |
386 return true; | 385 return true; |
387 } else if (md5 == cache_entry.md5()) { | 386 } else if (md5 == cache_entry.md5()) { |
388 // Otherwise, compare the MD5. | 387 // Otherwise, compare the MD5. |
389 return true; | 388 return true; |
390 } | 389 } |
391 return false; | 390 return false; |
392 } | 391 } |
393 | 392 |
394 } // namespace gdata | 393 } // namespace gdata |
OLD | NEW |