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_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> | |
| 11 #include <vector> | 10 #include <vector> |
| 12 | 11 |
| 13 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 14 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 15 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 16 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" | 15 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" |
| 17 #include "chrome/browser/google_apis/gdata_errorcode.h" | 16 #include "chrome/browser/google_apis/gdata_errorcode.h" |
| 18 | 17 |
| 19 class GURL; | 18 class GURL; |
| 20 | 19 |
| 21 namespace google_apis { | 20 namespace google_apis { |
| 22 class AboutResource; | 21 class AboutResource; |
| 23 class AppList; | 22 class AppList; |
| 24 class ResourceList; | 23 class ResourceList; |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace drive { | 26 namespace drive { |
| 28 | 27 |
| 29 class ChangeList; | 28 class ChangeList; |
| 30 class ChangeListLoaderObserver; | 29 class ChangeListLoaderObserver; |
| 31 class ChangeListProcessor; | 30 class ChangeListProcessor; |
| 32 class DriveScheduler; | 31 class DriveScheduler; |
| 33 class DriveWebAppsRegistry; | 32 class DriveWebAppsRegistry; |
| 34 | 33 |
| 35 // Callback run as a response to SearchFromServer and LoadDirectoryFromServer. | 34 // Callback run as a response to SearchFromServer. |
| 36 typedef base::Callback<void(ScopedVector<ChangeList> change_lists, | 35 typedef base::Callback<void(ScopedVector<ChangeList> change_lists, |
| 37 DriveFileError error)> LoadFeedListCallback; | 36 DriveFileError error)> LoadFeedListCallback; |
| 38 | 37 |
| 39 // ChangeListLoader is used to load feeds from WAPI (codename for | 38 // ChangeListLoader is used to load feeds from WAPI (codename for |
| 40 // Documents List API) or Google Drive API and load the cached metadata. | 39 // Documents List API) or Google Drive API and load the cached metadata. |
| 41 class ChangeListLoader { | 40 class ChangeListLoader { |
| 42 public: | 41 public: |
| 43 ChangeListLoader(DriveResourceMetadata* resource_metadata, | 42 ChangeListLoader(DriveResourceMetadata* resource_metadata, |
| 44 DriveScheduler* scheduler, | 43 DriveScheduler* scheduler, |
| 45 DriveWebAppsRegistry* webapps_registry); | 44 DriveWebAppsRegistry* webapps_registry); |
| 46 ~ChangeListLoader(); | 45 ~ChangeListLoader(); |
| 47 | 46 |
| 47 // Indicates whether there is a feed refreshing server request is in flight. | |
| 48 bool IsRefreshing() const; | |
| 49 | |
| 48 // Adds and removes the observer. | 50 // Adds and removes the observer. |
| 49 void AddObserver(ChangeListLoaderObserver* observer); | 51 void AddObserver(ChangeListLoaderObserver* observer); |
| 50 void RemoveObserver(ChangeListLoaderObserver* observer); | 52 void RemoveObserver(ChangeListLoaderObserver* observer); |
| 51 | 53 |
| 52 // Starts the change list loading first from the cache. If loading from the | 54 // Starts the change list loading first from the cache. If loading from the |
| 53 // cache is successful, runs |callback| and starts loading from the server | 55 // cache is successful, runs |callback| immediately and starts checking |
| 54 // if needed (i.e. the cache is old). If loading from the cache is | 56 // server for updates in background. If loading from the cache is |
| 55 // unsuccessful, starts loading from the server, and runs |callback| to | 57 // unsuccessful, starts loading from the server, and runs |callback| to tell |
| 56 // tell the result to the caller. | 58 // the result to the caller when it is finished. |
| 57 // | 59 // |
| 58 // If |directory_fetch_info| is not empty, the directory will be fetched | 60 // If |directory_fetch_info| is not empty, the directory will be fetched |
| 59 // first from the server, so the UI can show the directory contents | 61 // first from the server, so the UI can show the directory contents |
| 60 // instantly before the entire change list loading is complete. | 62 // instantly before the entire change list loading is complete. |
| 61 // | 63 // |
| 62 // |callback| must not be null. | 64 // |callback| must not be null. |
| 63 void LoadIfNeeded(const DirectoryFetchInfo& directory_fetch_info, | 65 void LoadIfNeeded(const DirectoryFetchInfo& directory_fetch_info, |
| 64 const FileOperationCallback& callback); | 66 const FileOperationCallback& callback); |
| 65 | 67 |
| 68 // Checks for updates on the server. Does nothing if the change list is now | |
| 69 // being loaded or refreshed. |callback| must not be null. | |
| 70 void CheckForUpdates(const FileOperationCallback& callback); | |
|
satorux1
2013/04/18 05:31:43
Is this a good place? Maybe move this above LoadIf
kinaba
2013/04/18 05:42:38
Done.
| |
| 71 | |
| 66 // Initiates the directory contents loading. This function first obtains | 72 // Initiates the directory contents loading. This function first obtains |
| 67 // the changestamp from the server in order to set the per-directory | 73 // the changestamp from the server in order to set the per-directory |
| 68 // changestamp for the directory. | 74 // changestamp for the directory. |
| 69 // | 75 // |
| 70 // Upon completion, |callback| is invoked. On success, the changestamp of | 76 // Upon completion, |callback| is invoked. On success, the changestamp of |
| 71 // the directory is updated. |callback| must not be null. | 77 // the directory is updated. |callback| must not be null. |
| 72 // | 78 // |
| 73 // Note that This function initiates the loading without comparing the | 79 // Note that This function initiates the loading without comparing the |
| 74 // directory changestamp against the server changestamp. The primary | 80 // directory changestamp against the server changestamp. The primary |
| 75 // purpose of this function is to update parts of entries in the directory | 81 // purpose of this function is to update parts of entries in the directory |
| 76 // which can stale over time, such as thumbnail URLs. | 82 // which can stale over time, such as thumbnail URLs. |
| 77 void LoadDirectoryFromServer(const std::string& directory_resource_id, | 83 void LoadDirectoryFromServer(const std::string& directory_resource_id, |
| 78 const FileOperationCallback& callback); | 84 const FileOperationCallback& callback); |
| 79 | 85 |
| 80 // Starts retrieving search results for |search_query| from the server. | 86 // Starts retrieving search results for |search_query| from the server. |
| 81 // If |next_feed| is set, this is the feed url that will be fetched. | 87 // If |next_feed| is set, this is the feed url that will be fetched. |
| 82 // If |next_feed| is an empty string, the default URL is used. | 88 // If |next_feed| is an empty string, the default URL is used. |
| 83 // Upon completion, |callback| is invoked. | 89 // Upon completion, |callback| is invoked. |
| 84 // |callback| must not be null. | 90 // |callback| must not be null. |
| 85 void SearchFromServer(const std::string& search_query, | 91 void SearchFromServer(const std::string& search_query, |
| 86 const GURL& next_feed, | 92 const GURL& next_feed, |
| 87 const LoadFeedListCallback& callback); | 93 const LoadFeedListCallback& callback); |
| 88 | 94 |
| 89 // Checks for updates on the server. Does nothing if the change list is now | |
| 90 // being loaded or refreshed. |callback| must not be null. | |
| 91 void CheckForUpdates(const FileOperationCallback& callback); | |
| 92 | |
| 93 // Updates whole directory structure feeds collected in |feed_list|. | 95 // Updates whole directory structure feeds collected in |feed_list|. |
| 94 // Record file statistics as UMA histograms. | 96 // Record file statistics as UMA histograms. |
| 95 // | 97 // |
| 96 // See comments at ChangeListProcessor::ApplyFeeds() for | 98 // See comments at ChangeListProcessor::ApplyFeeds() for |
| 97 // |about_resource| and |is_delta_feed|. | 99 // |about_resource| and |is_delta_feed|. |
| 98 // |update_finished_callback| must not be null. | 100 // |callback| must not be null. |
|
satorux1
2013/04/18 05:31:43
Could you add: TODO(satorux): Make this private. c
kinaba
2013/04/18 05:42:38
Done.
| |
| 99 void UpdateFromFeed(scoped_ptr<google_apis::AboutResource> about_resource, | 101 void UpdateFromFeed(scoped_ptr<google_apis::AboutResource> about_resource, |
| 100 ScopedVector<ChangeList> change_lists, | 102 ScopedVector<ChangeList> change_lists, |
| 101 bool is_delta_feed, | 103 bool is_delta_feed, |
| 102 const base::Closure& update_finished_callback); | 104 const base::Closure& callback); |
| 103 | |
| 104 // Indicates whether there is a feed refreshing server request is in flight. | |
| 105 bool IsRefreshing() const; | |
| 106 | 105 |
| 107 private: | 106 private: |
| 108 // Implementation of LoadIfNeeded and CheckForUpdates. Start metadata loading | 107 // Start metadata loading of |directory_fetch_info|, and calls |callback| |
| 109 // of |directory_fetch_info|, and calls |callback| when it's done. If there is | 108 // when it's done. If there is already a loading job in-flight for |
| 110 // already a loading job in-flight for |directory_fetch_info|, just append | 109 // |directory_fetch_info|, just append the |callback| to the callback queue |
| 111 // the |callback| to the callback queue of the already running job. | 110 // of the already running job. |
| 112 void Load(const DirectoryFetchInfo& directory_fetch_info, | 111 void Load(const DirectoryFetchInfo& directory_fetch_info, |
| 113 const FileOperationCallback& callback); | 112 const FileOperationCallback& callback); |
| 114 | 113 |
| 115 // Part of Load(). DoInitialLoad() is called if it is the first time to Load. | 114 // Part of Load(). DoInitialLoad() is called if it is the first time to Load. |
| 116 // Otherwise DoUpdateLoad() is used. The difference of two cases are: | 115 // Otherwise DoUpdateLoad() is used. The difference of two cases are: |
| 117 // - When we could load from cache, DoInitialLoad runs callback immediately | 116 // - When we could load from cache, DoInitialLoad runs callback immediately |
| 118 // and further operations (check changestamp and load from server if needed) | 117 // and further operations (check changestamp and load from server if needed) |
| 119 // in background. | 118 // in background. |
| 120 // - Even when |directory_fetch_info| is set, DoInitialLoad runs change list | 119 // - Even when |directory_fetch_info| is set, DoInitialLoad runs change list |
| 121 // loading after directory loading is finished. | 120 // loading after directory loading is finished. |
| 122 void DoInitialLoad(const DirectoryFetchInfo& directory_fetch_info, | 121 void DoInitialLoad(const DirectoryFetchInfo& directory_fetch_info, |
| 123 int64 local_changestamp); | 122 int64 local_changestamp); |
| 124 void DoUpdateLoad(const DirectoryFetchInfo& directory_fetch_info, | 123 void DoUpdateLoad(const DirectoryFetchInfo& directory_fetch_info, |
| 125 int64 local_changestamp); | 124 int64 local_changestamp); |
| 126 | 125 |
| 127 // Part of Load(). | 126 // Part of Load(). |
| 127 // This function should be called when the change list load is complete. | |
| 128 // Flushes the callbacks for change list loading and all directory loading. | |
| 129 void OnChangeListLoadComplete(DriveFileError error); | |
| 130 | |
| 131 // Part of Load(). | |
| 132 // This function should be called when the directory load is complete. | |
| 133 // Flushes the callbacks waiting for the directory to be loaded. | |
| 134 void OnDirectoryLoadComplete(const DirectoryFetchInfo& directory_fetch_info, | |
| 135 DriveFileError error); | |
| 136 | |
| 137 // ================= Implementation for change list loading ================= | |
| 138 | |
| 128 // Initiates the change list loading from the server when |local_changestamp| | 139 // Initiates the change list loading from the server when |local_changestamp| |
| 129 // is older than the server changestamp. If |directory_fetch_info| is set, | 140 // is older than the server changestamp. If |directory_fetch_info| is set, |
| 130 // do directory loading before change list loading. | 141 // do directory loading before change list loading. |
| 131 void LoadFromServerIfNeeded(const DirectoryFetchInfo& directory_fetch_info, | 142 void LoadFromServerIfNeeded(const DirectoryFetchInfo& directory_fetch_info, |
| 132 int64 local_changestamp); | 143 int64 local_changestamp); |
| 133 | 144 |
| 134 // Part of Load(). | 145 // Part of LoadFromServerIfNeeded(). |
| 135 // Checks the directory's changestamp and |last_known_remote_changestamp_|, | 146 // Called after GetAboutResource() for getting remote changestamp is complete. |
| 136 // and load the feed from server if it is old. Runs |callback| when it's done. | |
| 137 void CheckChangestampAndLoadDirectoryIfNeeed( | |
| 138 const DirectoryFetchInfo& directory_fetch_info, | |
| 139 int64 local_changestamp, | |
| 140 const FileOperationCallback& callback); | |
| 141 | |
| 142 // Part of LoadChangeListFromServer(). | |
| 143 // Callback to fetch all the resource list response from the server. | |
| 144 // After all the resource list are fetched, |callback| | |
| 145 // will be invoked with the collected change lists. | |
| 146 // |callback| must not be null. | |
| 147 void OnGetResourceList( | |
| 148 ScopedVector<ChangeList> change_lists, | |
| 149 const LoadFeedListCallback& callback, | |
| 150 base::TimeTicks start_time, | |
| 151 google_apis::GDataErrorCode status, | |
| 152 scoped_ptr<google_apis::ResourceList> data); | |
| 153 | |
| 154 // Part of LoadDirectoryFromServer(). Called when | |
| 155 // DriveScheduler::GetAboutResource() is complete. Calls | |
| 156 // DoLoadDirectoryFromServer() to initiate the directory contents loading. | |
| 157 void LoadDirectoryFromServerAfterGetAbout( | |
| 158 const std::string& directory_resource_id, | |
| 159 const FileOperationCallback& callback, | |
| 160 google_apis::GDataErrorCode status, | |
| 161 scoped_ptr<google_apis::AboutResource> about_resource); | |
| 162 | |
| 163 // Initiates the directory contents loading, based on |directory_fetch_info|. | |
| 164 // When it is finished it just runs |callback| but no other callbacks in | |
| 165 // |pending_load_callback_|, because it depends on the caller whether to flush | |
| 166 // callbacks. Thus, the caller must be responsible for task flushing. | |
| 167 void DoLoadDirectoryFromServer(const DirectoryFetchInfo& directory_fetch_info, | |
| 168 const FileOperationCallback& callback); | |
| 169 | |
| 170 // Part of DoLoadDirectoryFromServer for the grand root ("/drive" directory). | |
| 171 // Called when GetEntryInfoByPath is completed. | |
| 172 // |callback| must not be null. | |
| 173 void DoLoadGrandRootDirectoryFromServerAfterGetEntryInfoByPath( | |
| 174 const DirectoryFetchInfo& directory_fetch_info, | |
| 175 const FileOperationCallback& callback, | |
| 176 DriveFileError error, | |
| 177 scoped_ptr<DriveEntryProto> entry_proto); | |
| 178 | |
| 179 // Part of DoLoadDirectoryFromServer for the grand root ("/drive" directory). | |
| 180 // Called when GetAboutResource is completed. | |
| 181 // |callback| must not be null. | |
| 182 void DoLoadGrandRootDirectoryFromServerAfterGetAboutResource( | |
| 183 const DirectoryFetchInfo& directory_fetch_info, | |
| 184 const FileOperationCallback& callback, | |
| 185 google_apis::GDataErrorCode status, | |
| 186 scoped_ptr<google_apis::AboutResource> about_resource); | |
| 187 | |
| 188 // Part of DoLoadDirectoryFromServer(). Called after | |
| 189 // LoadFromServer() is complete. | |
| 190 void DoLoadDirectoryFromServerAfterLoad( | |
| 191 const DirectoryFetchInfo& directory_fetch_info, | |
| 192 const FileOperationCallback& callback, | |
| 193 ScopedVector<ChangeList> change_lists, | |
| 194 DriveFileError error); | |
| 195 | |
| 196 // Part of DoLoadDirectoryFromServer(). Called after | |
| 197 // DriveResourceMetadata::RefreshDirectory() is complete. | |
| 198 void DoLoadDirectoryFromServerAfterRefresh( | |
| 199 const DirectoryFetchInfo& directory_fetch_info, | |
| 200 const FileOperationCallback& callback, | |
| 201 DriveFileError error, | |
| 202 const base::FilePath& directory_path); | |
| 203 | |
| 204 // Part of LoadFromServerIfNeeded(). Called when GetAboutResource is complete. | |
| 205 void LoadFromServerIfNeededAfterGetAbout( | 147 void LoadFromServerIfNeededAfterGetAbout( |
| 206 const DirectoryFetchInfo& directory_fetch_info, | 148 const DirectoryFetchInfo& directory_fetch_info, |
| 207 int64 local_changestamp, | 149 int64 local_changestamp, |
| 208 google_apis::GDataErrorCode status, | 150 google_apis::GDataErrorCode status, |
| 209 scoped_ptr<google_apis::AboutResource> about_resource); | 151 scoped_ptr<google_apis::AboutResource> about_resource); |
| 210 | 152 |
| 211 // Part of LoadFromServerIfNeeded(). | 153 // Part of LoadFromServerIfNeeded(). |
| 154 // When LoadFromServerIfNeeded is called with |directory_fetch_info| for a | |
| 155 // specific directory, it tries to load the directory before loading the | |
| 156 // content of full filesystem. This method is called after directory loading | |
| 157 // is finished, and proceeds to the normal pass: LoadChangeListServer. | |
| 158 void LoadChangeListFromServerAfterLoadDirectory( | |
| 159 const DirectoryFetchInfo& directory_fetch_info, | |
| 160 scoped_ptr<google_apis::AboutResource> about_resource, | |
| 161 int64 start_changestamp, | |
| 162 DriveFileError error); | |
| 163 | |
| 164 // Part of LoadFromServerIfNeeded(). | |
| 212 // Starts loading the change list since |start_changestamp|, or the full | 165 // Starts loading the change list since |start_changestamp|, or the full |
| 213 // resource list if |start_changestamp| is zero. For full update, the | 166 // resource list if |start_changestamp| is zero. For full update, the |
| 214 // largest_change_id and root_folder_id from |about_resource| will be used. | 167 // largest_change_id and root_folder_id from |about_resource| will be used. |
| 215 void LoadChangeListFromServer( | 168 void LoadChangeListFromServer( |
| 216 scoped_ptr<google_apis::AboutResource> about_resource, | 169 scoped_ptr<google_apis::AboutResource> about_resource, |
| 217 int64 start_changestamp); | 170 int64 start_changestamp); |
| 218 | 171 |
| 219 // Part of LoadFromServerIfNeeded(). | 172 // Part of LoadFromServerIfNeeded(). |
| 220 // Starts loading the change list from the server. Called after the | 173 // Callback to fetch all the resource list response from the server. |
| 221 // directory contents are "fast-fetch"ed. | 174 // After all the resource list are fetched, |callback| |
| 222 void LoadChangeListFromServerAfterLoadDirectory( | 175 // will be invoked with the collected change lists. |
| 223 const DirectoryFetchInfo& directory_fetch_info, | 176 void OnGetResourceList(ScopedVector<ChangeList> change_lists, |
| 224 scoped_ptr<google_apis::AboutResource> about_resource, | 177 const LoadFeedListCallback& callback, |
| 225 int64 start_changestamp, | 178 base::TimeTicks start_time, |
| 226 DriveFileError error); | 179 google_apis::GDataErrorCode status, |
| 180 scoped_ptr<google_apis::ResourceList> data); | |
| 181 | |
| 182 // Part of LoadFromServerIfNeeded(). | |
| 183 // Applies the change list loaded from the server to local metadata storage. | |
| 184 void UpdateMetadataFromFeedAfterLoadFromServer( | |
| 185 scoped_ptr<google_apis::AboutResource> about_resource, | |
| 186 bool is_delta_feed, | |
| 187 ScopedVector<ChangeList> change_lists, | |
| 188 DriveFileError error); | |
| 189 | |
| 190 // Part of LoadFromServerIfNeeded(). | |
| 191 // Called when UpdateMetadataFromFeedAfterLoadFromServer is finished. | |
| 192 void OnUpdateFromFeed(); | |
| 193 | |
| 194 // ================= Implementation for directory loading ================= | |
| 195 | |
| 196 // Part of LoadDirectoryFromServer(). | |
| 197 // Called after GetAboutResource() for getting remote changestamp is complete. | |
| 198 // Note that it directly proceeds to DoLoadDirectoryFromServer() not going | |
| 199 // through CheckChangestampAndLoadDirectoryIfNeeed, because the purpose of | |
| 200 // LoadDirectoryFromServer is to force reloading regardless of changestamp. | |
| 201 void LoadDirectoryFromServerAfterGetAbout( | |
| 202 const std::string& directory_resource_id, | |
| 203 const FileOperationCallback& callback, | |
| 204 google_apis::GDataErrorCode status, | |
| 205 scoped_ptr<google_apis::AboutResource> about_resource); | |
| 206 | |
| 207 // Compares the directory's changestamp and |last_known_remote_changestamp_|. | |
| 208 // Starts DoLoadDirectoryFromServer() if the local data is old and runs | |
| 209 // |callback| when finished. If it is up to date, calls back immediately. | |
| 210 void CheckChangestampAndLoadDirectoryIfNeeed( | |
| 211 const DirectoryFetchInfo& directory_fetch_info, | |
| 212 int64 local_changestamp, | |
| 213 const FileOperationCallback& callback); | |
| 214 | |
| 215 // Loads the directory contents from server, and updates the local metadata. | |
| 216 // Runs |callback| when it is finished. | |
| 217 void DoLoadDirectoryFromServer(const DirectoryFetchInfo& directory_fetch_info, | |
| 218 const FileOperationCallback& callback); | |
| 219 | |
| 220 // Part of DoLoadDirectoryFromServer() for the grand root ("/drive"). | |
| 221 void DoLoadGrandRootDirectoryFromServerAfterGetEntryInfoByPath( | |
| 222 const DirectoryFetchInfo& directory_fetch_info, | |
| 223 const FileOperationCallback& callback, | |
| 224 DriveFileError error, | |
| 225 scoped_ptr<DriveEntryProto> entry_proto); | |
| 226 | |
| 227 // Part of DoLoadDirectoryFromServer() for the grand root ("/drive"). | |
| 228 void DoLoadGrandRootDirectoryFromServerAfterGetAboutResource( | |
| 229 const DirectoryFetchInfo& directory_fetch_info, | |
| 230 const FileOperationCallback& callback, | |
| 231 google_apis::GDataErrorCode status, | |
| 232 scoped_ptr<google_apis::AboutResource> about_resource); | |
| 233 | |
| 234 // Part of DoLoadDirectoryFromServer() for a normal directory. | |
| 235 void DoLoadDirectoryFromServerAfterLoad( | |
| 236 const DirectoryFetchInfo& directory_fetch_info, | |
| 237 const FileOperationCallback& callback, | |
| 238 ScopedVector<ChangeList> change_lists, | |
| 239 DriveFileError error); | |
| 240 | |
| 241 // Part of DoLoadDirectoryFromServer(). | |
| 242 void DoLoadDirectoryFromServerAfterRefresh( | |
| 243 const DirectoryFetchInfo& directory_fetch_info, | |
| 244 const FileOperationCallback& callback, | |
| 245 DriveFileError error, | |
| 246 const base::FilePath& directory_path); | |
| 247 | |
| 248 // ================= Implementation for other stuff ================= | |
| 227 | 249 |
| 228 // Callback for handling response from |DriveAPIService::GetAppList|. | 250 // Callback for handling response from |DriveAPIService::GetAppList|. |
| 229 // If the application list is successfully parsed, passes the list to | 251 // If the application list is successfully parsed, passes the list to |
| 230 // Drive webapps registry. | 252 // Drive webapps registry. |
| 231 void OnGetAppList(google_apis::GDataErrorCode status, | 253 void OnGetAppList(google_apis::GDataErrorCode status, |
| 232 scoped_ptr<google_apis::AppList> app_list); | 254 scoped_ptr<google_apis::AppList> app_list); |
| 233 | 255 |
| 234 // Part of SearchFromServer. Called when ResourceList is fetched from the | 256 // Part of SearchFromServer(). |
| 235 // server. | 257 // Processes the ResourceList received from server and passes to |callback|. |
| 236 // |callback| must not be null. | |
| 237 void SearchFromServerAfterGetResourceList( | 258 void SearchFromServerAfterGetResourceList( |
| 238 const LoadFeedListCallback& callback, | 259 const LoadFeedListCallback& callback, |
| 239 google_apis::GDataErrorCode status, | 260 google_apis::GDataErrorCode status, |
| 240 scoped_ptr<google_apis::ResourceList> resource_list); | 261 scoped_ptr<google_apis::ResourceList> resource_list); |
| 241 | 262 |
| 242 // Part of LoadChangeListFromServer(). | 263 // Part of UpdateFromFeed(). |
| 243 // Applies the change list loaded from the server to local metadata storage. | |
| 244 void UpdateMetadataFromFeedAfterLoadFromServer( | |
| 245 scoped_ptr<google_apis::AboutResource> about_resource, | |
| 246 bool is_delta_feed, | |
| 247 ScopedVector<ChangeList> change_lists, | |
| 248 DriveFileError error); | |
| 249 | |
| 250 // Callback for ChangeListProcessor::ApplyFeeds. | 264 // Callback for ChangeListProcessor::ApplyFeeds. |
| 251 void NotifyDirectoryChangedAfterApplyFeed( | 265 void NotifyDirectoryChangedAfterApplyFeed(bool should_notify, |
| 252 bool should_notify, | 266 const base::Closure& callback); |
| 253 const base::Closure& update_finished_callback); | |
| 254 | |
| 255 // Part of LoadChangeListFromServer(). | |
| 256 // Called when UpdateMetadataFromFeedAfterLoadFromServer is finished. | |
| 257 void OnUpdateFromFeed(); | |
| 258 | |
| 259 // This function should be called when the change list load is complete. | |
| 260 // Flushes the callbacks for change list loading and all directory loading. | |
| 261 void OnChangeListLoadComplete(DriveFileError error); | |
| 262 | |
| 263 // This function should be called when the directory load is complete. | |
| 264 // Flushes the callbacks waiting for the directory to be loaded. | |
| 265 void OnDirectoryLoadComplete(const DirectoryFetchInfo& directory_fetch_info, | |
| 266 DriveFileError error); | |
| 267 | 267 |
| 268 DriveResourceMetadata* resource_metadata_; // Not owned. | 268 DriveResourceMetadata* resource_metadata_; // Not owned. |
| 269 DriveScheduler* scheduler_; // Not owned. | 269 DriveScheduler* scheduler_; // Not owned. |
| 270 DriveWebAppsRegistry* webapps_registry_; // Not owned. | 270 DriveWebAppsRegistry* webapps_registry_; // Not owned. |
| 271 ObserverList<ChangeListLoaderObserver> observers_; | 271 ObserverList<ChangeListLoaderObserver> observers_; |
| 272 scoped_ptr<ChangeListProcessor> change_list_processor_; | 272 scoped_ptr<ChangeListProcessor> change_list_processor_; |
| 273 typedef std::map<std::string, std::vector<FileOperationCallback> > | 273 typedef std::map<std::string, std::vector<FileOperationCallback> > |
| 274 LoadCallbackMap; | 274 LoadCallbackMap; |
| 275 LoadCallbackMap pending_load_callback_; | 275 LoadCallbackMap pending_load_callback_; |
| 276 | 276 |
| 277 // Indicates whether there is a feed refreshing server request is in flight. | 277 // Indicates whether there is a feed refreshing server request is in flight. |
| 278 int64 last_known_remote_changestamp_; | 278 int64 last_known_remote_changestamp_; |
| 279 | 279 |
| 280 // True if the file system feed is loaded from the cache or from the server. | 280 // True if the file system feed is loaded from the cache or from the server. |
| 281 bool loaded_; | 281 bool loaded_; |
| 282 | 282 |
| 283 // Note: This should remain the last member so it'll be destroyed and | 283 // Note: This should remain the last member so it'll be destroyed and |
| 284 // invalidate its weak pointers before any other members are destroyed. | 284 // invalidate its weak pointers before any other members are destroyed. |
| 285 base::WeakPtrFactory<ChangeListLoader> weak_ptr_factory_; | 285 base::WeakPtrFactory<ChangeListLoader> weak_ptr_factory_; |
| 286 DISALLOW_COPY_AND_ASSIGN(ChangeListLoader); | 286 DISALLOW_COPY_AND_ASSIGN(ChangeListLoader); |
| 287 }; | 287 }; |
| 288 | 288 |
| 289 } // namespace drive | 289 } // namespace drive |
| 290 | 290 |
| 291 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ | 291 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ |
| OLD | NEW |