| 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 <vector> | 9 #include <vector> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // Callback for Iterate(). | 24 // Callback for Iterate(). |
| 25 typedef base::Callback<void(const std::string& resource_id, | 25 typedef base::Callback<void(const std::string& resource_id, |
| 26 const GDataCacheEntry& cache_entry)> | 26 const GDataCacheEntry& cache_entry)> |
| 27 IterateCallback; | 27 IterateCallback; |
| 28 | 28 |
| 29 // A map table of cache file's resource id to its CacheEntry* entry. | 29 // A map table of cache file's resource id to its CacheEntry* entry. |
| 30 typedef std::map<std::string, GDataCacheEntry> CacheMap; | 30 typedef std::map<std::string, GDataCacheEntry> CacheMap; |
| 31 | 31 |
| 32 virtual ~GDataCacheMetadata(); | 32 virtual ~GDataCacheMetadata(); |
| 33 | 33 |
| 34 // |pool| and |sequence_token| are used to assert that the functions are | 34 // Creates GDataCacheMetadata instance. |
| 35 // called on the right sequenced worker pool with the right sequence token. | |
| 36 // | |
| 37 // For testing, the thread assertion can be disabled by passing NULL and | |
| 38 // the default value of SequenceToken. | |
| 39 static scoped_ptr<GDataCacheMetadata> CreateGDataCacheMetadata( | 35 static scoped_ptr<GDataCacheMetadata> CreateGDataCacheMetadata( |
| 40 base::SequencedTaskRunner* blocking_task_runner); | 36 base::SequencedTaskRunner* blocking_task_runner); |
| 41 | 37 |
| 38 // Creates GDataCacheMetadata instance. This uses FakeGDataCacheMetadata, |
| 39 // which is an in-memory implmentation and faster than GDataCacheMetadataDB. |
| 40 static scoped_ptr<GDataCacheMetadata> CreateGDataCacheMetadataForTesting( |
| 41 base::SequencedTaskRunner* blocking_task_runner); |
| 42 |
| 42 // Initialize the cache metadata store. | 43 // Initialize the cache metadata store. |
| 43 virtual void Initialize(const std::vector<FilePath>& cache_paths) = 0; | 44 virtual void Initialize(const std::vector<FilePath>& cache_paths) = 0; |
| 44 // Adds a new cache entry corresponding to |resource_id| if it doesn't | 45 // Adds a new cache entry corresponding to |resource_id| if it doesn't |
| 45 // exist, otherwise update the existing entry. | 46 // exist, otherwise update the existing entry. |
| 46 virtual void AddOrUpdateCacheEntry(const std::string& resource_id, | 47 virtual void AddOrUpdateCacheEntry(const std::string& resource_id, |
| 47 const GDataCacheEntry& cache_entry) = 0; | 48 const GDataCacheEntry& cache_entry) = 0; |
| 48 | 49 |
| 49 // Removes entry corresponding to |resource_id| from cache map. | 50 // Removes entry corresponding to |resource_id| from cache map. |
| 50 virtual void RemoveCacheEntry(const std::string& resource_id) = 0; | 51 virtual void RemoveCacheEntry(const std::string& resource_id) = 0; |
| 51 | 52 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 78 | 79 |
| 79 private: | 80 private: |
| 80 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 81 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| 81 | 82 |
| 82 DISALLOW_COPY_AND_ASSIGN(GDataCacheMetadata); | 83 DISALLOW_COPY_AND_ASSIGN(GDataCacheMetadata); |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 } // namespace gdata | 86 } // namespace gdata |
| 86 | 87 |
| 87 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_METADATA_H_ | 88 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_METADATA_H_ |
| OLD | NEW |