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 static const int64 kSyncDelaySlowInMilliseconds; |
| 41 |
| 42 // Default delay when there're no changes. |
| 43 static const int64 kSyncDelayMaxInMilliseconds; |
| 44 |
28 class Client { | 45 class Client { |
29 public: | 46 public: |
30 virtual ~Client() {} | 47 virtual ~Client() {} |
31 virtual void OnSyncIdle() {} | 48 virtual void OnSyncIdle() {} |
32 virtual SyncServiceState GetSyncServiceState() = 0; | 49 virtual SyncServiceState GetSyncServiceState() = 0; |
33 virtual SyncFileSystemService* GetSyncService() = 0; | 50 virtual SyncFileSystemService* GetSyncService() = 0; |
34 }; | 51 }; |
35 | 52 |
36 class TimerHelper { | 53 class TimerHelper { |
37 public: | 54 public: |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 int64 last_delay_; | 100 int64 last_delay_; |
84 int64 pending_changes_; | 101 int64 pending_changes_; |
85 base::WeakPtrFactory<SyncProcessRunner> factory_; | 102 base::WeakPtrFactory<SyncProcessRunner> factory_; |
86 | 103 |
87 DISALLOW_COPY_AND_ASSIGN(SyncProcessRunner); | 104 DISALLOW_COPY_AND_ASSIGN(SyncProcessRunner); |
88 }; | 105 }; |
89 | 106 |
90 } // namespace sync_file_system | 107 } // namespace sync_file_system |
91 | 108 |
92 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_PROCESS_RUNNER_H_ | 109 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_PROCESS_RUNNER_H_ |
OLD | NEW |