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_DRIVE_DRIVE_FEED_PROCESSOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FEED_PROCESSOR_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FEED_PROCESSOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FEED_PROCESSOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 void ApplyEntryProtoMap(bool is_delta_feed, int64 feed_changestamp); | 72 void ApplyEntryProtoMap(bool is_delta_feed, int64 feed_changestamp); |
73 | 73 |
74 // Apply the next item from entry_proto_map_ to the file system. The async | 74 // Apply the next item from entry_proto_map_ to the file system. The async |
75 // version posts to the message loop to avoid recursive stack-overflow. | 75 // version posts to the message loop to avoid recursive stack-overflow. |
76 void ApplyNextEntryProto(); | 76 void ApplyNextEntryProto(); |
77 void ApplyNextEntryProtoAsync(); | 77 void ApplyNextEntryProtoAsync(); |
78 | 78 |
79 // Apply |entry_proto| to resource_metadata_. | 79 // Apply |entry_proto| to resource_metadata_. |
80 void ApplyEntryProto(const DriveEntryProto& entry_proto); | 80 void ApplyEntryProto(const DriveEntryProto& entry_proto); |
81 | 81 |
| 82 // Continue ApplyEntryProto. This is a callback for |
| 83 // DriveResourceMetadata::GetEntryInfoByResourceId. |
| 84 void ContinueApplyEntryProto( |
| 85 const DriveEntryProto& entry_proto, |
| 86 DriveFileError error, |
| 87 const FilePath& file_path, |
| 88 scoped_ptr<DriveEntryProto> old_entry_proto); |
| 89 |
82 // Apply the DriveEntryProto pointed to by |it| to resource_metadata_. | 90 // Apply the DriveEntryProto pointed to by |it| to resource_metadata_. |
83 void ApplyNextByIterator(DriveEntryProtoMap::iterator it); | 91 void ApplyNextByIterator(DriveEntryProtoMap::iterator it); |
84 | 92 |
85 // Helper function for adding an |entry| from the feed to its new parent. | 93 // TODO(achuith): Delete these. |
86 // changed_dirs_ are updated if this operation needs to raise a directory | 94 void AddEntryToParentDeprecated(DriveEntry* entry); |
87 // change notification. | 95 void RemoveEntryFromParent(DriveEntry* entry); |
88 void AddEntryToParent(DriveEntry* entry); | 96 DriveDirectory* ResolveParent(DriveEntry* new_entry); |
89 | 97 |
90 // Helper function for removing |entry| from its parent. | 98 // Helper function to add |entry_proto| to its parent. Updates changed_dirs_ |
91 // changed_dirs_ are updated if this operation needs to raise a directory | 99 // as a side effect. |
92 // change notification, including child directories. | 100 void AddEntryToParent(const DriveEntryProto& entry_proto); |
93 void RemoveEntryFromParent(DriveEntry* entry); | |
94 | 101 |
95 // Resolves parent directory for |new_entry| from the feed. | 102 // Callback for DriveResourceMetadata::AddEntryToParent. |
96 DriveDirectory* ResolveParent(DriveEntry* new_entry); | 103 void NotifyForAddEntryToParent(bool is_directory, |
| 104 DriveFileError error, |
| 105 const FilePath& file_path); |
| 106 |
| 107 |
| 108 // Removes entry pointed to by |resource_id| from its parent. Updates |
| 109 // changed_dirs_ as a side effect. |
| 110 void RemoveEntryFromParent( |
| 111 const DriveEntryProto& entry_proto, |
| 112 const FilePath& file_path); |
| 113 |
| 114 // Continues RemoveEntryFromParent after |
| 115 // DriveResourceMetadata::GetChildDirectories. |
| 116 void OnGetChildrenForRemove( |
| 117 const DriveEntryProto& entry_proto, |
| 118 const FilePath& file_path, |
| 119 const std::set<FilePath>& changed_directories); |
| 120 |
| 121 // Callback for DriveResourceMetadata::RemoveEntryFromParent. |
| 122 void NotifyForRemoveEntryFromParent( |
| 123 bool is_directory, |
| 124 const FilePath& file_path, |
| 125 const std::set<FilePath>& changed_directories, |
| 126 DriveFileError error, |
| 127 const FilePath& parent_path); |
| 128 |
| 129 // Refreshes DriveResourceMetadata entry that has the same resource_id as |
| 130 // |entry_proto| with |entry_proto|. Updates changed_dirs_ as a side effect. |
| 131 void RefreshEntryProto(const DriveEntryProto& entry_proto, |
| 132 const FilePath& file_path); |
| 133 |
| 134 // Callback for DriveResourceMetadata::RefreshEntryProto. |
| 135 void NotifyForRefreshEntryProto( |
| 136 const FilePath& old_file_path, |
| 137 DriveFileError error, |
| 138 const FilePath& file_path, |
| 139 scoped_ptr<DriveEntryProto> entry_proto); |
97 | 140 |
98 // Reset the state of this object. | 141 // Reset the state of this object. |
99 void Clear(); | 142 void Clear(); |
100 | 143 |
101 DriveResourceMetadata* resource_metadata_; // Not owned. | 144 DriveResourceMetadata* resource_metadata_; // Not owned. |
102 | 145 |
103 DriveEntryProtoMap entry_proto_map_; | 146 DriveEntryProtoMap entry_proto_map_; |
104 std::set<FilePath> changed_dirs_; | 147 std::set<FilePath> changed_dirs_; |
105 base::Closure on_complete_callback_; | 148 base::Closure on_complete_callback_; |
106 | 149 |
107 // Note: This should remain the last member so it'll be destroyed and | 150 // Note: This should remain the last member so it'll be destroyed and |
108 // invalidate its weak pointers before any other members are destroyed. | 151 // invalidate its weak pointers before any other members are destroyed. |
109 base::WeakPtrFactory<DriveFeedProcessor> weak_ptr_factory_; | 152 base::WeakPtrFactory<DriveFeedProcessor> weak_ptr_factory_; |
110 DISALLOW_COPY_AND_ASSIGN(DriveFeedProcessor); | 153 DISALLOW_COPY_AND_ASSIGN(DriveFeedProcessor); |
111 }; | 154 }; |
112 | 155 |
113 } // namespace drive | 156 } // namespace drive |
114 | 157 |
115 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FEED_PROCESSOR_H_ | 158 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FEED_PROCESSOR_H_ |
OLD | NEW |