| 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_GDATA_GDATA_WAPI_FEED_LOADER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 // Defines set of parameters sent to callback OnProtoLoaded(). | 54 // Defines set of parameters sent to callback OnProtoLoaded(). |
| 55 struct LoadRootFeedParams { | 55 struct LoadRootFeedParams { |
| 56 LoadRootFeedParams( | 56 LoadRootFeedParams( |
| 57 bool should_load_from_server, | 57 bool should_load_from_server, |
| 58 const FileOperationCallback& callback); | 58 const FileOperationCallback& callback); |
| 59 ~LoadRootFeedParams(); | 59 ~LoadRootFeedParams(); |
| 60 | 60 |
| 61 bool should_load_from_server; | 61 bool should_load_from_server; |
| 62 std::string proto; | 62 std::string proto; |
| 63 GDataFileError load_error; | 63 DriveFileError load_error; |
| 64 base::Time last_modified; | 64 base::Time last_modified; |
| 65 // Time when filesystem began to be loaded from disk. | 65 // Time when filesystem began to be loaded from disk. |
| 66 base::Time load_start_time; | 66 base::Time load_start_time; |
| 67 const FileOperationCallback callback; | 67 const FileOperationCallback callback; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 // Callback run as a response to LoadFromServer. | 70 // Callback run as a response to LoadFromServer. |
| 71 typedef base::Callback<void(GetDocumentsParams* params, | 71 typedef base::Callback<void(GetDocumentsParams* params, |
| 72 GDataFileError error)> | 72 DriveFileError error)> |
| 73 LoadDocumentFeedCallback; | 73 LoadDocumentFeedCallback; |
| 74 | 74 |
| 75 // GDataWapiFeedLoader is used to load feeds from WAPI (codename for | 75 // GDataWapiFeedLoader is used to load feeds from WAPI (codename for |
| 76 // Documents List API) and load the cached proto file. | 76 // Documents List API) and load the cached proto file. |
| 77 class GDataWapiFeedLoader { | 77 class GDataWapiFeedLoader { |
| 78 public: | 78 public: |
| 79 // Used to notify events from the loader. | 79 // Used to notify events from the loader. |
| 80 // All events are notified on UI thread. | 80 // All events are notified on UI thread. |
| 81 class Observer { | 81 class Observer { |
| 82 public: | 82 public: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 ContentOrigin initial_origin, | 145 ContentOrigin initial_origin, |
| 146 int64 local_changestamp, | 146 int64 local_changestamp, |
| 147 const FileOperationCallback& callback); | 147 const FileOperationCallback& callback); |
| 148 | 148 |
| 149 // Updates whole directory structure feeds collected in |feed_list|. | 149 // Updates whole directory structure feeds collected in |feed_list|. |
| 150 // On success, returns PLATFORM_FILE_OK. Record file statistics as UMA | 150 // On success, returns PLATFORM_FILE_OK. Record file statistics as UMA |
| 151 // histograms. | 151 // histograms. |
| 152 // | 152 // |
| 153 // See comments at GDataWapiFeedProcessor::ApplyFeeds() for | 153 // See comments at GDataWapiFeedProcessor::ApplyFeeds() for |
| 154 // |start_changestamp| and |root_feed_changestamp|. | 154 // |start_changestamp| and |root_feed_changestamp|. |
| 155 GDataFileError UpdateFromFeed( | 155 DriveFileError UpdateFromFeed( |
| 156 const std::vector<DocumentFeed*>& feed_list, | 156 const std::vector<DocumentFeed*>& feed_list, |
| 157 int64 start_changestamp, | 157 int64 start_changestamp, |
| 158 int64 root_feed_changestamp); | 158 int64 root_feed_changestamp); |
| 159 | 159 |
| 160 private: | 160 private: |
| 161 struct LoadFeedParams; | 161 struct LoadFeedParams; |
| 162 | 162 |
| 163 // Starts root feed load from the server, with detail specified in |param|. | 163 // Starts root feed load from the server, with detail specified in |param|. |
| 164 void LoadFromServer(const LoadFeedParams& param); | 164 void LoadFromServer(const LoadFeedParams& param); |
| 165 | 165 |
| 166 // Callback for handling root directory refresh from the cache. | 166 // Callback for handling root directory refresh from the cache. |
| 167 void OnProtoLoaded(LoadRootFeedParams* params); | 167 void OnProtoLoaded(LoadRootFeedParams* params); |
| 168 | 168 |
| 169 // Continues handling root directory refresh after the directory service | 169 // Continues handling root directory refresh after the directory service |
| 170 // is fully loaded. | 170 // is fully loaded. |
| 171 void ContinueWithInitializedDirectoryService(LoadRootFeedParams* params, | 171 void ContinueWithInitializedDirectoryService(LoadRootFeedParams* params, |
| 172 GDataFileError error); | 172 DriveFileError error); |
| 173 | 173 |
| 174 // Helper callback for handling results of metadata retrieval initiated from | 174 // Helper callback for handling results of metadata retrieval initiated from |
| 175 // ReloadFeedFromServerIfNeeded(). This method makes a decision about fetching | 175 // ReloadFeedFromServerIfNeeded(). This method makes a decision about fetching |
| 176 // the content of the root feed during the root directory refresh process. | 176 // the content of the root feed during the root directory refresh process. |
| 177 void OnGetAccountMetadata( | 177 void OnGetAccountMetadata( |
| 178 ContentOrigin initial_origin, | 178 ContentOrigin initial_origin, |
| 179 int64 local_changestamp, | 179 int64 local_changestamp, |
| 180 const FileOperationCallback& callback, | 180 const FileOperationCallback& callback, |
| 181 GDataErrorCode status, | 181 GDataErrorCode status, |
| 182 scoped_ptr<base::Value> feed_data); | 182 scoped_ptr<base::Value> feed_data); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 197 // Drive webapps registry. | 197 // Drive webapps registry. |
| 198 void OnGetApplicationList(GDataErrorCode status, | 198 void OnGetApplicationList(GDataErrorCode status, |
| 199 scoped_ptr<base::Value> json); | 199 scoped_ptr<base::Value> json); |
| 200 | 200 |
| 201 // Callback for handling feed content fetching while searching for file info. | 201 // Callback for handling feed content fetching while searching for file info. |
| 202 // This callback is invoked after async feed fetch operation that was | 202 // This callback is invoked after async feed fetch operation that was |
| 203 // invoked by StartDirectoryRefresh() completes. This callback will update | 203 // invoked by StartDirectoryRefresh() completes. This callback will update |
| 204 // the content of the refreshed directory object and continue initially | 204 // the content of the refreshed directory object and continue initially |
| 205 // started FindEntryByPath() request. | 205 // started FindEntryByPath() request. |
| 206 void OnFeedFromServerLoaded(GetDocumentsParams* params, | 206 void OnFeedFromServerLoaded(GetDocumentsParams* params, |
| 207 GDataFileError error); | 207 DriveFileError error); |
| 208 | 208 |
| 209 // Callback for handling response from |GDataWapiService::GetDocuments|. | 209 // Callback for handling response from |GDataWapiService::GetDocuments|. |
| 210 // Invokes |callback| when done. | 210 // Invokes |callback| when done. |
| 211 // |callback| must not be null. | 211 // |callback| must not be null. |
| 212 void OnGetDocuments( | 212 void OnGetDocuments( |
| 213 ContentOrigin initial_origin, | 213 ContentOrigin initial_origin, |
| 214 const LoadDocumentFeedCallback& callback, | 214 const LoadDocumentFeedCallback& callback, |
| 215 GetDocumentsParams* params, | 215 GetDocumentsParams* params, |
| 216 base::TimeTicks start_time, | 216 base::TimeTicks start_time, |
| 217 GDataErrorCode status, | 217 GDataErrorCode status, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 243 | 243 |
| 244 // Note: This should remain the last member so it'll be destroyed and | 244 // Note: This should remain the last member so it'll be destroyed and |
| 245 // invalidate its weak pointers before any other members are destroyed. | 245 // invalidate its weak pointers before any other members are destroyed. |
| 246 base::WeakPtrFactory<GDataWapiFeedLoader> weak_ptr_factory_; | 246 base::WeakPtrFactory<GDataWapiFeedLoader> weak_ptr_factory_; |
| 247 DISALLOW_COPY_AND_ASSIGN(GDataWapiFeedLoader); | 247 DISALLOW_COPY_AND_ASSIGN(GDataWapiFeedLoader); |
| 248 }; | 248 }; |
| 249 | 249 |
| 250 } // namespace gdata | 250 } // namespace gdata |
| 251 | 251 |
| 252 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_ | 252 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_ |
| OLD | NEW |