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_FILE_SYSTEM_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 private: | 65 private: |
66 DISALLOW_COPY_AND_ASSIGN(GDataFileBase); | 66 DISALLOW_COPY_AND_ASSIGN(GDataFileBase); |
67 }; | 67 }; |
68 | 68 |
69 typedef std::map<FilePath::StringType, GDataFileBase*> GDataFileCollection; | 69 typedef std::map<FilePath::StringType, GDataFileBase*> GDataFileCollection; |
70 | 70 |
71 // Represents "file" in in a GData virtual file system. On gdata feed side, | 71 // Represents "file" in in a GData virtual file system. On gdata feed side, |
72 // this could be either a regular file or a server side document. | 72 // this could be either a regular file or a server side document. |
73 class GDataFile : public GDataFileBase { | 73 class GDataFile : public GDataFileBase { |
74 public: | 74 public: |
| 75 // This is used as a bitmask for the cache state. |
| 76 enum CacheState { |
| 77 CACHE_STATE_NONE = 0x0, |
| 78 CACHE_STATE_PINNED = 0x1 << 0, |
| 79 CACHE_STATE_PRESENT = 0x1 << 1, |
| 80 CACHE_STATE_DIRTY = 0x1 << 2, |
| 81 }; |
| 82 |
75 explicit GDataFile(GDataDirectory* parent); | 83 explicit GDataFile(GDataDirectory* parent); |
76 virtual ~GDataFile(); | 84 virtual ~GDataFile(); |
77 virtual GDataFile* AsGDataFile() OVERRIDE; | 85 virtual GDataFile* AsGDataFile() OVERRIDE; |
78 | 86 |
79 static GDataFileBase* FromDocumentEntry(GDataDirectory* parent, | 87 static GDataFileBase* FromDocumentEntry(GDataDirectory* parent, |
80 DocumentEntry* doc); | 88 DocumentEntry* doc); |
81 | 89 |
82 DocumentEntry::EntryKind kind() const { return kind_; } | 90 DocumentEntry::EntryKind kind() const { return kind_; } |
| 91 const GURL& thumbnail_url() const { return thumbnail_url_; } |
| 92 const GURL& edit_url() const { return edit_url_; } |
83 const std::string& content_mime_type() const { return content_mime_type_; } | 93 const std::string& content_mime_type() const { return content_mime_type_; } |
84 const std::string& etag() const { return etag_; } | 94 const std::string& etag() const { return etag_; } |
85 const std::string& resource() const { return resource_id_; } | 95 const std::string& resource() const { return resource_id_; } |
86 const std::string& id() const { return id_; } | 96 const std::string& id() const { return id_; } |
87 const std::string& file_md5() const { return file_md5_; } | 97 const std::string& file_md5() const { return file_md5_; } |
| 98 // Returns a bitmask of CacheState enum values. |
| 99 const int cache_state() const { return cache_state_; } |
88 | 100 |
89 private: | 101 private: |
90 // Content URL for files. | 102 // Content URL for files. |
91 DocumentEntry::EntryKind kind_; | 103 DocumentEntry::EntryKind kind_; |
| 104 GURL thumbnail_url_; |
| 105 GURL edit_url_; |
92 std::string content_mime_type_; | 106 std::string content_mime_type_; |
93 std::string etag_; | 107 std::string etag_; |
94 std::string resource_id_; | 108 std::string resource_id_; |
95 std::string id_; | 109 std::string id_; |
96 std::string file_md5_; | 110 std::string file_md5_; |
| 111 int cache_state_; |
97 | 112 |
98 DISALLOW_COPY_AND_ASSIGN(GDataFile); | 113 DISALLOW_COPY_AND_ASSIGN(GDataFile); |
99 }; | 114 }; |
100 | 115 |
101 // Represents "directory" in a GData virtual file system. Maps to gdata | 116 // Represents "directory" in a GData virtual file system. Maps to gdata |
102 // collection element. | 117 // collection element. |
103 class GDataDirectory : public GDataFileBase { | 118 class GDataDirectory : public GDataFileBase { |
104 public: | 119 public: |
105 explicit GDataDirectory(GDataDirectory* parent); | 120 explicit GDataDirectory(GDataDirectory* parent); |
106 virtual ~GDataDirectory(); | 121 virtual ~GDataDirectory(); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 }; | 419 }; |
405 | 420 |
406 // Singleton that owns all GDataFileSystems and associates them with | 421 // Singleton that owns all GDataFileSystems and associates them with |
407 // Profiles. | 422 // Profiles. |
408 class GDataFileSystemFactory : public ProfileKeyedServiceFactory { | 423 class GDataFileSystemFactory : public ProfileKeyedServiceFactory { |
409 public: | 424 public: |
410 // Returns the GDataFileSystem for |profile|, creating it if it is not | 425 // Returns the GDataFileSystem for |profile|, creating it if it is not |
411 // yet created. | 426 // yet created. |
412 static GDataFileSystem* GetForProfile(Profile* profile); | 427 static GDataFileSystem* GetForProfile(Profile* profile); |
413 | 428 |
414 // Returns the GDataFileSystemFactory instance. | 429 // Returns the GDataFileSystemFactory instance. |
415 static GDataFileSystemFactory* GetInstance(); | 430 static GDataFileSystemFactory* GetInstance(); |
416 | 431 |
417 private: | 432 private: |
418 friend struct DefaultSingletonTraits<GDataFileSystemFactory>; | 433 friend struct DefaultSingletonTraits<GDataFileSystemFactory>; |
419 | 434 |
420 GDataFileSystemFactory(); | 435 GDataFileSystemFactory(); |
421 virtual ~GDataFileSystemFactory(); | 436 virtual ~GDataFileSystemFactory(); |
422 | 437 |
423 // ProfileKeyedServiceFactory: | 438 // ProfileKeyedServiceFactory: |
424 virtual ProfileKeyedService* BuildServiceInstanceFor( | 439 virtual ProfileKeyedService* BuildServiceInstanceFor( |
425 Profile* profile) const OVERRIDE; | 440 Profile* profile) const OVERRIDE; |
426 }; | 441 }; |
427 | 442 |
428 } // namespace gdata | 443 } // namespace gdata |
429 | 444 |
430 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 445 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
OLD | NEW |