OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/sync_file_system/sync_process_runner.h" | 5 #include "chrome/browser/sync_file_system/sync_process_runner.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | |
10 #include <queue> | 9 #include <queue> |
| 10 #include <utility> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace sync_file_system { | 16 namespace sync_file_system { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 class FakeClient : public SyncProcessRunner::Client { | 20 class FakeClient : public SyncProcessRunner::Client { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 DISALLOW_COPY_AND_ASSIGN(FakeTimerHelper); | 79 DISALLOW_COPY_AND_ASSIGN(FakeTimerHelper); |
80 }; | 80 }; |
81 | 81 |
82 class FakeSyncProcessRunner : public SyncProcessRunner { | 82 class FakeSyncProcessRunner : public SyncProcessRunner { |
83 public: | 83 public: |
84 FakeSyncProcessRunner(SyncProcessRunner::Client* client, | 84 FakeSyncProcessRunner(SyncProcessRunner::Client* client, |
85 scoped_ptr<TimerHelper> timer_helper, | 85 scoped_ptr<TimerHelper> timer_helper, |
86 size_t max_parallel_task) | 86 size_t max_parallel_task) |
87 : SyncProcessRunner("FakeSyncProcess", | 87 : SyncProcessRunner("FakeSyncProcess", |
88 client, timer_helper.Pass(), | 88 client, |
| 89 std::move(timer_helper), |
89 max_parallel_task), | 90 max_parallel_task), |
90 max_parallel_task_(max_parallel_task) { | 91 max_parallel_task_(max_parallel_task) {} |
91 } | |
92 | 92 |
93 void StartSync(const SyncStatusCallback& callback) override { | 93 void StartSync(const SyncStatusCallback& callback) override { |
94 EXPECT_LT(running_tasks_.size(), max_parallel_task_); | 94 EXPECT_LT(running_tasks_.size(), max_parallel_task_); |
95 running_tasks_.push(callback); | 95 running_tasks_.push(callback); |
96 } | 96 } |
97 | 97 |
98 ~FakeSyncProcessRunner() override {} | 98 ~FakeSyncProcessRunner() override {} |
99 | 99 |
100 void UpdateChanges(int num_changes) { | 100 void UpdateChanges(int num_changes) { |
101 OnChangesUpdated(num_changes); | 101 OnChangesUpdated(num_changes); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 263 |
264 // Then, following failing task should not extend throttling period. | 264 // Then, following failing task should not extend throttling period. |
265 fake_timer->AdvanceToScheduledTime(); | 265 fake_timer->AdvanceToScheduledTime(); |
266 fake_client.set_service_state(SYNC_SERVICE_TEMPORARY_UNAVAILABLE); | 266 fake_client.set_service_state(SYNC_SERVICE_TEMPORARY_UNAVAILABLE); |
267 fake_runner.CompleteTask(SYNC_STATUS_FAILED); | 267 fake_runner.CompleteTask(SYNC_STATUS_FAILED); |
268 EXPECT_EQ(SyncProcessRunner::kSyncDelaySlowInMilliseconds, | 268 EXPECT_EQ(SyncProcessRunner::kSyncDelaySlowInMilliseconds, |
269 fake_timer->GetCurrentDelay()); | 269 fake_timer->GetCurrentDelay()); |
270 } | 270 } |
271 | 271 |
272 } // namespace sync_file_system | 272 } // namespace sync_file_system |
OLD | NEW |