Commit 25cabf3f authored by satorux@chromium.org's avatar satorux@chromium.org

gdata: Introduce GDataWapiFeedProcessor class

This class is introduced to separate code related to WAPI
(codename of Documents List API) feed processing.

To minimize diffs, the the class is defined in gdata_file_system.cc
The code will be moved to a set of new files in a separate patch.

BUG=130669
TEST=out/Release/unit_tests --gtest_filter=GData* && out/Release/browser_tests --gtest_filter=GData*

Review URL: https://chromiumcodereview.appspot.com/10825120

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149373 0039d316-1c4b-4281-b951-d872f2087c98
parent 977cfa42
...@@ -38,6 +38,10 @@ namespace { ...@@ -38,6 +38,10 @@ namespace {
struct LoadRootFeedParams; struct LoadRootFeedParams;
} // namespace } // namespace
// TODO(satorux): Move this into a new file. crbug.com/130669
typedef std::map<std::string /* resource_id */, GDataEntry*>
FileResourceIdMap;
// The production implementation of GDataFileSystemInterface. // The production implementation of GDataFileSystemInterface.
class GDataFileSystem : public GDataFileSystemInterface, class GDataFileSystem : public GDataFileSystemInterface,
public content::NotificationObserver { public content::NotificationObserver {
...@@ -156,9 +160,6 @@ class GDataFileSystem : public GDataFileSystemInterface, ...@@ -156,9 +160,6 @@ class GDataFileSystem : public GDataFileSystemInterface,
// execution of GetFileByPath() method. // execution of GetFileByPath() method.
struct GetFileFromCacheParams; struct GetFileFromCacheParams;
typedef std::map<std::string /* resource_id */, GDataEntry*>
FileResourceIdMap;
// Callback similar to FileOperationCallback but with a given |file_path|. // Callback similar to FileOperationCallback but with a given |file_path|.
typedef base::Callback<void(GDataFileError error, typedef base::Callback<void(GDataFileError error,
const FilePath& file_path)> const FilePath& file_path)>
...@@ -169,9 +170,6 @@ class GDataFileSystem : public GDataFileSystemInterface, ...@@ -169,9 +170,6 @@ class GDataFileSystem : public GDataFileSystemInterface,
GDataFileError error)> GDataFileError error)>
LoadDocumentFeedCallback; LoadDocumentFeedCallback;
// Struct used to record UMA stats with FeedToFileResourceMap().
struct FeedToFileResourceMapUmaStats;
// Struct used for StartFileUploadOnUIThread(). // Struct used for StartFileUploadOnUIThread().
struct StartFileUploadParams; struct StartFileUploadParams;
...@@ -524,60 +522,12 @@ class GDataFileSystem : public GDataFileSystemInterface, ...@@ -524,60 +522,12 @@ class GDataFileSystem : public GDataFileSystemInterface,
int largest_changestamp, int largest_changestamp,
int root_feed_changestamp); int root_feed_changestamp);
// Updates UMA histograms about file counts.
void UpdateFileCountUmaHistograms(
const FeedToFileResourceMapUmaStats& uma_stats) const;
// Applies the pre-processed feed from |file_map| map onto the file system.
// All entries in |file_map| will be erased (i.e. the map becomes empty),
// and values are deleted.
void ApplyFeedFromFileUrlMap(bool is_delta_feed,
int feed_changestamp,
FileResourceIdMap* file_map);
// Helper function for adding new |file| from the feed into |directory|. It
// checks the type of file and updates |changed_dirs| if this file adding
// operation needs to raise directory notification update. If file is being
// added to |orphaned_dir_service| such notifications are not raised since
// we ignore such files and don't add them to the file system now.
// static
static void AddEntryToDirectoryAndCollectChangedDirectories(
GDataEntry* entry,
GDataDirectory* directory,
GDataDirectoryService* orphaned_dir_service,
std::set<FilePath>* changed_dirs);
// Helper function for removing |entry| from |directory|. If |entry| is a
// directory too, it will collect all its children file paths into
// |changed_dirs| as well.
// static
static void RemoveEntryFromDirectoryAndCollectChangedDirectories(
GDataDirectory* directory,
GDataEntry* entry,
std::set<FilePath>* changed_dirs);
// Callback for GetEntryByResourceIdAsync. // Callback for GetEntryByResourceIdAsync.
// Removes stale entry upon upload of file. // Removes stale entry upon upload of file.
static void RemoveStaleEntryOnUpload(const std::string& resource_id, static void RemoveStaleEntryOnUpload(const std::string& resource_id,
GDataDirectory* parent_dir, GDataDirectory* parent_dir,
GDataEntry* existing_entry); GDataEntry* existing_entry);
// Finds directory where new |file| should be added to during feed processing.
// |orphaned_entries_dir| collects files/dirs that don't have a parent in
// either locally cached file system or in this new feed.
GDataDirectory* FindDirectoryForNewEntry(
GDataEntry* new_entry,
const FileResourceIdMap& file_map,
GDataDirectoryService* orphaned_entries);
// Converts list of document feeds from collected feeds into
// FileResourceIdMap.
GDataFileError FeedToFileResourceMap(
const std::vector<DocumentFeed*>& feed_list,
FileResourceIdMap* file_map,
int* feed_changestamp,
FeedToFileResourceMapUmaStats* uma_stats);
// Converts |entry_value| into GFileDocument instance and adds it // Converts |entry_value| into GFileDocument instance and adds it
// to virtual file system at |directory_path|. // to virtual file system at |directory_path|.
GDataFileError AddNewDirectory(const FilePath& directory_path, GDataFileError AddNewDirectory(const FilePath& directory_path,
......
...@@ -294,6 +294,7 @@ class GDataDirectory : public GDataEntry { ...@@ -294,6 +294,7 @@ class GDataDirectory : public GDataEntry {
// TODO(satorux): Remove the friend statements. crbug.com/139649 // TODO(satorux): Remove the friend statements. crbug.com/139649
friend class GDataDirectoryService; friend class GDataDirectoryService;
friend class GDataFileSystem; friend class GDataFileSystem;
friend class GDataWapiFeedProcessor;
// Adds child file to the directory and takes over the ownership of |file| // Adds child file to the directory and takes over the ownership of |file|
// object. The method will also do name de-duplication to ensure that the // object. The method will also do name de-duplication to ensure that the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment