Chromium Code Reviews| Index: chrome/browser/chromeos/gdata/gdata_files.h |
| =================================================================== |
| --- chrome/browser/chromeos/gdata/gdata_files.h (revision 151008) |
| +++ chrome/browser/chromeos/gdata/gdata_files.h (working copy) |
| @@ -7,6 +7,7 @@ |
| #include <map> |
| #include <string> |
| +#include <vector> |
| #include "base/callback.h" |
| #include "base/gtest_prod_util.h" |
| @@ -325,7 +326,6 @@ |
| private: |
| // TODO(satorux): Remove the friend statements. crbug.com/139649 |
| friend class GDataDirectoryService; |
| - friend class GDataFileSystem; |
| friend class GDataWapiFeedProcessor; |
| explicit GDataDirectory(GDataDirectoryService* directory_service); |
| @@ -383,6 +383,8 @@ |
| // Map of resource id and serialized GDataEntry. |
| typedef std::map<std::string, std::string> SerializedMap; |
| + // Map of resource id strings to GDataEntry*. |
| + typedef std::map<std::string, GDataEntry*> ResourceMap; |
| GDataDirectoryService(); |
| ~GDataDirectoryService(); |
| @@ -417,6 +419,11 @@ |
| // Sets root directory resource id and initialize the root entry. |
| void InitializeRootEntry(const std::string& root_id); |
| + // Add |new entry| to |directory| and invoke the callback asynchronously. |
| + void AddEntryToDirectory(GDataDirectory* directory, |
| + GDataEntry* new_entry, |
| + const base::Closure& callback); |
| + |
| // Move |entry| to |directory_path| asynchronously. Removes entry from |
| // previous parent. Must be called on UI thread. |callback| is called on the |
| // UI thread. |
| @@ -424,6 +431,10 @@ |
| GDataEntry* entry, |
| const FileMoveCallback& callback); |
| + // Remove |entry| from its parent. Calls |callback|, which may be null. |
| + void RemoveEntryFromParent(GDataEntry* entry, |
| + const base::Closure& callback); |
| + |
| // Adds the entry to resource map. |
| void AddEntryToResourceMap(GDataEntry* entry); |
| @@ -475,9 +486,12 @@ |
| // fresh value |fresh_file|. |
| void RefreshFile(scoped_ptr<GDataFile> fresh_file); |
| - // Replaces file entry |old_entry| with its fresh value |fresh_file|. |
| - static void RefreshFileInternal(scoped_ptr<GDataFile> fresh_file, |
| - GDataEntry* old_entry); |
| + // Remove all child files of |directory| and replace with file_map. |
| + // Note that |callback| is only called if the directory is successfully |
| + // refreshed. |
|
satorux1
2012/08/10 16:14:44
please document if |callback| is optional or not.
achuithb
2012/08/11 00:37:45
Done here and elsewhere.
|
| + void RefreshDirectory(const std::string& directory_resource_id, |
| + const ResourceMap& file_map, |
| + const base::Closure& callback); |
| // Serializes/Parses to/from string via proto classes. |
| void SerializeToString(std::string* serialized_proto) const; |
| @@ -490,9 +504,6 @@ |
| void SaveToDB(); |
| private: |
| - // A map table of file's resource string to its GDataFile* entry. |
| - typedef std::map<std::string, GDataEntry*> ResourceMap; |
| - |
| // Initializes the resource map using serialized_resources fetched from the |
| // database. |
| void InitResourceMap(CreateDBParams* create_params, |
| @@ -521,6 +532,20 @@ |
| GDataFileError error, |
| scoped_ptr<GDataEntryProto> entry_proto); |
| + // These internal functions need friend access to private GDataDirectory |
| + // methods. |
| + // Replaces file entry |old_entry| with its fresh value |fresh_file|. |
| + static void RefreshFileInternal(scoped_ptr<GDataFile> fresh_file, |
| + GDataEntry* old_entry); |
| + |
| + // Remove all child files of |directory| and replace with file_map. |
| + // Note that |callback| is only called if the directory is successfully |
| + // refreshed. |
| + static void RefreshDirectoryInternal(const ResourceMap& file_map, |
| + const base::Closure& callback, |
| + GDataEntry* directory_entry); |
| + |
| + |
| // Private data members. |
| scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| scoped_ptr<ResourceMetadataDB> directory_service_db_; |