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 "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
11 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h" | 11 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h" |
12 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | 12 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class Value; | 16 class Value; |
17 } | 17 } |
18 | 18 |
19 namespace gdata { | 19 namespace gdata { |
20 | 20 |
21 class DriveWebAppsRegistryInterface; | 21 class DriveWebAppsRegistryInterface; |
22 class DocumentFeed; | 22 class DocumentFeed; |
23 class DocumentsServiceInterface; | 23 class DriveServiceInterface; |
24 class GDataCache; | 24 class GDataCache; |
25 struct GetDocumentsUiState; | 25 struct GetDocumentsUiState; |
26 | 26 |
27 // Set of parameters sent to LoadDocumentFeedCallback callback. | 27 // Set of parameters sent to LoadDocumentFeedCallback callback. |
28 struct GetDocumentsParams { | 28 struct GetDocumentsParams { |
29 GetDocumentsParams(int64 start_changestamp, | 29 GetDocumentsParams(int64 start_changestamp, |
30 int64 root_feed_changestamp, | 30 int64 root_feed_changestamp, |
31 std::vector<DocumentFeed*>* feed_list, | 31 std::vector<DocumentFeed*>* feed_list, |
32 const std::string& search_query, | 32 const std::string& search_query, |
33 const std::string& directory_resource_id, | 33 const std::string& directory_resource_id, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 // Triggered when the feed from the server is loaded. | 89 // Triggered when the feed from the server is loaded. |
90 virtual void OnFeedFromServerLoaded() {} | 90 virtual void OnFeedFromServerLoaded() {} |
91 | 91 |
92 protected: | 92 protected: |
93 virtual ~Observer() {} | 93 virtual ~Observer() {} |
94 }; | 94 }; |
95 | 95 |
96 GDataWapiFeedLoader( | 96 GDataWapiFeedLoader( |
97 GDataDirectoryService* directory_service, | 97 GDataDirectoryService* directory_service, |
98 DocumentsServiceInterface* documents_service, | 98 DriveServiceInterface* drive_service, |
99 DriveWebAppsRegistryInterface* webapps_registry, | 99 DriveWebAppsRegistryInterface* webapps_registry, |
100 GDataCache* cache, | 100 GDataCache* cache, |
101 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_); | 101 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_); |
102 ~GDataWapiFeedLoader(); | 102 ~GDataWapiFeedLoader(); |
103 | 103 |
104 // Adds and removes the observer. | 104 // Adds and removes the observer. |
105 void AddObserver(Observer* observer); | 105 void AddObserver(Observer* observer); |
106 void RemoveObserver(Observer* observer); | 106 void RemoveObserver(Observer* observer); |
107 | 107 |
108 // Starts root feed load from the cache. If successful, runs |callback| to | 108 // Starts root feed load from the cache. If successful, runs |callback| to |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // from ReloadFeedFromServerIfNeeded() for Drive V2 API. | 182 // from ReloadFeedFromServerIfNeeded() for Drive V2 API. |
183 // This method makes a decision about fetching the content of the root feed | 183 // This method makes a decision about fetching the content of the root feed |
184 // during the root directory refresh process. | 184 // during the root directory refresh process. |
185 void OnGetAboutResource( | 185 void OnGetAboutResource( |
186 ContentOrigin initial_origin, | 186 ContentOrigin initial_origin, |
187 int64 local_changestamp, | 187 int64 local_changestamp, |
188 const FileOperationCallback& callback, | 188 const FileOperationCallback& callback, |
189 GDataErrorCode status, | 189 GDataErrorCode status, |
190 scoped_ptr<base::Value> feed_data); | 190 scoped_ptr<base::Value> feed_data); |
191 | 191 |
192 // Callback for handling response from | 192 // Callback for handling response from |DriveAPIService::GetApplicationInfo|. |
193 // |GDataDocumentsService::GetApplicationList|. | |
194 // If the application list is successfully parsed, passes the list to | 193 // If the application list is successfully parsed, passes the list to |
195 // Drive webapps registry. | 194 // Drive webapps registry. |
196 void OnGetApplicationList(GDataErrorCode status, | 195 void OnGetApplicationList(GDataErrorCode status, |
197 scoped_ptr<base::Value> json); | 196 scoped_ptr<base::Value> json); |
198 | 197 |
199 // Callback for handling feed content fetching while searching for file info. | 198 // Callback for handling feed content fetching while searching for file info. |
200 // This callback is invoked after async feed fetch operation that was | 199 // This callback is invoked after async feed fetch operation that was |
201 // invoked by StartDirectoryRefresh() completes. This callback will update | 200 // invoked by StartDirectoryRefresh() completes. This callback will update |
202 // the content of the refreshed directory object and continue initially | 201 // the content of the refreshed directory object and continue initially |
203 // started FindEntryByPath() request. | 202 // started FindEntryByPath() request. |
204 void OnFeedFromServerLoaded(GetDocumentsParams* params, | 203 void OnFeedFromServerLoaded(GetDocumentsParams* params, |
205 GDataFileError error); | 204 GDataFileError error); |
206 | 205 |
207 // Callback for handling response from |GDataDocumentsService::GetDocuments|. | 206 // Callback for handling response from |GDataWapiService::GetDocuments|. |
208 // Invokes |callback| when done. | 207 // Invokes |callback| when done. |
209 // |callback| must not be null. | 208 // |callback| must not be null. |
210 void OnGetDocuments( | 209 void OnGetDocuments( |
211 ContentOrigin initial_origin, | 210 ContentOrigin initial_origin, |
212 const LoadDocumentFeedCallback& callback, | 211 const LoadDocumentFeedCallback& callback, |
213 GetDocumentsParams* params, | 212 GetDocumentsParams* params, |
214 base::TimeTicks start_time, | 213 base::TimeTicks start_time, |
215 GDataErrorCode status, | 214 GDataErrorCode status, |
216 scoped_ptr<base::Value> data); | 215 scoped_ptr<base::Value> data); |
217 | 216 |
218 // Callback for handling response from |GDataDocumentsService::GetChanglist|. | 217 // Callback for handling response from |DriveAPIService::GetChanglist|. |
219 // Invokes |callback| when done. | 218 // Invokes |callback| when done. |
220 // |callback| must not be null. | 219 // |callback| must not be null. |
221 void OnGetChangelist(ContentOrigin initial_origin, | 220 void OnGetChangelist(ContentOrigin initial_origin, |
222 const LoadDocumentFeedCallback& callback, | 221 const LoadDocumentFeedCallback& callback, |
223 GetDocumentsParams* params, | 222 GetDocumentsParams* params, |
224 base::TimeTicks start_time, | 223 base::TimeTicks start_time, |
225 GDataErrorCode status, | 224 GDataErrorCode status, |
226 scoped_ptr<base::Value> data); | 225 scoped_ptr<base::Value> data); |
227 | 226 |
228 // Save filesystem to disk. | 227 // Save filesystem to disk. |
229 void SaveFileSystem(); | 228 void SaveFileSystem(); |
230 | 229 |
231 // Callback for handling UI updates caused by document fetching. | 230 // Callback for handling UI updates caused by document fetching. |
232 void OnNotifyDocumentFeedFetched( | 231 void OnNotifyDocumentFeedFetched( |
233 base::WeakPtr<GetDocumentsUiState> ui_state); | 232 base::WeakPtr<GetDocumentsUiState> ui_state); |
234 | 233 |
235 GDataDirectoryService* directory_service_; // Not owned. | 234 GDataDirectoryService* directory_service_; // Not owned. |
236 DocumentsServiceInterface* documents_service_; // Not owned. | 235 DriveServiceInterface* drive_service_; // Not owned. |
237 DriveWebAppsRegistryInterface* webapps_registry_; // Not owned. | 236 DriveWebAppsRegistryInterface* webapps_registry_; // Not owned. |
238 GDataCache* cache_; // Not owned. | 237 GDataCache* cache_; // Not owned. |
239 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 238 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
240 ObserverList<Observer> observers_; | 239 ObserverList<Observer> observers_; |
241 | 240 |
242 // Note: This should remain the last member so it'll be destroyed and | 241 // Note: This should remain the last member so it'll be destroyed and |
243 // invalidate its weak pointers before any other members are destroyed. | 242 // invalidate its weak pointers before any other members are destroyed. |
244 base::WeakPtrFactory<GDataWapiFeedLoader> weak_ptr_factory_; | 243 base::WeakPtrFactory<GDataWapiFeedLoader> weak_ptr_factory_; |
245 DISALLOW_COPY_AND_ASSIGN(GDataWapiFeedLoader); | 244 DISALLOW_COPY_AND_ASSIGN(GDataWapiFeedLoader); |
246 }; | 245 }; |
247 | 246 |
248 } // namespace gdata | 247 } // namespace gdata |
249 | 248 |
250 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_ | 249 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_WAPI_FEED_LOADER_H_ |
OLD | NEW |