diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-29 06:09:16 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-29 06:09:16 +0000 |
commit | b20d21dece2caabf04a6036dc120d519de1b1125 (patch) | |
tree | 0aa66ace8bf5a7673671ba290c947f1b11d53804 /chrome/browser/sync_file_system/sync_process_runner.h | |
parent | fb2b1939ae8c86de354ac9e00965a8f71f861b8e (diff) | |
download | chromium_src-b20d21dece2caabf04a6036dc120d519de1b1125.zip chromium_src-b20d21dece2caabf04a6036dc120d519de1b1125.tar.gz chromium_src-b20d21dece2caabf04a6036dc120d519de1b1125.tar.bz2 |
Prepare for using two backends in SyncFileSystemService, part 4
As a preparation for using multiple RemoteFileSyncService.
- Moved SyncFileSystemService::SyncRunner implementation into its own file, sync_process_runner.* and renamed to SyncProcessRunner
- Added LocalSyncRunner and RemoteSyncRunner class, both extend SyncProcessRunner
- Let LocalSyncRunner implement LocalFileSyncService::Observer
- Let RemoteSyncRunner implement RemoteFileSyncService::Observer
The plan is: we're going to have two RemoteFileSyncService and RemoteSyncRunner
for v1 and v2.
No functional changes yet.
BUG=324215
TEST=manual (tested some remote and local sync)
Review URL: https://codereview.chromium.org/95023003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237886 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync_file_system/sync_process_runner.h')
-rw-r--r-- | chrome/browser/sync_file_system/sync_process_runner.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/chrome/browser/sync_file_system/sync_process_runner.h b/chrome/browser/sync_file_system/sync_process_runner.h new file mode 100644 index 0000000..792f311 --- /dev/null +++ b/chrome/browser/sync_file_system/sync_process_runner.h @@ -0,0 +1,59 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_PROCESS_RUNNER_H_ +#define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_PROCESS_RUNNER_H_ + +#include "base/basictypes.h" +#include "base/memory/weak_ptr.h" +#include "base/timer/timer.h" +#include "chrome/browser/sync_file_system/sync_callbacks.h" + +namespace sync_file_system { + +class SyncFileSystemService; + +// A base class to schedule a sync. +// Each subclass must implement StartSync(). +// An instance of this class is supposed to be owned by SyncFileSystemService. +// +// Note that multiple SyncProcessRunner doesn't coordinate its sync schedule +// with each other. +class SyncProcessRunner { + public: + typedef base::Callback<void(const SyncStatusCallback&)> Task; + SyncProcessRunner(const std::string& name, + SyncFileSystemService* sync_service); + virtual ~SyncProcessRunner(); + + virtual void StartSync(const SyncStatusCallback& callback) = 0; + + void Schedule(); + void ScheduleIfNotRunning(); + void OnChangesUpdated(int64 pending_changes); + + protected: + SyncFileSystemService* sync_service() { return sync_service_; } + + private: + void Finished(SyncStatusCode status); + void Run(); + void ScheduleInternal(int64 delay); + + std::string name_; + SyncFileSystemService* sync_service_; + base::OneShotTimer<SyncProcessRunner> timer_; + base::Time last_scheduled_; + int64 current_delay_; + int64 last_delay_; + int64 pending_changes_; + bool running_; + base::WeakPtrFactory<SyncProcessRunner> factory_; + + DISALLOW_COPY_AND_ASSIGN(SyncProcessRunner); +}; + +} // namespace sync_file_system + +#endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_PROCESS_RUNNER_H_ |