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_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 | 114 |
115 // Triggered when a dirty file has been committed (saved) successfully. | 115 // Triggered when a dirty file has been committed (saved) successfully. |
116 virtual void OnCacheCommitted(const std::string& resource_id) {} | 116 virtual void OnCacheCommitted(const std::string& resource_id) {} |
117 | 117 |
118 protected: | 118 protected: |
119 virtual ~Observer() {} | 119 virtual ~Observer() {} |
120 }; | 120 }; |
121 | 121 |
122 // Structure to store information of an existing cache file. | 122 // Structure to store information of an existing cache file. |
123 struct CacheEntry { | 123 struct CacheEntry { |
124 CacheEntry() : cache_state(0) {} | 124 CacheEntry() : cache_state(CACHE_STATE_NONE) {} |
125 | 125 |
126 CacheEntry(const std::string& md5, | 126 CacheEntry(const std::string& md5, |
127 int cache_state) | 127 int cache_state) |
128 : md5(md5), | 128 : md5(md5), |
129 cache_state(cache_state) { | 129 cache_state(cache_state) { |
130 } | 130 } |
131 | 131 |
132 bool IsPresent() const { return IsCachePresent(cache_state); } | 132 bool IsPresent() const { return IsCachePresent(cache_state); } |
133 bool IsPinned() const { return IsCachePinned(cache_state); } | 133 bool IsPinned() const { return IsCachePinned(cache_state); } |
134 bool IsDirty() const { return IsCacheDirty(cache_state); } | 134 bool IsDirty() const { return IsCacheDirty(cache_state); } |
135 bool IsMounted() const { return IsCacheMounted(cache_state); } | 135 bool IsMounted() const { return IsCacheMounted(cache_state); } |
136 bool IsPersistent() const { return IsCachePersistent(cache_state); } | 136 bool IsPersistent() const { return IsCachePersistent(cache_state); } |
137 | 137 |
138 // Returns the type of the sub directory where the cache file is stored. | 138 // Returns the type of the sub directory where the cache file is stored. |
139 CacheSubDirectoryType GetSubDirectoryType() const { | 139 CacheSubDirectoryType GetSubDirectoryType() const { |
140 return IsPersistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP; | 140 return IsPersistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP; |
141 } | 141 } |
142 | 142 |
143 // For debugging purposes. | 143 // For debugging purposes. |
144 std::string ToString() const; | 144 std::string ToString() const; |
145 | 145 |
146 std::string md5; | 146 std::string md5; |
147 int cache_state; | 147 int cache_state; |
148 }; | 148 }; |
149 | 149 |
150 // Callback for GetCacheEntryOnUIThread. | 150 // Callback for GetCacheEntryOnUIThread. |
151 // |success| indicates if the operation was successful. | 151 // |success| indicates if the operation was successful. |
152 // |cache_entry| is the obtained cache entry. | 152 // |cache_entry| is the obtained cache entry. On failure, |cache_state| is |
153 // |set to CACHE_STATE_NONE. | |
hshi1
2012/07/10 23:54:49
Nit: remove extra character '|' before "set".
satorux1
2012/07/11 05:24:58
Done.
| |
153 // | 154 // |
154 // TODO(satorux): Unlike other callback types, this has to be defined | 155 // TODO(satorux): Unlike other callback types, this has to be defined |
155 // inside GDataCache as CacheEntry is inside GDataCache. We should get them | 156 // inside GDataCache as CacheEntry is inside GDataCache. We should get them |
156 // outside of GDataCache. | 157 // outside of GDataCache. |
157 typedef base::Callback<void(bool success, const CacheEntry& cache_entry)> | 158 typedef base::Callback<void(bool success, const CacheEntry& cache_entry)> |
158 GetCacheEntryCallback; | 159 GetCacheEntryCallback; |
159 | 160 |
160 static bool IsCachePresent(int cache_state) { | 161 static bool IsCachePresent(int cache_state) { |
161 return cache_state & CACHE_STATE_PRESENT; | 162 return cache_state & CACHE_STATE_PRESENT; |
162 } | 163 } |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 }; | 526 }; |
526 | 527 |
527 // Sets the free disk space getter for testing. | 528 // Sets the free disk space getter for testing. |
528 // The existing getter is deleted. | 529 // The existing getter is deleted. |
529 void SetFreeDiskSpaceGetterForTesting( | 530 void SetFreeDiskSpaceGetterForTesting( |
530 FreeDiskSpaceGetterInterface* getter); | 531 FreeDiskSpaceGetterInterface* getter); |
531 | 532 |
532 } // namespace gdata | 533 } // namespace gdata |
533 | 534 |
534 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ | 535 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ |
OLD | NEW |