| 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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // See the comment at Load() for |directory_fetch_info| parameter. | 102 // See the comment at Load() for |directory_fetch_info| parameter. |
| 103 // |callback| must not be null. | 103 // |callback| must not be null. |
| 104 // TODO(satorux): make this private. crbug.com/193417 | 104 // TODO(satorux): make this private. crbug.com/193417 |
| 105 void LoadFromServerIfNeeded(const DirectoryFetchInfo& directory_fetch_info, | 105 void LoadFromServerIfNeeded(const DirectoryFetchInfo& directory_fetch_info, |
| 106 const FileOperationCallback& callback); | 106 const FileOperationCallback& callback); |
| 107 | 107 |
| 108 // Updates whole directory structure feeds collected in |feed_list|. | 108 // Updates whole directory structure feeds collected in |feed_list|. |
| 109 // Record file statistics as UMA histograms. | 109 // Record file statistics as UMA histograms. |
| 110 // | 110 // |
| 111 // See comments at ChangeListProcessor::ApplyFeeds() for | 111 // See comments at ChangeListProcessor::ApplyFeeds() for |
| 112 // |is_delta_feed| and |root_feed_changestamp|. | 112 // |about_resource| and |is_delta_feed|. |
| 113 // |update_finished_callback| must not be null. | 113 // |update_finished_callback| must not be null. |
| 114 void UpdateFromFeed(const ScopedVector<google_apis::ResourceList>& feed_list, | 114 void UpdateFromFeed( |
| 115 bool is_delta_feed, | 115 scoped_ptr<google_apis::AboutResource> about_resource, |
| 116 int64 root_feed_changestamp, | 116 const ScopedVector<google_apis::ResourceList>& feed_list, |
| 117 const base::Closure& update_finished_callback); | 117 bool is_delta_feed, |
| 118 const base::Closure& update_finished_callback); |
| 118 | 119 |
| 119 // Indicates whether there is a feed refreshing server request is in flight. | 120 // Indicates whether there is a feed refreshing server request is in flight. |
| 120 bool refreshing() const { return refreshing_; } | 121 bool refreshing() const { return refreshing_; } |
| 121 | 122 |
| 122 private: | 123 private: |
| 123 struct GetResourceListUiState; | 124 struct GetResourceListUiState; |
| 124 struct LoadFeedParams; | 125 struct LoadFeedParams; |
| 125 | 126 |
| 126 // Starts the change list loading from the cache, and runs |callback| to | 127 // Starts the change list loading from the cache, and runs |callback| to |
| 127 // tell the result to the caller. |callback| must not be null. | 128 // tell the result to the caller. |callback| must not be null. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // Part of LoadFromServerIfNeeded(). Called when | 182 // Part of LoadFromServerIfNeeded(). Called when |
| 182 // DriveScheduler::GetAboutResource() is complete. This method calls | 183 // DriveScheduler::GetAboutResource() is complete. This method calls |
| 183 // CompareChangestampsAndLoadIfNeeded() to make a decision about whether or | 184 // CompareChangestampsAndLoadIfNeeded() to make a decision about whether or |
| 184 // not to fetch the change list. | 185 // not to fetch the change list. |
| 185 void LoadFromServerIfNeededAfterGetAbout( | 186 void LoadFromServerIfNeededAfterGetAbout( |
| 186 const DirectoryFetchInfo& directory_fetch_info, | 187 const DirectoryFetchInfo& directory_fetch_info, |
| 187 const FileOperationCallback& callback, | 188 const FileOperationCallback& callback, |
| 188 google_apis::GDataErrorCode status, | 189 google_apis::GDataErrorCode status, |
| 189 scoped_ptr<google_apis::AboutResource> about_resource); | 190 scoped_ptr<google_apis::AboutResource> about_resource); |
| 190 | 191 |
| 191 // Compares |remote_changestamp| and |local_changestamp| and triggers | 192 // Compares the largetst_change_id in |about_resource| and |local_changestamp| |
| 192 // LoadFromServer if necessary. | 193 // and triggers LoadFromServer if necessary. |
| 193 void CompareChangestampsAndLoadIfNeeded( | 194 void CompareChangestampsAndLoadIfNeeded( |
| 194 const DirectoryFetchInfo& directory_fetch_info, | 195 const DirectoryFetchInfo& directory_fetch_info, |
| 195 const FileOperationCallback& callback, | 196 const FileOperationCallback& callback, |
| 196 int64 remote_changestamp, | 197 scoped_ptr<google_apis::AboutResource> about_resource, |
| 197 int64 local_changestamp); | 198 int64 local_changestamp); |
| 198 | 199 |
| 199 // Starts loading the change list since |start_changestamp|, or the full | 200 // Starts loading the change list since |start_changestamp|, or the full |
| 200 // resource list if |start_changestamp| is zero. |remote_changestamp| will | 201 // resource list if |start_changestamp| is zero. For full update, the |
| 201 // be stored in DriveResourceMetadata, once loading is done. | 202 // largest_change_id and root_folder_id from |about_resource| will be used. |
| 202 // callback must not be null. | 203 // |callback| must not be null. |
| 203 void LoadChangeListFromServer( | 204 void LoadChangeListFromServer( |
| 205 scoped_ptr<google_apis::AboutResource> about_resource, |
| 204 int64 start_changestamp, | 206 int64 start_changestamp, |
| 205 int64 remote_changestamp, | |
| 206 const FileOperationCallback& callback); | 207 const FileOperationCallback& callback); |
| 207 | 208 |
| 208 // Starts loading the change list from the server. Called after the | 209 // Starts loading the change list from the server. Called after the |
| 209 // directory contents are "fast-fetch"ed. | 210 // directory contents are "fast-fetch"ed. |
| 210 void StartLoadChangeListFromServer( | 211 void StartLoadChangeListFromServer( |
| 211 const DirectoryFetchInfo& directory_fetch_info, | 212 const DirectoryFetchInfo& directory_fetch_info, |
| 213 scoped_ptr<google_apis::AboutResource> about_resource, |
| 212 int64 start_changestamp, | 214 int64 start_changestamp, |
| 213 int64 remote_changestamp, | |
| 214 const FileOperationCallback& callback, | 215 const FileOperationCallback& callback, |
| 215 DriveFileError error); | 216 DriveFileError error); |
| 216 | 217 |
| 217 // Callback for handling response from |DriveAPIService::GetAppList|. | 218 // Callback for handling response from |DriveAPIService::GetAppList|. |
| 218 // If the application list is successfully parsed, passes the list to | 219 // If the application list is successfully parsed, passes the list to |
| 219 // Drive webapps registry. | 220 // Drive webapps registry. |
| 220 void OnGetAppList(google_apis::GDataErrorCode status, | 221 void OnGetAppList(google_apis::GDataErrorCode status, |
| 221 scoped_ptr<google_apis::AppList> app_list); | 222 scoped_ptr<google_apis::AppList> app_list); |
| 222 | 223 |
| 223 // Callback for handling feed content fetching while searching for file info. | 224 // Callback for handling feed content fetching while searching for file info. |
| 224 // This callback is invoked after async feed fetch operation that was | 225 // This callback is invoked after async feed fetch operation that was |
| 225 // invoked by StartDirectoryRefresh() completes. This callback will update | 226 // invoked by StartDirectoryRefresh() completes. This callback will update |
| 226 // the content of the refreshed directory object and continue initially | 227 // the content of the refreshed directory object and continue initially |
| 227 // started FindEntryByPath() request. | 228 // started FindEntryByPath() request. |
| 228 void UpdateMetadataFromFeedAfterLoadFromServer( | 229 void UpdateMetadataFromFeedAfterLoadFromServer( |
| 230 scoped_ptr<google_apis::AboutResource> about_resource, |
| 229 bool is_delta_feed, | 231 bool is_delta_feed, |
| 230 int64 feed_changestamp, | |
| 231 const FileOperationCallback& callback, | 232 const FileOperationCallback& callback, |
| 232 const ScopedVector<google_apis::ResourceList>& feed_list, | 233 const ScopedVector<google_apis::ResourceList>& feed_list, |
| 233 DriveFileError error); | 234 DriveFileError error); |
| 234 | 235 |
| 235 // Save filesystem to disk. | 236 // Save filesystem to disk. |
| 236 void SaveFileSystem(); | 237 void SaveFileSystem(); |
| 237 | 238 |
| 238 // Callback for handling UI updates caused by feed fetching. | 239 // Callback for handling UI updates caused by feed fetching. |
| 239 void OnNotifyResourceListFetched( | 240 void OnNotifyResourceListFetched( |
| 240 base::WeakPtr<GetResourceListUiState> ui_state); | 241 base::WeakPtr<GetResourceListUiState> ui_state); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 295 |
| 295 // Note: This should remain the last member so it'll be destroyed and | 296 // Note: This should remain the last member so it'll be destroyed and |
| 296 // invalidate its weak pointers before any other members are destroyed. | 297 // invalidate its weak pointers before any other members are destroyed. |
| 297 base::WeakPtrFactory<ChangeListLoader> weak_ptr_factory_; | 298 base::WeakPtrFactory<ChangeListLoader> weak_ptr_factory_; |
| 298 DISALLOW_COPY_AND_ASSIGN(ChangeListLoader); | 299 DISALLOW_COPY_AND_ASSIGN(ChangeListLoader); |
| 299 }; | 300 }; |
| 300 | 301 |
| 301 } // namespace drive | 302 } // namespace drive |
| 302 | 303 |
| 303 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ | 304 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ |
| OLD | NEW |