| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // Represents "file" in in a GData virtual file system. On gdata feed side, | 160 // Represents "file" in in a GData virtual file system. On gdata feed side, |
| 161 // this could be either a regular file or a server side document. | 161 // this could be either a regular file or a server side document. |
| 162 class GDataFile : public GDataFileBase { | 162 class GDataFile : public GDataFileBase { |
| 163 public: | 163 public: |
| 164 // This is used as a bitmask for the cache state. | 164 // This is used as a bitmask for the cache state. |
| 165 enum CacheState { | 165 enum CacheState { |
| 166 CACHE_STATE_NONE = 0x0, | 166 CACHE_STATE_NONE = 0x0, |
| 167 CACHE_STATE_PINNED = 0x1 << 0, | 167 CACHE_STATE_PINNED = 0x1 << 0, |
| 168 CACHE_STATE_PRESENT = 0x1 << 1, | 168 CACHE_STATE_PRESENT = 0x1 << 1, |
| 169 CACHE_STATE_DIRTY = 0x1 << 2, | 169 CACHE_STATE_DIRTY = 0x1 << 2, |
| 170 CACHE_STATE_MOUNTED = 0x1 << 3, |
| 170 }; | 171 }; |
| 171 | 172 |
| 172 explicit GDataFile(GDataDirectory* parent, GDataRootDirectory* root); | 173 explicit GDataFile(GDataDirectory* parent, GDataRootDirectory* root); |
| 173 virtual ~GDataFile(); | 174 virtual ~GDataFile(); |
| 174 virtual GDataFile* AsGDataFile() OVERRIDE; | 175 virtual GDataFile* AsGDataFile() OVERRIDE; |
| 175 | 176 |
| 176 static GDataFileBase* FromDocumentEntry(GDataDirectory* parent, | 177 static GDataFileBase* FromDocumentEntry(GDataDirectory* parent, |
| 177 DocumentEntry* doc, | 178 DocumentEntry* doc, |
| 178 GDataRootDirectory* root); | 179 GDataRootDirectory* root); |
| 179 | 180 |
| 180 // Convert to/from proto. | 181 // Convert to/from proto. |
| 181 void FromProto(const GDataFileProto& proto); | 182 void FromProto(const GDataFileProto& proto); |
| 182 void ToProto(GDataFileProto* proto) const; | 183 void ToProto(GDataFileProto* proto) const; |
| 183 | 184 |
| 184 static bool IsCachePresent(int cache_state) { | 185 static bool IsCachePresent(int cache_state) { |
| 185 return cache_state & CACHE_STATE_PRESENT; | 186 return cache_state & CACHE_STATE_PRESENT; |
| 186 } | 187 } |
| 187 static bool IsCachePinned(int cache_state) { | 188 static bool IsCachePinned(int cache_state) { |
| 188 return cache_state & CACHE_STATE_PINNED; | 189 return cache_state & CACHE_STATE_PINNED; |
| 189 } | 190 } |
| 190 static bool IsCacheDirty(int cache_state) { | 191 static bool IsCacheDirty(int cache_state) { |
| 191 return cache_state & CACHE_STATE_DIRTY; | 192 return cache_state & CACHE_STATE_DIRTY; |
| 192 } | 193 } |
| 194 static bool IsCacheMounted(int cache_state) { |
| 195 return cache_state & CACHE_STATE_MOUNTED; |
| 196 } |
| 193 static int SetCachePresent(int cache_state) { | 197 static int SetCachePresent(int cache_state) { |
| 194 return cache_state |= CACHE_STATE_PRESENT; | 198 return cache_state |= CACHE_STATE_PRESENT; |
| 195 } | 199 } |
| 196 static int SetCachePinned(int cache_state) { | 200 static int SetCachePinned(int cache_state) { |
| 197 return cache_state |= CACHE_STATE_PINNED; | 201 return cache_state |= CACHE_STATE_PINNED; |
| 198 } | 202 } |
| 199 static int SetCacheDirty(int cache_state) { | 203 static int SetCacheDirty(int cache_state) { |
| 200 return cache_state |= CACHE_STATE_DIRTY; | 204 return cache_state |= CACHE_STATE_DIRTY; |
| 201 } | 205 } |
| 206 static int SetCacheMounted(int cache_state) { |
| 207 return cache_state |= CACHE_STATE_MOUNTED; |
| 208 } |
| 202 static int ClearCachePresent(int cache_state) { | 209 static int ClearCachePresent(int cache_state) { |
| 203 return cache_state &= ~CACHE_STATE_PRESENT; | 210 return cache_state &= ~CACHE_STATE_PRESENT; |
| 204 } | 211 } |
| 205 static int ClearCachePinned(int cache_state) { | 212 static int ClearCachePinned(int cache_state) { |
| 206 return cache_state &= ~CACHE_STATE_PINNED; | 213 return cache_state &= ~CACHE_STATE_PINNED; |
| 207 } | 214 } |
| 208 static int ClearCacheDirty(int cache_state) { | 215 static int ClearCacheDirty(int cache_state) { |
| 209 return cache_state &= ~CACHE_STATE_DIRTY; | 216 return cache_state &= ~CACHE_STATE_DIRTY; |
| 210 } | 217 } |
| 218 static int ClearCacheMounted(int cache_state) { |
| 219 return cache_state &= ~CACHE_STATE_MOUNTED; |
| 220 } |
| 211 | 221 |
| 212 DocumentEntry::EntryKind kind() const { return kind_; } | 222 DocumentEntry::EntryKind kind() const { return kind_; } |
| 213 const GURL& thumbnail_url() const { return thumbnail_url_; } | 223 const GURL& thumbnail_url() const { return thumbnail_url_; } |
| 214 const GURL& alternate_url() const { return alternate_url_; } | 224 const GURL& alternate_url() const { return alternate_url_; } |
| 215 const std::string& content_mime_type() const { return content_mime_type_; } | 225 const std::string& content_mime_type() const { return content_mime_type_; } |
| 216 const std::string& etag() const { return etag_; } | 226 const std::string& etag() const { return etag_; } |
| 217 const std::string& id() const { return id_; } | 227 const std::string& id() const { return id_; } |
| 218 const std::string& file_md5() const { return file_md5_; } | 228 const std::string& file_md5() const { return file_md5_; } |
| 219 // The |callback| is invoked with a bitmask of CacheState enum values. | 229 // The |callback| is invoked with a bitmask of CacheState enum values. |
| 220 void GetCacheState(const GetCacheStateCallback& callback); | 230 void GetCacheState(const GetCacheStateCallback& callback); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 | 364 |
| 355 bool IsPresent() const { | 365 bool IsPresent() const { |
| 356 return GDataFile::IsCachePresent(cache_state); | 366 return GDataFile::IsCachePresent(cache_state); |
| 357 } | 367 } |
| 358 bool IsPinned() const { | 368 bool IsPinned() const { |
| 359 return GDataFile::IsCachePinned(cache_state); | 369 return GDataFile::IsCachePinned(cache_state); |
| 360 } | 370 } |
| 361 bool IsDirty() const { | 371 bool IsDirty() const { |
| 362 return GDataFile::IsCacheDirty(cache_state); | 372 return GDataFile::IsCacheDirty(cache_state); |
| 363 } | 373 } |
| 374 bool IsMounted() const { |
| 375 return GDataFile::IsCacheMounted(cache_state); |
| 376 } |
| 364 | 377 |
| 365 // For debugging purposes. | 378 // For debugging purposes. |
| 366 std::string ToString() const; | 379 std::string ToString() const; |
| 367 | 380 |
| 368 std::string md5; | 381 std::string md5; |
| 369 CacheSubDirectoryType sub_dir_type; | 382 CacheSubDirectoryType sub_dir_type; |
| 370 int cache_state; | 383 int cache_state; |
| 371 }; | 384 }; |
| 372 | 385 |
| 373 // A map table of cache file's resource id to its CacheEntry* entry. | 386 // 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... |
| 446 GDataFileSystem* file_system_; | 459 GDataFileSystem* file_system_; |
| 447 | 460 |
| 448 int largest_changestamp_; | 461 int largest_changestamp_; |
| 449 | 462 |
| 450 DISALLOW_COPY_AND_ASSIGN(GDataRootDirectory); | 463 DISALLOW_COPY_AND_ASSIGN(GDataRootDirectory); |
| 451 }; | 464 }; |
| 452 | 465 |
| 453 } // namespace gdata | 466 } // namespace gdata |
| 454 | 467 |
| 455 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ | 468 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ |
| OLD | NEW |