Chromium Code Reviews| Index: chrome/browser/chromeos/gdata/gdata_files.h |
| =================================================================== |
| --- chrome/browser/chromeos/gdata/gdata_files.h (revision 149697) |
| +++ chrome/browser/chromeos/gdata/gdata_files.h (working copy) |
| @@ -21,11 +21,17 @@ |
| #include "chrome/browser/profiles/profile_keyed_service.h" |
| #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
| +namespace base { |
| +class SequencedTaskRunner; |
| +} |
| + |
| namespace gdata { |
| +struct CreateDBParams; |
| class GDataFile; |
| class GDataDirectory; |
| class GDataDirectoryService; |
| +class GDataDirectoryServiceDB; |
| class GDataEntryProto; |
| class GDataDirectoryProto; |
| @@ -89,9 +95,8 @@ |
| GDataDirectoryService* directory_service); |
| // Serialize/Parse to/from string via proto classes. |
| - // TODO(achuith): Correctly set up parent_ and root_ links in |
| - // FromProtoString. |
| void SerializeToString(std::string* serialized_proto) const; |
| + // TODO(achuith): Get rid of this. crbug.com/140314. |
| static scoped_ptr<GDataEntry> FromProtoString( |
| const std::string& serialized_proto); |
| @@ -106,7 +111,7 @@ |
| PlatformFileInfoProto* proto); |
| // Converts to/from proto. Only handles the common part (i.e. does not |
| - // touch |file_specific_info| and |directory_specific_info|. |
| + // touch |file_specific_info|). |
| bool FromProto(const GDataEntryProto& proto) WARN_UNUSED_RESULT; |
| void ToProto(GDataEntryProto* proto) const; |
| @@ -336,12 +341,17 @@ |
| DISALLOW_COPY_AND_ASSIGN(GDataDirectory); |
| }; |
| +// TODO(achuith,hashimoto,satorux): Move this to a separate file. |
| +// crbug.com/140317. |
| // Class to handle GDataEntry* lookups, add/remove GDataEntry*. |
| class GDataDirectoryService { |
| public: |
| // Callback for GetEntryByResourceIdAsync. |
| typedef base::Callback<void(GDataEntry* entry)> GetEntryByResourceIdCallback; |
| + // Map of resource id and serialized GDataEntry. |
| + typedef std::map<std::string, std::string> SerializedMap; |
| + |
| GDataDirectoryService(); |
| ~GDataDirectoryService(); |
| @@ -405,18 +415,45 @@ |
| void SerializeToString(std::string* serialized_proto) const; |
| bool ParseFromString(const std::string& serialized_proto); |
| + // Restores from and saves to database. |
| + void InitFromDB(const FilePath& db_path, |
| + base::SequencedTaskRunner* blocking_task_runner, |
| + LoadRootFeedParams* load_params, |
| + const base::Closure& callback); |
| + void SaveToDB(); |
| + |
| private: |
| // A map table of file's resource string to its GDataFile* entry. |
| typedef std::map<std::string, GDataEntry*> ResourceMap; |
| - scoped_ptr<GDataDirectory> root_; // Stored in the serialized proto. |
| + // Initializes the resource map using serialized_resources fetched from the |
| + // database. |
| + void InitResourceMap(CreateDBParams* create_params, |
| + LoadRootFeedParams* load_params, |
| + const base::Closure& callback); |
| + |
| + // Clears root_ and the resource map. |
| + void ClearRoot(); |
| + |
| + // Creates GDataEntry from serialized string. |
| + scoped_ptr<GDataEntry> FromProtoString( |
| + const std::string& serialized_proto); |
| + |
| + // Private data members. |
| + scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| + scoped_ptr<GDataDirectoryServiceDB> directory_service_db_; |
| + |
| ResourceMap resource_map_; |
| + scoped_ptr<GDataDirectory> root_; // Stored in the serialized proto. |
| + |
| base::Time last_serialized_; |
| size_t serialized_size_; |
| int largest_changestamp_; // Stored in the serialized proto. |
| ContentOrigin origin_; |
| + base::WeakPtrFactory<GDataDirectoryService> weak_ptr_factory_; |
|
satorux1
2012/08/03 06:32:50
Please add
// Note: This should remain the las
achuithb
2012/08/03 19:15:59
Done.
|
| + |
| DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService); |
| }; |