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_CHANGE_LIST_LOADER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 void ScheduleRun(const DirectoryFetchInfo& directory_fetch_info, | 129 void ScheduleRun(const DirectoryFetchInfo& directory_fetch_info, |
130 const FileOperationCallback& callback); | 130 const FileOperationCallback& callback); |
131 | 131 |
132 // Indicates whether there is a feed refreshing server request is in flight. | 132 // Indicates whether there is a feed refreshing server request is in flight. |
133 bool refreshing() const { return refreshing_; } | 133 bool refreshing() const { return refreshing_; } |
134 | 134 |
135 private: | 135 private: |
136 struct GetResourceListUiState; | 136 struct GetResourceListUiState; |
137 struct LoadFeedParams; | 137 struct LoadFeedParams; |
138 struct LoadRootFeedParams; | 138 struct LoadRootFeedParams; |
139 struct UpdateMetadataParams; | |
140 | 139 |
141 // Part of Load(). Called after loading from the cache is complete. | 140 // Part of Load(). Called after loading from the cache is complete. |
142 void LoadAfterLoadFromCache( | 141 void LoadAfterLoadFromCache( |
143 const DirectoryFetchInfo directory_fetch_info, | 142 const DirectoryFetchInfo directory_fetch_info, |
144 const FileOperationCallback& callback, | 143 const FileOperationCallback& callback, |
145 DriveFileError error); | 144 DriveFileError error); |
146 | 145 |
147 // Starts root feed load from the server, with details specified in |params|. | 146 // Starts loading from the server, with details specified in |params|. This |
148 void LoadFromServer(scoped_ptr<LoadFeedParams> params); | 147 // is a general purpuse function, which is used for loading change lists, |
| 148 // full resource lists, and directory contents. |
| 149 void LoadFromServer(scoped_ptr<LoadFeedParams> params, |
| 150 const LoadFeedListCallback& callback); |
| 151 |
| 152 // Part of LoadFromServer. Called when DriveScheduler::GetResourceList() is |
| 153 // complete. |callback| must not be null. |
| 154 void LoadFromServerAfterGetResourceList( |
| 155 scoped_ptr<LoadFeedParams> params, |
| 156 const LoadFeedListCallback& callback, |
| 157 base::TimeTicks start_time, |
| 158 google_apis::GDataErrorCode status, |
| 159 scoped_ptr<google_apis::ResourceList> data); |
149 | 160 |
150 // Part of LoadDirectoryFromServer() Callled when | 161 // Part of LoadDirectoryFromServer() Callled when |
151 // DriveScheduler::GetAboutResource() is complete. Calls | 162 // DriveScheduler::GetAboutResource() is complete. Calls |
152 // DoLoadDirectoryFromServer() to initiate the directory contents loading. | 163 // DoLoadDirectoryFromServer() to initiate the directory contents loading. |
153 void LoadDirectoryFromServerAfterGetAbout( | 164 void LoadDirectoryFromServerAfterGetAbout( |
154 const std::string& directory_resource_id, | 165 const std::string& directory_resource_id, |
155 const FileOperationCallback& callback, | 166 const FileOperationCallback& callback, |
156 google_apis::GDataErrorCode status, | 167 google_apis::GDataErrorCode status, |
157 scoped_ptr<google_apis::AboutResource> about_resource); | 168 scoped_ptr<google_apis::AboutResource> about_resource); |
158 | 169 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 scoped_ptr<google_apis::AboutResource> about_resource); | 202 scoped_ptr<google_apis::AboutResource> about_resource); |
192 | 203 |
193 // Compares |remote_changestamp| and |local_changestamp| and triggers | 204 // Compares |remote_changestamp| and |local_changestamp| and triggers |
194 // LoadFromServer if necessary. | 205 // LoadFromServer if necessary. |
195 void CompareChangestampsAndLoadIfNeeded( | 206 void CompareChangestampsAndLoadIfNeeded( |
196 const DirectoryFetchInfo& directory_fetch_info, | 207 const DirectoryFetchInfo& directory_fetch_info, |
197 const FileOperationCallback& callback, | 208 const FileOperationCallback& callback, |
198 int64 remote_changestamp, | 209 int64 remote_changestamp, |
199 int64 local_changestamp); | 210 int64 local_changestamp); |
200 | 211 |
| 212 // Starts loading the change list since |start_changestamp|, or the full |
| 213 // resource list if |start_changestamp| is zero. |remote_changestamp| will |
| 214 // be stored in DriveResourceMetadata, once loading is done. |
| 215 // callback must not be null. |
| 216 void LoadChangeListFromServer( |
| 217 int64 start_changestamp, |
| 218 int64 remote_changestamp, |
| 219 const FileOperationCallback& callback); |
| 220 |
201 // Callback for handling response from |DriveAPIService::GetAppList|. | 221 // Callback for handling response from |DriveAPIService::GetAppList|. |
202 // If the application list is successfully parsed, passes the list to | 222 // If the application list is successfully parsed, passes the list to |
203 // Drive webapps registry. | 223 // Drive webapps registry. |
204 void OnGetAppList(google_apis::GDataErrorCode status, | 224 void OnGetAppList(google_apis::GDataErrorCode status, |
205 scoped_ptr<google_apis::AppList> app_list); | 225 scoped_ptr<google_apis::AppList> app_list); |
206 | 226 |
207 // Callback for handling feed content fetching while searching for file info. | 227 // Callback for handling feed content fetching while searching for file info. |
208 // This callback is invoked after async feed fetch operation that was | 228 // This callback is invoked after async feed fetch operation that was |
209 // invoked by StartDirectoryRefresh() completes. This callback will update | 229 // invoked by StartDirectoryRefresh() completes. This callback will update |
210 // the content of the refreshed directory object and continue initially | 230 // the content of the refreshed directory object and continue initially |
211 // started FindEntryByPath() request. | 231 // started FindEntryByPath() request. |
212 void UpdateMetadataFromFeedAfterLoadFromServer( | 232 void UpdateMetadataFromFeedAfterLoadFromServer( |
213 const UpdateMetadataParams& params, | 233 bool is_delta_feed, |
| 234 int64 feed_changestamp, |
| 235 const FileOperationCallback& callback, |
214 const ScopedVector<google_apis::ResourceList>& feed_list, | 236 const ScopedVector<google_apis::ResourceList>& feed_list, |
215 DriveFileError error); | 237 DriveFileError error); |
216 | 238 |
217 // Callback for handling response from |GDataWapiService::GetResourceList|. | |
218 // Invokes |callback| when done. | |
219 // |callback| must not be null. | |
220 void OnGetResourceList(scoped_ptr<LoadFeedParams> params, | |
221 base::TimeTicks start_time, | |
222 google_apis::GDataErrorCode status, | |
223 scoped_ptr<google_apis::ResourceList> data); | |
224 | |
225 // Save filesystem to disk. | 239 // Save filesystem to disk. |
226 void SaveFileSystem(); | 240 void SaveFileSystem(); |
227 | 241 |
228 // Callback for handling UI updates caused by feed fetching. | 242 // Callback for handling UI updates caused by feed fetching. |
229 void OnNotifyResourceListFetched( | 243 void OnNotifyResourceListFetched( |
230 base::WeakPtr<GetResourceListUiState> ui_state); | 244 base::WeakPtr<GetResourceListUiState> ui_state); |
231 | 245 |
232 // Callback for ChangeListProcessor::ApplyFeeds. | 246 // Callback for ChangeListProcessor::ApplyFeeds. |
233 void NotifyDirectoryChanged(bool should_notify, | 247 void NotifyDirectoryChanged(bool should_notify, |
234 const base::Closure& update_finished_callback); | 248 const base::Closure& update_finished_callback); |
(...skipping 26 matching lines...) Expand all Loading... |
261 | 275 |
262 // Note: This should remain the last member so it'll be destroyed and | 276 // Note: This should remain the last member so it'll be destroyed and |
263 // invalidate its weak pointers before any other members are destroyed. | 277 // invalidate its weak pointers before any other members are destroyed. |
264 base::WeakPtrFactory<ChangeListLoader> weak_ptr_factory_; | 278 base::WeakPtrFactory<ChangeListLoader> weak_ptr_factory_; |
265 DISALLOW_COPY_AND_ASSIGN(ChangeListLoader); | 279 DISALLOW_COPY_AND_ASSIGN(ChangeListLoader); |
266 }; | 280 }; |
267 | 281 |
268 } // namespace drive | 282 } // namespace drive |
269 | 283 |
270 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ | 284 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ |
OLD | NEW |