| 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 |
| 54 // Checks for updates on the server. Does nothing if the change list is now |
| 55 // being loaded or refreshed. |callback| must not be null. |
| 56 void CheckForUpdates(const FileOperationCallback& callback); |
| 57 |
| 52 // Starts the change list loading first from the cache. If loading from the | 58 // 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 | 59 // cache is successful, runs |callback| immediately and starts checking |
| 54 // if needed (i.e. the cache is old). If loading from the cache is | 60 // server for updates in background. If loading from the cache is |
| 55 // unsuccessful, starts loading from the server, and runs |callback| to | 61 // unsuccessful, starts loading from the server, and runs |callback| to tell |
| 56 // tell the result to the caller. | 62 // the result to the caller when it is finished. |
| 57 // | 63 // |
| 58 // If |directory_fetch_info| is not empty, the directory will be fetched | 64 // 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 | 65 // first from the server, so the UI can show the directory contents |
| 60 // instantly before the entire change list loading is complete. | 66 // instantly before the entire change list loading is complete. |
| 61 // | 67 // |
| 62 // |callback| must not be null. | 68 // |callback| must not be null. |
| 63 void LoadIfNeeded(const DirectoryFetchInfo& directory_fetch_info, | 69 void LoadIfNeeded(const DirectoryFetchInfo& directory_fetch_info, |
| 64 const FileOperationCallback& callback); | 70 const FileOperationCallback& callback); |
| 65 | 71 |
| 66 // Initiates the directory contents loading. This function first obtains | 72 // Initiates the directory contents loading. This function first obtains |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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 | 95 // TODO(satorux): Make this private. crbug.com/232208 |
| 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|. | 96 // Updates whole directory structure feeds collected in |feed_list|. |
| 94 // Record file statistics as UMA histograms. | 97 // Record file statistics as UMA histograms. |
| 95 // | 98 // |
| 96 // See comments at ChangeListProcessor::ApplyFeeds() for | 99 // See comments at ChangeListProcessor::ApplyFeeds() for |
| 97 // |about_resource| and |is_delta_feed|. | 100 // |about_resource| and |is_delta_feed|. |
| 98 // |update_finished_callback| must not be null. | 101 // |callback| must not be null. |
| 99 void UpdateFromFeed(scoped_ptr<google_apis::AboutResource> about_resource, | 102 void UpdateFromFeed(scoped_ptr<google_apis::AboutResource> about_resource, |
| 100 ScopedVector<ChangeList> change_lists, | 103 ScopedVector<ChangeList> change_lists, |
| 101 bool is_delta_feed, | 104 bool is_delta_feed, |
| 102 const base::Closure& update_finished_callback); | 105 const base::Closure& callback); |
| 103 | |
| 104 // Indicates whether there is a feed refreshing server request is in flight. | |
| 105 bool IsRefreshing() const; | |
| 106 | 106 |
| 107 private: | 107 private: |
| 108 // Implementation of LoadIfNeeded and CheckForUpdates. Start metadata loading | 108 // 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 | 109 // 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 | 110 // |directory_fetch_info|, just append the |callback| to the callback queue |
| 111 // the |callback| to the callback queue of the already running job. | 111 // of the already running job. |
| 112 void Load(const DirectoryFetchInfo& directory_fetch_info, | 112 void Load(const DirectoryFetchInfo& directory_fetch_info, |
| 113 const FileOperationCallback& callback); | 113 const FileOperationCallback& callback); |
| 114 | 114 |
| 115 // Part of Load(). DoInitialLoad() is called if it is the first time to Load. | 115 // 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: | 116 // Otherwise DoUpdateLoad() is used. The difference of two cases are: |
| 117 // - When we could load from cache, DoInitialLoad runs callback immediately | 117 // - When we could load from cache, DoInitialLoad runs callback immediately |
| 118 // and further operations (check changestamp and load from server if needed) | 118 // and further operations (check changestamp and load from server if needed) |
| 119 // in background. | 119 // in background. |
| 120 // - Even when |directory_fetch_info| is set, DoInitialLoad runs change list | 120 // - Even when |directory_fetch_info| is set, DoInitialLoad runs change list |
| 121 // loading after directory loading is finished. | 121 // loading after directory loading is finished. |
| 122 void DoInitialLoad(const DirectoryFetchInfo& directory_fetch_info, | 122 void DoInitialLoad(const DirectoryFetchInfo& directory_fetch_info, |
| 123 int64 local_changestamp); | 123 int64 local_changestamp); |
| 124 void DoUpdateLoad(const DirectoryFetchInfo& directory_fetch_info, | 124 void DoUpdateLoad(const DirectoryFetchInfo& directory_fetch_info, |
| 125 int64 local_changestamp); | 125 int64 local_changestamp); |
| 126 | 126 |
| 127 // Part of Load(). | 127 // Part of Load(). |
| 128 // This function should be called when the change list load is complete. |
| 129 // Flushes the callbacks for change list loading and all directory loading. |
| 130 void OnChangeListLoadComplete(DriveFileError error); |
| 131 |
| 132 // Part of Load(). |
| 133 // This function should be called when the directory load is complete. |
| 134 // Flushes the callbacks waiting for the directory to be loaded. |
| 135 void OnDirectoryLoadComplete(const DirectoryFetchInfo& directory_fetch_info, |
| 136 DriveFileError error); |
| 137 |
| 138 // ================= Implementation for change list loading ================= |
| 139 |
| 128 // Initiates the change list loading from the server when |local_changestamp| | 140 // Initiates the change list loading from the server when |local_changestamp| |
| 129 // is older than the server changestamp. If |directory_fetch_info| is set, | 141 // is older than the server changestamp. If |directory_fetch_info| is set, |
| 130 // do directory loading before change list loading. | 142 // do directory loading before change list loading. |
| 131 void LoadFromServerIfNeeded(const DirectoryFetchInfo& directory_fetch_info, | 143 void LoadFromServerIfNeeded(const DirectoryFetchInfo& directory_fetch_info, |
| 132 int64 local_changestamp); | 144 int64 local_changestamp); |
| 133 | 145 |
| 134 // Part of Load(). | 146 // Part of LoadFromServerIfNeeded(). |
| 135 // Checks the directory's changestamp and |last_known_remote_changestamp_|, | 147 // 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( | 148 void LoadFromServerIfNeededAfterGetAbout( |
| 206 const DirectoryFetchInfo& directory_fetch_info, | 149 const DirectoryFetchInfo& directory_fetch_info, |
| 207 int64 local_changestamp, | 150 int64 local_changestamp, |
| 208 google_apis::GDataErrorCode status, | 151 google_apis::GDataErrorCode status, |
| 209 scoped_ptr<google_apis::AboutResource> about_resource); | 152 scoped_ptr<google_apis::AboutResource> about_resource); |
| 210 | 153 |
| 211 // Part of LoadFromServerIfNeeded(). | 154 // Part of LoadFromServerIfNeeded(). |
| 155 // When LoadFromServerIfNeeded is called with |directory_fetch_info| for a |
| 156 // specific directory, it tries to load the directory before loading the |
| 157 // content of full filesystem. This method is called after directory loading |
| 158 // is finished, and proceeds to the normal pass: LoadChangeListServer. |
| 159 void LoadChangeListFromServerAfterLoadDirectory( |
| 160 const DirectoryFetchInfo& directory_fetch_info, |
| 161 scoped_ptr<google_apis::AboutResource> about_resource, |
| 162 int64 start_changestamp, |
| 163 DriveFileError error); |
| 164 |
| 165 // Part of LoadFromServerIfNeeded(). |
| 212 // Starts loading the change list since |start_changestamp|, or the full | 166 // Starts loading the change list since |start_changestamp|, or the full |
| 213 // resource list if |start_changestamp| is zero. For full update, the | 167 // 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. | 168 // largest_change_id and root_folder_id from |about_resource| will be used. |
| 215 void LoadChangeListFromServer( | 169 void LoadChangeListFromServer( |
| 216 scoped_ptr<google_apis::AboutResource> about_resource, | 170 scoped_ptr<google_apis::AboutResource> about_resource, |
| 217 int64 start_changestamp); | 171 int64 start_changestamp); |
| 218 | 172 |
| 219 // Part of LoadFromServerIfNeeded(). | 173 // Part of LoadFromServerIfNeeded(). |
| 220 // Starts loading the change list from the server. Called after the | 174 // Callback to fetch all the resource list response from the server. |
| 221 // directory contents are "fast-fetch"ed. | 175 // After all the resource list are fetched, |callback| |
| 222 void LoadChangeListFromServerAfterLoadDirectory( | 176 // will be invoked with the collected change lists. |
| 223 const DirectoryFetchInfo& directory_fetch_info, | 177 void OnGetResourceList(ScopedVector<ChangeList> change_lists, |
| 224 scoped_ptr<google_apis::AboutResource> about_resource, | 178 const LoadFeedListCallback& callback, |
| 225 int64 start_changestamp, | 179 base::TimeTicks start_time, |
| 226 DriveFileError error); | 180 google_apis::GDataErrorCode status, |
| 181 scoped_ptr<google_apis::ResourceList> data); |
| 182 |
| 183 // Part of LoadFromServerIfNeeded(). |
| 184 // Applies the change list loaded from the server to local metadata storage. |
| 185 void UpdateMetadataFromFeedAfterLoadFromServer( |
| 186 scoped_ptr<google_apis::AboutResource> about_resource, |
| 187 bool is_delta_feed, |
| 188 ScopedVector<ChangeList> change_lists, |
| 189 DriveFileError error); |
| 190 |
| 191 // Part of LoadFromServerIfNeeded(). |
| 192 // Called when UpdateMetadataFromFeedAfterLoadFromServer is finished. |
| 193 void OnUpdateFromFeed(); |
| 194 |
| 195 // ================= Implementation for directory loading ================= |
| 196 |
| 197 // Part of LoadDirectoryFromServer(). |
| 198 // Called after GetAboutResource() for getting remote changestamp is complete. |
| 199 // Note that it directly proceeds to DoLoadDirectoryFromServer() not going |
| 200 // through CheckChangestampAndLoadDirectoryIfNeeed, because the purpose of |
| 201 // LoadDirectoryFromServer is to force reloading regardless of changestamp. |
| 202 void LoadDirectoryFromServerAfterGetAbout( |
| 203 const std::string& directory_resource_id, |
| 204 const FileOperationCallback& callback, |
| 205 google_apis::GDataErrorCode status, |
| 206 scoped_ptr<google_apis::AboutResource> about_resource); |
| 207 |
| 208 // Compares the directory's changestamp and |last_known_remote_changestamp_|. |
| 209 // Starts DoLoadDirectoryFromServer() if the local data is old and runs |
| 210 // |callback| when finished. If it is up to date, calls back immediately. |
| 211 void CheckChangestampAndLoadDirectoryIfNeeed( |
| 212 const DirectoryFetchInfo& directory_fetch_info, |
| 213 int64 local_changestamp, |
| 214 const FileOperationCallback& callback); |
| 215 |
| 216 // Loads the directory contents from server, and updates the local metadata. |
| 217 // Runs |callback| when it is finished. |
| 218 void DoLoadDirectoryFromServer(const DirectoryFetchInfo& directory_fetch_info, |
| 219 const FileOperationCallback& callback); |
| 220 |
| 221 // Part of DoLoadDirectoryFromServer() for the grand root ("/drive"). |
| 222 void DoLoadGrandRootDirectoryFromServerAfterGetEntryInfoByPath( |
| 223 const DirectoryFetchInfo& directory_fetch_info, |
| 224 const FileOperationCallback& callback, |
| 225 DriveFileError error, |
| 226 scoped_ptr<DriveEntryProto> entry_proto); |
| 227 |
| 228 // Part of DoLoadDirectoryFromServer() for the grand root ("/drive"). |
| 229 void DoLoadGrandRootDirectoryFromServerAfterGetAboutResource( |
| 230 const DirectoryFetchInfo& directory_fetch_info, |
| 231 const FileOperationCallback& callback, |
| 232 google_apis::GDataErrorCode status, |
| 233 scoped_ptr<google_apis::AboutResource> about_resource); |
| 234 |
| 235 // Part of DoLoadDirectoryFromServer() for a normal directory. |
| 236 void DoLoadDirectoryFromServerAfterLoad( |
| 237 const DirectoryFetchInfo& directory_fetch_info, |
| 238 const FileOperationCallback& callback, |
| 239 ScopedVector<ChangeList> change_lists, |
| 240 DriveFileError error); |
| 241 |
| 242 // Part of DoLoadDirectoryFromServer(). |
| 243 void DoLoadDirectoryFromServerAfterRefresh( |
| 244 const DirectoryFetchInfo& directory_fetch_info, |
| 245 const FileOperationCallback& callback, |
| 246 DriveFileError error, |
| 247 const base::FilePath& directory_path); |
| 248 |
| 249 // ================= Implementation for other stuff ================= |
| 227 | 250 |
| 228 // Callback for handling response from |DriveAPIService::GetAppList|. | 251 // Callback for handling response from |DriveAPIService::GetAppList|. |
| 229 // If the application list is successfully parsed, passes the list to | 252 // If the application list is successfully parsed, passes the list to |
| 230 // Drive webapps registry. | 253 // Drive webapps registry. |
| 231 void OnGetAppList(google_apis::GDataErrorCode status, | 254 void OnGetAppList(google_apis::GDataErrorCode status, |
| 232 scoped_ptr<google_apis::AppList> app_list); | 255 scoped_ptr<google_apis::AppList> app_list); |
| 233 | 256 |
| 234 // Part of SearchFromServer. Called when ResourceList is fetched from the | 257 // Part of SearchFromServer(). |
| 235 // server. | 258 // Processes the ResourceList received from server and passes to |callback|. |
| 236 // |callback| must not be null. | |
| 237 void SearchFromServerAfterGetResourceList( | 259 void SearchFromServerAfterGetResourceList( |
| 238 const LoadFeedListCallback& callback, | 260 const LoadFeedListCallback& callback, |
| 239 google_apis::GDataErrorCode status, | 261 google_apis::GDataErrorCode status, |
| 240 scoped_ptr<google_apis::ResourceList> resource_list); | 262 scoped_ptr<google_apis::ResourceList> resource_list); |
| 241 | 263 |
| 242 // Part of LoadChangeListFromServer(). | 264 // 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. | 265 // Callback for ChangeListProcessor::ApplyFeeds. |
| 251 void NotifyDirectoryChangedAfterApplyFeed( | 266 void NotifyDirectoryChangedAfterApplyFeed(bool should_notify, |
| 252 bool should_notify, | 267 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 | 268 |
| 268 DriveResourceMetadata* resource_metadata_; // Not owned. | 269 DriveResourceMetadata* resource_metadata_; // Not owned. |
| 269 DriveScheduler* scheduler_; // Not owned. | 270 DriveScheduler* scheduler_; // Not owned. |
| 270 DriveWebAppsRegistry* webapps_registry_; // Not owned. | 271 DriveWebAppsRegistry* webapps_registry_; // Not owned. |
| 271 ObserverList<ChangeListLoaderObserver> observers_; | 272 ObserverList<ChangeListLoaderObserver> observers_; |
| 272 scoped_ptr<ChangeListProcessor> change_list_processor_; | 273 scoped_ptr<ChangeListProcessor> change_list_processor_; |
| 273 typedef std::map<std::string, std::vector<FileOperationCallback> > | 274 typedef std::map<std::string, std::vector<FileOperationCallback> > |
| 274 LoadCallbackMap; | 275 LoadCallbackMap; |
| 275 LoadCallbackMap pending_load_callback_; | 276 LoadCallbackMap pending_load_callback_; |
| 276 | 277 |
| 277 // Indicates whether there is a feed refreshing server request is in flight. | 278 // Indicates whether there is a feed refreshing server request is in flight. |
| 278 int64 last_known_remote_changestamp_; | 279 int64 last_known_remote_changestamp_; |
| 279 | 280 |
| 280 // True if the file system feed is loaded from the cache or from the server. | 281 // True if the file system feed is loaded from the cache or from the server. |
| 281 bool loaded_; | 282 bool loaded_; |
| 282 | 283 |
| 283 // Note: This should remain the last member so it'll be destroyed and | 284 // Note: This should remain the last member so it'll be destroyed and |
| 284 // invalidate its weak pointers before any other members are destroyed. | 285 // invalidate its weak pointers before any other members are destroyed. |
| 285 base::WeakPtrFactory<ChangeListLoader> weak_ptr_factory_; | 286 base::WeakPtrFactory<ChangeListLoader> weak_ptr_factory_; |
| 286 DISALLOW_COPY_AND_ASSIGN(ChangeListLoader); | 287 DISALLOW_COPY_AND_ASSIGN(ChangeListLoader); |
| 287 }; | 288 }; |
| 288 | 289 |
| 289 } // namespace drive | 290 } // namespace drive |
| 290 | 291 |
| 291 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ | 292 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_CHANGE_LIST_LOADER_H_ |
| OLD | NEW |