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_FILES_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // Represents "file" in in a GData virtual file system. On gdata feed side, | 149 // Represents "file" in in a GData virtual file system. On gdata feed side, |
150 // this could be either a regular file or a server side document. | 150 // this could be either a regular file or a server side document. |
151 class GDataFile : public GDataFileBase { | 151 class GDataFile : public GDataFileBase { |
152 public: | 152 public: |
153 // This is used as a bitmask for the cache state. | 153 // This is used as a bitmask for the cache state. |
154 enum CacheState { | 154 enum CacheState { |
155 CACHE_STATE_NONE = 0x0, | 155 CACHE_STATE_NONE = 0x0, |
156 CACHE_STATE_PINNED = 0x1 << 0, | 156 CACHE_STATE_PINNED = 0x1 << 0, |
157 CACHE_STATE_PRESENT = 0x1 << 1, | 157 CACHE_STATE_PRESENT = 0x1 << 1, |
158 CACHE_STATE_DIRTY = 0x1 << 2, | 158 CACHE_STATE_DIRTY = 0x1 << 2, |
| 159 CACHE_STATE_MOUNTED = 0x1 << 3, |
159 }; | 160 }; |
160 | 161 |
161 explicit GDataFile(GDataDirectory* parent, GDataRootDirectory* root); | 162 explicit GDataFile(GDataDirectory* parent, GDataRootDirectory* root); |
162 virtual ~GDataFile(); | 163 virtual ~GDataFile(); |
163 virtual GDataFile* AsGDataFile() OVERRIDE; | 164 virtual GDataFile* AsGDataFile() OVERRIDE; |
164 | 165 |
165 static GDataFileBase* FromDocumentEntry(GDataDirectory* parent, | 166 static GDataFileBase* FromDocumentEntry(GDataDirectory* parent, |
166 DocumentEntry* doc, | 167 DocumentEntry* doc, |
167 GDataRootDirectory* root); | 168 GDataRootDirectory* root); |
168 | 169 |
169 // Convert to/from proto. | 170 // Convert to/from proto. |
170 void FromProto(const GDataFileProto& proto); | 171 void FromProto(const GDataFileProto& proto); |
171 void ToProto(GDataFileProto* proto) const; | 172 void ToProto(GDataFileProto* proto) const; |
172 | 173 |
173 static bool IsCachePresent(int cache_state) { | 174 static bool IsCachePresent(int cache_state) { |
174 return cache_state & CACHE_STATE_PRESENT; | 175 return cache_state & CACHE_STATE_PRESENT; |
175 } | 176 } |
176 static bool IsCachePinned(int cache_state) { | 177 static bool IsCachePinned(int cache_state) { |
177 return cache_state & CACHE_STATE_PINNED; | 178 return cache_state & CACHE_STATE_PINNED; |
178 } | 179 } |
179 static bool IsCacheDirty(int cache_state) { | 180 static bool IsCacheDirty(int cache_state) { |
180 return cache_state & CACHE_STATE_DIRTY; | 181 return cache_state & CACHE_STATE_DIRTY; |
181 } | 182 } |
| 183 static bool IsCacheMounted(int cache_state) { |
| 184 return cache_state & CACHE_STATE_MOUNTED; |
| 185 } |
182 static int SetCachePresent(int cache_state) { | 186 static int SetCachePresent(int cache_state) { |
183 return cache_state |= CACHE_STATE_PRESENT; | 187 return cache_state |= CACHE_STATE_PRESENT; |
184 } | 188 } |
185 static int SetCachePinned(int cache_state) { | 189 static int SetCachePinned(int cache_state) { |
186 return cache_state |= CACHE_STATE_PINNED; | 190 return cache_state |= CACHE_STATE_PINNED; |
187 } | 191 } |
188 static int SetCacheDirty(int cache_state) { | 192 static int SetCacheDirty(int cache_state) { |
189 return cache_state |= CACHE_STATE_DIRTY; | 193 return cache_state |= CACHE_STATE_DIRTY; |
190 } | 194 } |
| 195 static int SetCacheMounted(int cache_state) { |
| 196 return cache_state |= CACHE_STATE_MOUNTED; |
| 197 } |
191 static int ClearCachePresent(int cache_state) { | 198 static int ClearCachePresent(int cache_state) { |
192 return cache_state &= ~CACHE_STATE_PRESENT; | 199 return cache_state &= ~CACHE_STATE_PRESENT; |
193 } | 200 } |
194 static int ClearCachePinned(int cache_state) { | 201 static int ClearCachePinned(int cache_state) { |
195 return cache_state &= ~CACHE_STATE_PINNED; | 202 return cache_state &= ~CACHE_STATE_PINNED; |
196 } | 203 } |
197 static int ClearCacheDirty(int cache_state) { | 204 static int ClearCacheDirty(int cache_state) { |
198 return cache_state &= ~CACHE_STATE_DIRTY; | 205 return cache_state &= ~CACHE_STATE_DIRTY; |
199 } | 206 } |
| 207 static int ClearCacheMounted(int cache_state) { |
| 208 return cache_state &= ~CACHE_STATE_MOUNTED; |
| 209 } |
200 | 210 |
201 DocumentEntry::EntryKind kind() const { return kind_; } | 211 DocumentEntry::EntryKind kind() const { return kind_; } |
202 const GURL& thumbnail_url() const { return thumbnail_url_; } | 212 const GURL& thumbnail_url() const { return thumbnail_url_; } |
203 const GURL& edit_url() const { return edit_url_; } | 213 const GURL& edit_url() const { return edit_url_; } |
204 const std::string& content_mime_type() const { return content_mime_type_; } | 214 const std::string& content_mime_type() const { return content_mime_type_; } |
205 const std::string& etag() const { return etag_; } | 215 const std::string& etag() const { return etag_; } |
206 const std::string& id() const { return id_; } | 216 const std::string& id() const { return id_; } |
207 const std::string& file_md5() const { return file_md5_; } | 217 const std::string& file_md5() const { return file_md5_; } |
208 // The |callback| is invoked with a bitmask of CacheState enum values. | 218 // The |callback| is invoked with a bitmask of CacheState enum values. |
209 void GetCacheState(const GetCacheStateCallback& callback); | 219 void GetCacheState(const GetCacheStateCallback& callback); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 350 |
341 bool IsPresent() const { | 351 bool IsPresent() const { |
342 return GDataFile::IsCachePresent(cache_state); | 352 return GDataFile::IsCachePresent(cache_state); |
343 } | 353 } |
344 bool IsPinned() const { | 354 bool IsPinned() const { |
345 return GDataFile::IsCachePinned(cache_state); | 355 return GDataFile::IsCachePinned(cache_state); |
346 } | 356 } |
347 bool IsDirty() const { | 357 bool IsDirty() const { |
348 return GDataFile::IsCacheDirty(cache_state); | 358 return GDataFile::IsCacheDirty(cache_state); |
349 } | 359 } |
| 360 bool IsMounted() const { |
| 361 return GDataFile::IsCacheMounted(cache_state); |
| 362 } |
350 | 363 |
351 // For debugging purposes. | 364 // For debugging purposes. |
352 std::string ToString() const; | 365 std::string ToString() const; |
353 | 366 |
354 std::string md5; | 367 std::string md5; |
355 CacheSubDirectoryType sub_dir_type; | 368 CacheSubDirectoryType sub_dir_type; |
356 int cache_state; | 369 int cache_state; |
357 }; | 370 }; |
358 | 371 |
359 // A map table of cache file's resource id to its CacheEntry* entry. | 372 // A map table of cache file's resource id to its CacheEntry* entry. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 GDataFileSystem* file_system_; | 445 GDataFileSystem* file_system_; |
433 | 446 |
434 int largest_changestamp_; | 447 int largest_changestamp_; |
435 | 448 |
436 DISALLOW_COPY_AND_ASSIGN(GDataRootDirectory); | 449 DISALLOW_COPY_AND_ASSIGN(GDataRootDirectory); |
437 }; | 450 }; |
438 | 451 |
439 } // namespace gdata | 452 } // namespace gdata |
440 | 453 |
441 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ | 454 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ |
OLD | NEW |