Chromium Code Reviews| 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_WAPI_FEED_PROCESSOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_PROCESSOR_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_PROCESSOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_PROCESSOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | 14 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" |
| 15 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" | 15 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" |
| 16 | 16 |
| 17 namespace gdata { | 17 namespace gdata { |
| 18 | 18 |
| 19 class DriveDirectory; | 19 class DriveDirectory; |
| 20 class GDataDirectoryService; | |
| 21 class DriveEntry; | 20 class DriveEntry; |
| 21 class DriveResourceMetadata; | |
| 22 | 22 |
| 23 typedef std::map<std::string /* resource_id */, DriveEntry*> | 23 typedef std::map<std::string /* resource_id */, DriveEntry*> |
| 24 FileResourceIdMap; | 24 FileResourceIdMap; |
| 25 | 25 |
| 26 // Struct used to record UMA stats with FeedToFileResourceMap(). | 26 // Struct used to record UMA stats with FeedToFileResourceMap(). |
| 27 struct FeedToFileResourceMapUmaStats { | 27 struct FeedToFileResourceMapUmaStats { |
| 28 FeedToFileResourceMapUmaStats(); | 28 FeedToFileResourceMapUmaStats(); |
| 29 ~FeedToFileResourceMapUmaStats(); | 29 ~FeedToFileResourceMapUmaStats(); |
| 30 | 30 |
| 31 typedef std::map<DocumentEntry::EntryKind, int> EntryKindToCountMap; | 31 typedef std::map<DocumentEntry::EntryKind, int> EntryKindToCountMap; |
| 32 int num_regular_files; | 32 int num_regular_files; |
| 33 int num_hosted_documents; | 33 int num_hosted_documents; |
| 34 EntryKindToCountMap num_files_with_entry_kind; | 34 EntryKindToCountMap num_files_with_entry_kind; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 // GDataWapiFeedProcessor is used to process feeds from WAPI (codename for | 37 // GDataWapiFeedProcessor is used to process feeds from WAPI (codename for |
| 38 // Documents List API). | 38 // Documents List API). |
| 39 class GDataWapiFeedProcessor { | 39 class GDataWapiFeedProcessor { |
| 40 public: | 40 public: |
| 41 explicit GDataWapiFeedProcessor(GDataDirectoryService* directory_service); | 41 explicit GDataWapiFeedProcessor(DriveResourceMetadata* resource_metadata); |
| 42 ~GDataWapiFeedProcessor(); | 42 ~GDataWapiFeedProcessor(); |
| 43 | 43 |
| 44 // Applies the documents feeds to the file system using |directory_service_|. | 44 // Applies the documents feeds to the file system using |resource_metadata_|. |
| 45 // | 45 // |
| 46 // |start_changestamp| determines the type of feed to process. The value is | 46 // |start_changestamp| determines the type of feed to process. The value is |
| 47 // set to zero for the root feeds, every other value is for the delta feeds. | 47 // set to zero for the root feeds, every other value is for the delta feeds. |
| 48 // | 48 // |
| 49 // In the case of processing the root feeds |root_feed_changestamp| is used | 49 // In the case of processing the root feeds |root_feed_changestamp| is used |
| 50 // as its initial changestamp value. The value comes from | 50 // as its initial changestamp value. The value comes from |
| 51 // AccountMetadataFeed. | 51 // AccountMetadataFeed. |
| 52 GDataFileError ApplyFeeds(const std::vector<DocumentFeed*>& feed_list, | 52 GDataFileError ApplyFeeds(const std::vector<DocumentFeed*>& feed_list, |
| 53 int64 start_changestamp, | 53 int64 start_changestamp, |
| 54 int64 root_feed_changestamp, | 54 int64 root_feed_changestamp, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 71 // All entries in |file_map| will be erased (i.e. the map becomes empty), | 71 // All entries in |file_map| will be erased (i.e. the map becomes empty), |
| 72 // and values are deleted. | 72 // and values are deleted. |
| 73 void ApplyFeedFromFileUrlMap(bool is_delta_feed, | 73 void ApplyFeedFromFileUrlMap(bool is_delta_feed, |
| 74 int64 feed_changestamp, | 74 int64 feed_changestamp, |
| 75 FileResourceIdMap* file_map, | 75 FileResourceIdMap* file_map, |
| 76 std::set<FilePath>* changed_dirs); | 76 std::set<FilePath>* changed_dirs); |
| 77 | 77 |
| 78 // Helper function for adding new |file| from the feed into |directory|. It | 78 // Helper function for adding new |file| from the feed into |directory|. It |
| 79 // checks the type of file and updates |changed_dirs| if this file adding | 79 // checks the type of file and updates |changed_dirs| if this file adding |
| 80 // operation needs to raise directory notification update. If file is being | 80 // operation needs to raise directory notification update. If file is being |
| 81 // added to |orphaned_dir_service| such notifications are not raised since | 81 // added to |orphaned_res_metadata| such notifications are not raised since |
| 82 // we ignore such files and don't add them to the file system now. | 82 // we ignore such files and don't add them to the file system now. |
| 83 static void AddEntryToDirectoryAndCollectChangedDirectories( | 83 static void AddEntryToDirectoryAndCollectChangedDirectories( |
| 84 DriveEntry* entry, | 84 DriveEntry* entry, |
| 85 DriveDirectory* directory, | 85 DriveDirectory* directory, |
| 86 GDataDirectoryService* orphaned_dir_service, | 86 DriveResourceMetadata* orphaned_res_metadata, |
|
achuithb
2012/08/22 09:41:06
let's call this orphaned_resources instead.
kochi
2012/08/22 10:04:56
Done.
| |
| 87 std::set<FilePath>* changed_dirs); | 87 std::set<FilePath>* changed_dirs); |
| 88 | 88 |
| 89 // Helper function for removing |entry| from |directory|. If |entry| is a | 89 // Helper function for removing |entry| from |directory|. If |entry| is a |
| 90 // directory too, it will collect all its children file paths into | 90 // directory too, it will collect all its children file paths into |
| 91 // |changed_dirs| as well. | 91 // |changed_dirs| as well. |
| 92 static void RemoveEntryFromDirectoryAndCollectChangedDirectories( | 92 static void RemoveEntryFromDirectoryAndCollectChangedDirectories( |
| 93 DriveDirectory* directory, | 93 DriveDirectory* directory, |
| 94 DriveEntry* entry, | 94 DriveEntry* entry, |
| 95 std::set<FilePath>* changed_dirs); | 95 std::set<FilePath>* changed_dirs); |
| 96 | 96 |
| 97 // Finds directory where new |file| should be added to during feed processing. | 97 // Finds directory where new |file| should be added to during feed processing. |
| 98 // |orphaned_entries_dir| collects files/dirs that don't have a parent in | 98 // |orphaned_entries_dir| collects files/dirs that don't have a parent in |
| 99 // either locally cached file system or in this new feed. | 99 // either locally cached file system or in this new feed. |
| 100 DriveDirectory* FindDirectoryForNewEntry( | 100 DriveDirectory* FindDirectoryForNewEntry( |
| 101 DriveEntry* new_entry, | 101 DriveEntry* new_entry, |
| 102 const FileResourceIdMap& file_map, | 102 const FileResourceIdMap& file_map, |
| 103 GDataDirectoryService* orphaned_dir_service); | 103 DriveResourceMetadata* orphaned_res_metadata); |
| 104 | 104 |
| 105 GDataDirectoryService* directory_service_; // Not owned by the class. | 105 DriveResourceMetadata* resource_metadata_; // Not owned by the class. |
|
achuithb
2012/08/22 09:41:06
Just say
// Not owned
to be consistent.
kochi
2012/08/22 10:04:56
Done.
| |
| 106 DISALLOW_COPY_AND_ASSIGN(GDataWapiFeedProcessor); | 106 DISALLOW_COPY_AND_ASSIGN(GDataWapiFeedProcessor); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace gdata | 109 } // namespace gdata |
| 110 | 110 |
| 111 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_PROCESSOR_H_ | 111 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_PROCESSOR_H_ |
| OLD | NEW |