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 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 // |pool| and |sequence_token| are used to assert that the functions are | 28 // |pool| and |sequence_token| are used to assert that the functions are |
29 // called on the right sequenced worker pool with the right sequence token. | 29 // called on the right sequenced worker pool with the right sequence token. |
30 // | 30 // |
31 // For testing, the thread assertion can be disabled by passing NULL and | 31 // For testing, the thread assertion can be disabled by passing NULL and |
32 // the default value of SequenceToken. | 32 // the default value of SequenceToken. |
33 GDataCacheMetadata( | 33 GDataCacheMetadata( |
34 base::SequencedWorkerPool* pool, | 34 base::SequencedWorkerPool* pool, |
35 const base::SequencedWorkerPool::SequenceToken& sequence_token); | 35 const base::SequencedWorkerPool::SequenceToken& sequence_token); |
36 virtual ~GDataCacheMetadata(); | 36 virtual ~GDataCacheMetadata(); |
37 | 37 |
38 // Updates cache map with entry corresponding to |resource_id|. | 38 // Adds a new cache entry corresponding to |resource_id| if it doesn't |
39 // Creates new entry if it doesn't exist, otherwise update the entry. | 39 // exist, otherwise update the existing entry. |
40 virtual void UpdateCache(const std::string& resource_id, | 40 virtual void AddOrUpdateCacheEntry(const std::string& resource_id, |
41 const GDataCacheEntry& cache_entry) = 0; | 41 const GDataCacheEntry& cache_entry) = 0; |
42 | 42 |
43 // Removes entry corresponding to |resource_id| from cache map. | 43 // Removes entry corresponding to |resource_id| from cache map. |
44 virtual void RemoveFromCache(const std::string& resource_id) = 0; | 44 virtual void RemoveCacheEntry(const std::string& resource_id) = 0; |
45 | 45 |
46 // Returns the cache entry for file corresponding to |resource_id| and |md5| | 46 // Returns the cache entry for file corresponding to |resource_id| and |md5| |
47 // if entry exists in cache map. Otherwise, returns NULL. | 47 // if entry exists in cache map. Otherwise, returns NULL. |
48 // |md5| can be empty if only matching |resource_id| is desired, which may | 48 // |md5| can be empty if only matching |resource_id| is desired, which may |
49 // happen when looking for pinned entries where symlinks' filenames have no | 49 // happen when looking for pinned entries where symlinks' filenames have no |
50 // extension and hence no md5. | 50 // extension and hence no md5. |
51 virtual scoped_ptr<GDataCacheEntry> GetCacheEntry( | 51 virtual scoped_ptr<GDataCacheEntry> GetCacheEntry( |
52 const std::string& resource_id, | 52 const std::string& resource_id, |
53 const std::string& md5) = 0; | 53 const std::string& md5) = 0; |
54 | 54 |
(...skipping 21 matching lines...) Expand all Loading... |
76 public: | 76 public: |
77 GDataCacheMetadataMap( | 77 GDataCacheMetadataMap( |
78 base::SequencedWorkerPool* pool, | 78 base::SequencedWorkerPool* pool, |
79 const base::SequencedWorkerPool::SequenceToken& sequence_token); | 79 const base::SequencedWorkerPool::SequenceToken& sequence_token); |
80 virtual ~GDataCacheMetadataMap(); | 80 virtual ~GDataCacheMetadataMap(); |
81 | 81 |
82 // Initializes the data. | 82 // Initializes the data. |
83 void Initialize(const std::vector<FilePath>& cache_paths); | 83 void Initialize(const std::vector<FilePath>& cache_paths); |
84 | 84 |
85 // GDataCacheMetadata overrides: | 85 // GDataCacheMetadata overrides: |
86 virtual void UpdateCache( | 86 virtual void AddOrUpdateCacheEntry( |
87 const std::string& resource_id, | 87 const std::string& resource_id, |
88 const GDataCacheEntry& cache_entry) OVERRIDE; | 88 const GDataCacheEntry& cache_entry) OVERRIDE; |
89 virtual void RemoveFromCache(const std::string& resource_id) OVERRIDE; | 89 virtual void RemoveCacheEntry(const std::string& resource_id) OVERRIDE; |
90 virtual scoped_ptr<GDataCacheEntry> GetCacheEntry( | 90 virtual scoped_ptr<GDataCacheEntry> GetCacheEntry( |
91 const std::string& resource_id, | 91 const std::string& resource_id, |
92 const std::string& md5) OVERRIDE; | 92 const std::string& md5) OVERRIDE; |
93 virtual void RemoveTemporaryFiles() OVERRIDE; | 93 virtual void RemoveTemporaryFiles() OVERRIDE; |
94 virtual void Iterate(const IterateCallback& callback) OVERRIDE; | 94 virtual void Iterate(const IterateCallback& callback) OVERRIDE; |
95 | 95 |
96 // A map table of cache file's resource id to its CacheEntry* entry. | 96 // A map table of cache file's resource id to its CacheEntry* entry. |
97 typedef std::map<std::string, GDataCacheEntry> CacheMap; | 97 typedef std::map<std::string, GDataCacheEntry> CacheMap; |
98 | 98 |
99 // A map table of resource ID to file path. | 99 // A map table of resource ID to file path. |
(...skipping 20 matching lines...) Expand all Loading... |
120 const GDataCacheEntry& cache_entry); | 120 const GDataCacheEntry& cache_entry); |
121 | 121 |
122 CacheMap cache_map_; | 122 CacheMap cache_map_; |
123 | 123 |
124 DISALLOW_COPY_AND_ASSIGN(GDataCacheMetadataMap); | 124 DISALLOW_COPY_AND_ASSIGN(GDataCacheMetadataMap); |
125 }; | 125 }; |
126 | 126 |
127 } // namespace gdata | 127 } // namespace gdata |
128 | 128 |
129 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_METADATA_H_ | 129 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_METADATA_H_ |
OLD | NEW |