Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h

Issue 10877006: Rename GDataErrorCode to DriveErrorCode, GDataFileError to DriveFileError (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "chrome/browser/chromeos/gdata/drive_errorcode.h"
14 #include "chrome/browser/chromeos/gdata/drive_resource_metadata.h" 15 #include "chrome/browser/chromeos/gdata/drive_resource_metadata.h"
15 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 17
18 namespace base { 18 namespace base {
19 class Value; 19 class Value;
20 } 20 }
21 21
22 namespace gdata { 22 namespace gdata {
23 23
24 class DocumentFeed; 24 class DocumentFeed;
25 class DriveCache; 25 class DriveCache;
(...skipping 27 matching lines...) Expand all
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
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 DriveErrorCode status,
182 scoped_ptr<base::Value> feed_data); 182 scoped_ptr<base::Value> feed_data);
183 183
184 // Helper callback for handling results of account data retrieval initiated 184 // Helper callback for handling results of account data retrieval initiated
185 // from ReloadFeedFromServerIfNeeded() for Drive V2 API. 185 // from ReloadFeedFromServerIfNeeded() for Drive V2 API.
186 // This method makes a decision about fetching the content of the root feed 186 // This method makes a decision about fetching the content of the root feed
187 // during the root directory refresh process. 187 // during the root directory refresh process.
188 void OnGetAboutResource( 188 void OnGetAboutResource(
189 ContentOrigin initial_origin, 189 ContentOrigin initial_origin,
190 int64 local_changestamp, 190 int64 local_changestamp,
191 const FileOperationCallback& callback, 191 const FileOperationCallback& callback,
192 GDataErrorCode status, 192 DriveErrorCode status,
193 scoped_ptr<base::Value> feed_data); 193 scoped_ptr<base::Value> feed_data);
194 194
195 // Callback for handling response from |DriveAPIService::GetApplicationInfo|. 195 // Callback for handling response from |DriveAPIService::GetApplicationInfo|.
196 // If the application list is successfully parsed, passes the list to 196 // If the application list is successfully parsed, passes the list to
197 // Drive webapps registry. 197 // Drive webapps registry.
198 void OnGetApplicationList(GDataErrorCode status, 198 void OnGetApplicationList(DriveErrorCode 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 DriveErrorCode status,
218 scoped_ptr<base::Value> data); 218 scoped_ptr<base::Value> data);
219 219
220 // Callback for handling response from |DriveAPIService::GetChanglist|. 220 // Callback for handling response from |DriveAPIService::GetChanglist|.
221 // Invokes |callback| when done. 221 // Invokes |callback| when done.
222 // |callback| must not be null. 222 // |callback| must not be null.
223 void OnGetChangelist(ContentOrigin initial_origin, 223 void OnGetChangelist(ContentOrigin initial_origin,
224 const LoadDocumentFeedCallback& callback, 224 const LoadDocumentFeedCallback& callback,
225 GetDocumentsParams* params, 225 GetDocumentsParams* params,
226 base::TimeTicks start_time, 226 base::TimeTicks start_time,
227 GDataErrorCode status, 227 DriveErrorCode status,
228 scoped_ptr<base::Value> data); 228 scoped_ptr<base::Value> data);
229 229
230 // Save filesystem to disk. 230 // Save filesystem to disk.
231 void SaveFileSystem(); 231 void SaveFileSystem();
232 232
233 // Callback for handling UI updates caused by document fetching. 233 // Callback for handling UI updates caused by document fetching.
234 void OnNotifyDocumentFeedFetched( 234 void OnNotifyDocumentFeedFetched(
235 base::WeakPtr<GetDocumentsUiState> ui_state); 235 base::WeakPtr<GetDocumentsUiState> ui_state);
236 236
237 DriveResourceMetadata* resource_metadata_; // Not owned. 237 DriveResourceMetadata* resource_metadata_; // Not owned.
238 DriveServiceInterface* drive_service_; // Not owned. 238 DriveServiceInterface* drive_service_; // Not owned.
239 DriveWebAppsRegistryInterface* webapps_registry_; // Not owned. 239 DriveWebAppsRegistryInterface* webapps_registry_; // Not owned.
240 DriveCache* cache_; // Not owned. 240 DriveCache* cache_; // Not owned.
241 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 241 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
242 ObserverList<Observer> observers_; 242 ObserverList<Observer> observers_;
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698