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

Side by Side Diff: chrome/browser/sync_file_system/drive_file_sync_service.h

Issue 11421125: Implement polling part of DriveFileSyncService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/NotifyRemoteChangeAvailable/NotifyRemoteChangeQueueUpdated/ Created 8 years 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_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_ 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback_forward.h" 14 #include "base/callback_forward.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h" 17 #include "base/observer_list.h"
18 #include "base/threading/non_thread_safe.h" 18 #include "base/threading/non_thread_safe.h"
19 #include "base/timer.h"
19 #include "chrome/browser/google_apis/drive_service_interface.h" 20 #include "chrome/browser/google_apis/drive_service_interface.h"
20 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 21 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
21 #include "chrome/browser/sync_file_system/local_change_processor.h" 22 #include "chrome/browser/sync_file_system/local_change_processor.h"
22 #include "chrome/browser/sync_file_system/remote_file_sync_service.h" 23 #include "chrome/browser/sync_file_system/remote_file_sync_service.h"
23 #include "webkit/fileapi/syncable/file_change.h" 24 #include "webkit/fileapi/syncable/file_change.h"
24 #include "webkit/fileapi/syncable/sync_callbacks.h" 25 #include "webkit/fileapi/syncable/sync_callbacks.h"
25 #include "webkit/fileapi/syncable/sync_operation_type.h" 26 #include "webkit/fileapi/syncable/sync_operation_type.h"
26 27
27 namespace google_apis { 28 namespace google_apis {
28 class DocumentFeed; 29 class DocumentFeed;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 scoped_ptr<ProcessRemoteChangeParam> param, 272 scoped_ptr<ProcessRemoteChangeParam> param,
272 fileapi::SyncStatusCode status); 273 fileapi::SyncStatusCode status);
273 void AbortRemoteSync( 274 void AbortRemoteSync(
274 scoped_ptr<ProcessRemoteChangeParam> param, 275 scoped_ptr<ProcessRemoteChangeParam> param,
275 fileapi::SyncStatusCode status); 276 fileapi::SyncStatusCode status);
276 void FinalizeRemoteSync( 277 void FinalizeRemoteSync(
277 scoped_ptr<ProcessRemoteChangeParam> param, 278 scoped_ptr<ProcessRemoteChangeParam> param,
278 fileapi::SyncStatusCode status); 279 fileapi::SyncStatusCode status);
279 280
280 void AppendNewRemoteChange(const GURL& origin, 281 void AppendNewRemoteChange(const GURL& origin,
281 google_apis::DocumentEntry* entry, 282 const google_apis::DocumentEntry& entry,
282 int64 changestamp, 283 int64 changestamp,
283 RemoteSyncType sync_type); 284 RemoteSyncType sync_type);
284 void CancelRemoteChange(const fileapi::FileSystemURL& url); 285 void RemoveRemoteChange(const fileapi::FileSystemURL& url);
285 void MaybeMarkAsIncrementalSyncOrigin(const GURL& origin); 286 void MaybeMarkAsIncrementalSyncOrigin(const GURL& origin);
286 287
287 // This returns false if no change is found for the |url|. 288 // This returns false if no change is found for the |url|.
288 bool GetPendingChangeForFileSystemURL(const fileapi::FileSystemURL& url, 289 bool GetPendingChangeForFileSystemURL(const fileapi::FileSystemURL& url,
289 RemoteChange* change) const; 290 RemoteChange* change) const;
290 291
291 // A wrapper implementation to GDataErrorCodeToSyncStatusCode which returns 292 // A wrapper implementation to GDataErrorCodeToSyncStatusCode which returns
292 // authentication error if the user is not signed in. 293 // authentication error if the user is not signed in.
293 fileapi::SyncStatusCode GDataErrorCodeToSyncStatusCodeWrapper( 294 fileapi::SyncStatusCode GDataErrorCodeToSyncStatusCodeWrapper(
294 google_apis::GDataErrorCode error) const; 295 google_apis::GDataErrorCode error) const;
295 296
296 FilePath temporary_file_dir_; 297 FilePath temporary_file_dir_;
297 298
299 void FetchChangesForIncrementalSync();
300 void DidFetchChangesForIncrementalSync(
301 scoped_ptr<TaskToken> token,
302 google_apis::GDataErrorCode error,
303 scoped_ptr<google_apis::DocumentFeed> changes);
304 bool GetOriginForEntry(const google_apis::DocumentEntry& entry, GURL* origin);
305 void SchedulePolling();
306
298 scoped_ptr<DriveMetadataStore> metadata_store_; 307 scoped_ptr<DriveMetadataStore> metadata_store_;
299 scoped_ptr<DriveFileSyncClient> sync_client_; 308 scoped_ptr<DriveFileSyncClient> sync_client_;
300 309
301 fileapi::SyncStatusCode last_operation_status_; 310 fileapi::SyncStatusCode last_operation_status_;
302 RemoteServiceState state_; 311 RemoteServiceState state_;
303 std::deque<base::Closure> pending_tasks_; 312 std::deque<base::Closure> pending_tasks_;
304 313
305 int64 largest_changestamp_; 314 int64 largest_fetched_changestamp_;
315
306 PendingChangeQueue pending_changes_; 316 PendingChangeQueue pending_changes_;
307 URLToChange url_to_change_; 317 URLToChange url_to_change_;
308 318
309 std::set<GURL> pending_batch_sync_origins_; 319 std::set<GURL> pending_batch_sync_origins_;
310 320
311 // Absence of |token_| implies a task is running. Incoming tasks should 321 // Absence of |token_| implies a task is running. Incoming tasks should
312 // wait for the task to finish in |pending_tasks_| if |token_| is null. 322 // wait for the task to finish in |pending_tasks_| if |token_| is null.
313 // Each task must take TaskToken instance from |token_| and must hold it 323 // Each task must take TaskToken instance from |token_| and must hold it
314 // until it finished. And the task must return the instance through 324 // until it finished. And the task must return the instance through
315 // NotifyTaskDone when the task finished. 325 // NotifyTaskDone when the task finished.
316 scoped_ptr<TaskToken> token_; 326 scoped_ptr<TaskToken> token_;
317 327
328 base::OneShotTimer<DriveFileSyncService> polling_timer_;
329 int64 polling_delay_seconds_;
330 bool polling_enabled_;
331
318 ObserverList<Observer> observers_; 332 ObserverList<Observer> observers_;
319 333
320 // Use WeakPtrFactory instead of SupportsWeakPtr to revoke the weak pointer 334 // Use WeakPtrFactory instead of SupportsWeakPtr to revoke the weak pointer
321 // in |token_|. 335 // in |token_|.
322 base::WeakPtrFactory<DriveFileSyncService> weak_factory_; 336 base::WeakPtrFactory<DriveFileSyncService> weak_factory_;
323 337
324 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncService); 338 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncService);
325 }; 339 };
326 340
327 } // namespace sync_file_system 341 } // namespace sync_file_system
328 342
329 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_ 343 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698