| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SYNC_PROCESS_RUNNER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_PROCESS_RUNNER_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_PROCESS_RUNNER_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_PROCESS_RUNNER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "chrome/browser/sync_file_system/sync_callbacks.h" | 13 #include "chrome/browser/sync_file_system/sync_callbacks.h" |
| 14 #include "chrome/browser/sync_file_system/sync_service_state.h" | 14 #include "chrome/browser/sync_file_system/sync_service_state.h" |
| 15 | 15 |
| 16 namespace sync_file_system { | 16 namespace sync_file_system { |
| 17 | 17 |
| 18 class SyncFileSystemService; | 18 class SyncFileSystemService; |
| 19 | 19 |
| 20 // A base class to schedule a sync. | 20 // A base class to schedule a sync. |
| 21 // Each subclass must implement StartSync(). | 21 // Each subclass must implement StartSync(). |
| 22 // An instance of this class is supposed to be owned by SyncFileSystemService. | 22 // An instance of this class is supposed to be owned by SyncFileSystemService. |
| 23 // | 23 // |
| 24 // Note that multiple SyncProcessRunner doesn't coordinate its sync schedule | 24 // Note that multiple SyncProcessRunner doesn't coordinate its sync schedule |
| 25 // with each other. | 25 // with each other. |
| 26 class SyncProcessRunner { | 26 class SyncProcessRunner { |
| 27 public: | 27 public: |
| 28 // Default delay when more changes are available. |
| 29 static const int64 kSyncDelayInMilliseconds; |
| 30 |
| 31 // Default delay when the previous change has had an error (but remote service |
| 32 // is running). |
| 33 static const int64 kSyncDelayWithSyncError; |
| 34 |
| 35 // Default delay when there're more than 10 pending changes. |
| 36 static const int64 kSyncDelayFastInMilliseconds; |
| 37 static const int kPendingChangeThresholdForFastSync; |
| 38 |
| 39 // Default delay when remote service is temporarily unavailable. |
| 40 // The delay backs off exponentially from initial value on repeated failure. |
| 41 static const int64 kSyncDelaySlowInMilliseconds; |
| 42 |
| 43 // Default delay when there're no changes. |
| 44 static const int64 kSyncDelayMaxInMilliseconds; |
| 45 |
| 28 class Client { | 46 class Client { |
| 29 public: | 47 public: |
| 30 virtual ~Client() {} | 48 virtual ~Client() {} |
| 31 virtual void OnSyncIdle() {} | 49 virtual void OnSyncIdle() {} |
| 32 virtual SyncServiceState GetSyncServiceState() = 0; | 50 virtual SyncServiceState GetSyncServiceState() = 0; |
| 33 virtual SyncFileSystemService* GetSyncService() = 0; | 51 virtual SyncFileSystemService* GetSyncService() = 0; |
| 34 }; | 52 }; |
| 35 | 53 |
| 36 class TimerHelper { | 54 class TimerHelper { |
| 37 public: | 55 public: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 int64 last_delay_; | 101 int64 last_delay_; |
| 84 int64 pending_changes_; | 102 int64 pending_changes_; |
| 85 base::WeakPtrFactory<SyncProcessRunner> factory_; | 103 base::WeakPtrFactory<SyncProcessRunner> factory_; |
| 86 | 104 |
| 87 DISALLOW_COPY_AND_ASSIGN(SyncProcessRunner); | 105 DISALLOW_COPY_AND_ASSIGN(SyncProcessRunner); |
| 88 }; | 106 }; |
| 89 | 107 |
| 90 } // namespace sync_file_system | 108 } // namespace sync_file_system |
| 91 | 109 |
| 92 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_PROCESS_RUNNER_H_ | 110 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_PROCESS_RUNNER_H_ |
| OLD | NEW |