| 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 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_METADATA_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_METADATA_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_METADATA_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_METADATA_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // Updates cache map with entry corresponding to |resource_id|. | 39 // Updates cache map with entry corresponding to |resource_id|. |
| 40 // Creates new entry if it doesn't exist, otherwise update the entry. | 40 // Creates new entry if it doesn't exist, otherwise update the entry. |
| 41 virtual void UpdateCache(const std::string& resource_id, | 41 virtual void UpdateCache(const std::string& resource_id, |
| 42 const std::string& md5, | 42 const std::string& md5, |
| 43 int cache_state) = 0; | 43 int cache_state) = 0; |
| 44 | 44 |
| 45 // Removes entry corresponding to |resource_id| from cache map. | 45 // Removes entry corresponding to |resource_id| from cache map. |
| 46 virtual void RemoveFromCache(const std::string& resource_id) = 0; | 46 virtual void RemoveFromCache(const std::string& resource_id) = 0; |
| 47 | 47 |
| 48 // Returns the cache entry for file corresponding to |resource_id| and |md5| | 48 // Gets the cache entry for file corresponding to |resource_id| and |md5| |
| 49 // if entry exists in cache map. Otherwise, returns NULL. | 49 // and returns true if entry exists in cache map. Otherwise, returns false. |
| 50 // |md5| can be empty if only matching |resource_id| is desired, which may | 50 // |md5| can be empty if only matching |resource_id| is desired, which may |
| 51 // happen when looking for pinned entries where symlinks' filenames have no | 51 // happen when looking for pinned entries where symlinks' filenames have no |
| 52 // extension and hence no md5. | 52 // extension and hence no md5. |
| 53 virtual scoped_ptr<GDataCache::CacheEntry> GetCacheEntry( | 53 virtual bool GetCacheEntry(const std::string& resource_id, |
| 54 const std::string& resource_id, | 54 const std::string& md5, |
| 55 const std::string& md5) = 0; | 55 GDataCache::CacheEntry* entry) = 0; |
| 56 | 56 |
| 57 // Removes temporary files (files in CACHE_TYPE_TMP) from the cache map. | 57 // Removes temporary files (files in CACHE_TYPE_TMP) from the cache map. |
| 58 virtual void RemoveTemporaryFiles() = 0; | 58 virtual void RemoveTemporaryFiles() = 0; |
| 59 | 59 |
| 60 // Iterates over all the cache entries synchronously. |callback| is called | 60 // Iterates over all the cache entries synchronously. |callback| is called |
| 61 // on each cache entry. | 61 // on each cache entry. |
| 62 virtual void Iterate(const IterateCallback& callback) = 0; | 62 virtual void Iterate(const IterateCallback& callback) = 0; |
| 63 | 63 |
| 64 protected: | 64 protected: |
| 65 // Checks whether the current thread is on the right sequenced worker pool | 65 // Checks whether the current thread is on the right sequenced worker pool |
| (...skipping 16 matching lines...) Expand all Loading... |
| 82 virtual ~GDataCacheMetadataMap(); | 82 virtual ~GDataCacheMetadataMap(); |
| 83 | 83 |
| 84 // Initializes the data. | 84 // Initializes the data. |
| 85 void Initialize(const std::vector<FilePath>& cache_paths); | 85 void Initialize(const std::vector<FilePath>& cache_paths); |
| 86 | 86 |
| 87 // GDataCacheMetadata overrides: | 87 // GDataCacheMetadata overrides: |
| 88 virtual void UpdateCache(const std::string& resource_id, | 88 virtual void UpdateCache(const std::string& resource_id, |
| 89 const std::string& md5, | 89 const std::string& md5, |
| 90 int cache_state) OVERRIDE; | 90 int cache_state) OVERRIDE; |
| 91 virtual void RemoveFromCache(const std::string& resource_id) OVERRIDE; | 91 virtual void RemoveFromCache(const std::string& resource_id) OVERRIDE; |
| 92 virtual scoped_ptr<GDataCache::CacheEntry> GetCacheEntry( | 92 virtual bool GetCacheEntry(const std::string& resource_id, |
| 93 const std::string& resource_id, | 93 const std::string& md5, |
| 94 const std::string& md5) OVERRIDE; | 94 GDataCache::CacheEntry* entry) OVERRIDE; |
| 95 virtual void RemoveTemporaryFiles() OVERRIDE; | 95 virtual void RemoveTemporaryFiles() OVERRIDE; |
| 96 virtual void Iterate(const IterateCallback& callback) OVERRIDE; | 96 virtual void Iterate(const IterateCallback& callback) OVERRIDE; |
| 97 | 97 |
| 98 // A map table of cache file's resource id to its CacheEntry* entry. | 98 // A map table of cache file's resource id to its CacheEntry* entry. |
| 99 typedef std::map<std::string, GDataCache::CacheEntry> CacheMap; | 99 typedef std::map<std::string, GDataCache::CacheEntry> CacheMap; |
| 100 | 100 |
| 101 // A map table of resource ID to file path. | 101 // A map table of resource ID to file path. |
| 102 typedef std::map<std::string, FilePath> ResourceIdToFilePathMap; | 102 typedef std::map<std::string, FilePath> ResourceIdToFilePathMap; |
| 103 | 103 |
| 104 private: | 104 private: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 122 const GDataCache::CacheEntry& cache_entry); | 122 const GDataCache::CacheEntry& cache_entry); |
| 123 | 123 |
| 124 CacheMap cache_map_; | 124 CacheMap cache_map_; |
| 125 | 125 |
| 126 DISALLOW_COPY_AND_ASSIGN(GDataCacheMetadataMap); | 126 DISALLOW_COPY_AND_ASSIGN(GDataCacheMetadataMap); |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 } // namespace gdata | 129 } // namespace gdata |
| 130 | 130 |
| 131 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_METADATA_H_ | 131 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_METADATA_H_ |
| OLD | NEW |