| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> |
| 11 #include <string> | 12 #include <string> |
| 12 | 13 |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 17 #include "chrome/browser/sync_file_system/sync_callbacks.h" | 17 #include "chrome/browser/sync_file_system/sync_callbacks.h" |
| 18 #include "chrome/browser/sync_file_system/sync_service_state.h" | 18 #include "chrome/browser/sync_file_system/sync_service_state.h" |
| 19 | 19 |
| 20 namespace sync_file_system { | 20 namespace sync_file_system { |
| 21 | 21 |
| 22 class SyncFileSystemService; | 22 class SyncFileSystemService; |
| 23 | 23 |
| 24 // A base class to schedule a sync. | 24 // A base class to schedule a sync. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 const base::TimeDelta& delay, | 63 const base::TimeDelta& delay, |
| 64 const base::Closure& closure) = 0; | 64 const base::Closure& closure) = 0; |
| 65 virtual base::TimeTicks Now() const = 0; | 65 virtual base::TimeTicks Now() const = 0; |
| 66 | 66 |
| 67 protected: | 67 protected: |
| 68 TimerHelper() {} | 68 TimerHelper() {} |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 SyncProcessRunner(const std::string& name, | 71 SyncProcessRunner(const std::string& name, |
| 72 Client* client, | 72 Client* client, |
| 73 scoped_ptr<TimerHelper> timer_helper, | 73 std::unique_ptr<TimerHelper> timer_helper, |
| 74 size_t max_parallel_task); | 74 size_t max_parallel_task); |
| 75 virtual ~SyncProcessRunner(); | 75 virtual ~SyncProcessRunner(); |
| 76 | 76 |
| 77 // Subclass must implement this. | 77 // Subclass must implement this. |
| 78 virtual void StartSync(const SyncStatusCallback& callback) = 0; | 78 virtual void StartSync(const SyncStatusCallback& callback) = 0; |
| 79 | 79 |
| 80 // Schedules a new sync. | 80 // Schedules a new sync. |
| 81 void Schedule(); | 81 void Schedule(); |
| 82 | 82 |
| 83 int64_t pending_changes() const { return pending_changes_; } | 83 int64_t pending_changes() const { return pending_changes_; } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 102 // Clears old throttling setting that is already over. | 102 // Clears old throttling setting that is already over. |
| 103 void ResetOldThrottling(); | 103 void ResetOldThrottling(); |
| 104 void ResetThrottling(); | 104 void ResetThrottling(); |
| 105 | 105 |
| 106 void CheckIfIdle(); | 106 void CheckIfIdle(); |
| 107 | 107 |
| 108 std::string name_; | 108 std::string name_; |
| 109 Client* client_; | 109 Client* client_; |
| 110 size_t max_parallel_task_; | 110 size_t max_parallel_task_; |
| 111 size_t running_tasks_; | 111 size_t running_tasks_; |
| 112 scoped_ptr<TimerHelper> timer_helper_; | 112 std::unique_ptr<TimerHelper> timer_helper_; |
| 113 base::TimeTicks last_run_; | 113 base::TimeTicks last_run_; |
| 114 base::TimeTicks last_scheduled_; | 114 base::TimeTicks last_scheduled_; |
| 115 SyncServiceState service_state_; | 115 SyncServiceState service_state_; |
| 116 | 116 |
| 117 base::TimeTicks throttle_from_; | 117 base::TimeTicks throttle_from_; |
| 118 base::TimeTicks throttle_until_; | 118 base::TimeTicks throttle_until_; |
| 119 | 119 |
| 120 int64_t pending_changes_; | 120 int64_t pending_changes_; |
| 121 base::WeakPtrFactory<SyncProcessRunner> factory_; | 121 base::WeakPtrFactory<SyncProcessRunner> factory_; |
| 122 | 122 |
| 123 DISALLOW_COPY_AND_ASSIGN(SyncProcessRunner); | 123 DISALLOW_COPY_AND_ASSIGN(SyncProcessRunner); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 } // namespace sync_file_system | 126 } // namespace sync_file_system |
| 127 | 127 |
| 128 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_PROCESS_RUNNER_H_ | 128 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_PROCESS_RUNNER_H_ |
| OLD | NEW |