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

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: fix for optional changestamp field 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 scoped_ptr<ProcessRemoteChangeParam> param, 271 scoped_ptr<ProcessRemoteChangeParam> param,
271 fileapi::SyncStatusCode status); 272 fileapi::SyncStatusCode status);
272 void AbortRemoteSync( 273 void AbortRemoteSync(
273 scoped_ptr<ProcessRemoteChangeParam> param, 274 scoped_ptr<ProcessRemoteChangeParam> param,
274 fileapi::SyncStatusCode status); 275 fileapi::SyncStatusCode status);
275 void FinalizeRemoteSync( 276 void FinalizeRemoteSync(
276 scoped_ptr<ProcessRemoteChangeParam> param, 277 scoped_ptr<ProcessRemoteChangeParam> param,
277 fileapi::SyncStatusCode status); 278 fileapi::SyncStatusCode status);
278 279
279 void AppendNewRemoteChange(const GURL& origin, 280 void AppendNewRemoteChange(const GURL& origin,
280 google_apis::DocumentEntry* entry, 281 const google_apis::DocumentEntry& entry,
281 int64 changestamp, 282 int64 changestamp,
282 RemoteSyncType sync_type); 283 RemoteSyncType sync_type);
283 void CancelRemoteChange(const fileapi::FileSystemURL& url); 284 void CancelRemoteChange(const fileapi::FileSystemURL& url);
284 void MaybeMarkAsIncrementalSyncOrigin(const GURL& origin); 285 void MaybeMarkAsIncrementalSyncOrigin(const GURL& origin);
285 286
286 // This returns false if no change is found for the |url|. 287 // This returns false if no change is found for the |url|.
287 bool GetPendingChangeForFileSystemURL(const fileapi::FileSystemURL& url, 288 bool GetPendingChangeForFileSystemURL(const fileapi::FileSystemURL& url,
288 RemoteChange* change) const; 289 RemoteChange* change) const;
289 290
290 FilePath temporary_file_dir_; 291 FilePath temporary_file_dir_;
291 292
293 void FetchChangesForIncrementalSync();
294 void DidFetchChangesForIncrementalSync(
295 scoped_ptr<TaskToken> token,
296 google_apis::GDataErrorCode error,
297 scoped_ptr<google_apis::DocumentFeed> changes);
298 bool GetOriginForEntry(const google_apis::DocumentEntry& entry, GURL* origin);
299 void SchedulePolling();
300
292 scoped_ptr<DriveMetadataStore> metadata_store_; 301 scoped_ptr<DriveMetadataStore> metadata_store_;
293 scoped_ptr<DriveFileSyncClient> sync_client_; 302 scoped_ptr<DriveFileSyncClient> sync_client_;
294 303
295 fileapi::SyncStatusCode last_operation_status_; 304 fileapi::SyncStatusCode last_operation_status_;
296 RemoteServiceState state_; 305 RemoteServiceState state_;
297 std::deque<base::Closure> pending_tasks_; 306 std::deque<base::Closure> pending_tasks_;
298 307
299 int64 largest_changestamp_; 308 int64 largest_synced_changestamp_;
309 int64 largest_fetched_changestamp_;
310
300 PendingChangeQueue pending_changes_; 311 PendingChangeQueue pending_changes_;
301 URLToChange url_to_change_; 312 URLToChange url_to_change_;
302 313
303 std::set<GURL> pending_batch_sync_origins_; 314 std::set<GURL> pending_batch_sync_origins_;
304 315
305 // Absence of |token_| implies a task is running. Incoming tasks should 316 // Absence of |token_| implies a task is running. Incoming tasks should
306 // wait for the task to finish in |pending_tasks_| if |token_| is null. 317 // wait for the task to finish in |pending_tasks_| if |token_| is null.
307 // Each task must take TaskToken instance from |token_| and must hold it 318 // Each task must take TaskToken instance from |token_| and must hold it
308 // until it finished. And the task must return the instance through 319 // until it finished. And the task must return the instance through
309 // NotifyTaskDone when the task finished. 320 // NotifyTaskDone when the task finished.
310 scoped_ptr<TaskToken> token_; 321 scoped_ptr<TaskToken> token_;
311 322
323 base::OneShotTimer<DriveFileSyncService> polling_timer_;
324 base::TimeDelta polling_delay_;
325
312 ObserverList<Observer> observers_; 326 ObserverList<Observer> observers_;
313 327
314 // Use WeakPtrFactory instead of SupportsWeakPtr to revoke the weak pointer 328 // Use WeakPtrFactory instead of SupportsWeakPtr to revoke the weak pointer
315 // in |token_|. 329 // in |token_|.
316 base::WeakPtrFactory<DriveFileSyncService> weak_factory_; 330 base::WeakPtrFactory<DriveFileSyncService> weak_factory_;
317 331
318 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncService); 332 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncService);
319 }; 333 };
320 334
321 } // namespace sync_file_system 335 } // namespace sync_file_system
322 336
323 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_ 337 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698