| 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> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <queue> | 10 #include <queue> |
| 8 | 11 |
| 12 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 15 |
| 12 namespace sync_file_system { | 16 namespace sync_file_system { |
| 13 | 17 |
| 14 namespace { | 18 namespace { |
| 15 | 19 |
| 16 class FakeClient : public SyncProcessRunner::Client { | 20 class FakeClient : public SyncProcessRunner::Client { |
| 17 public: | 21 public: |
| 18 FakeClient() : service_state_(SYNC_SERVICE_RUNNING) {} | 22 FakeClient() : service_state_(SYNC_SERVICE_RUNNING) {} |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 59 |
| 56 base::Closure task = timer_task_; | 60 base::Closure task = timer_task_; |
| 57 timer_task_.Reset(); | 61 timer_task_.Reset(); |
| 58 task.Run(); | 62 task.Run(); |
| 59 } | 63 } |
| 60 | 64 |
| 61 void AdvanceToScheduledTime() { | 65 void AdvanceToScheduledTime() { |
| 62 SetCurrentTime(scheduled_time_); | 66 SetCurrentTime(scheduled_time_); |
| 63 } | 67 } |
| 64 | 68 |
| 65 int64 GetCurrentDelay() { | 69 int64_t GetCurrentDelay() { |
| 66 EXPECT_FALSE(timer_task_.is_null()); | 70 EXPECT_FALSE(timer_task_.is_null()); |
| 67 return (scheduled_time_ - current_time_).InMilliseconds(); | 71 return (scheduled_time_ - current_time_).InMilliseconds(); |
| 68 } | 72 } |
| 69 | 73 |
| 70 private: | 74 private: |
| 71 base::TimeTicks current_time_; | 75 base::TimeTicks current_time_; |
| 72 base::TimeTicks scheduled_time_; | 76 base::TimeTicks scheduled_time_; |
| 73 base::Closure timer_task_; | 77 base::Closure timer_task_; |
| 74 | 78 |
| 75 DISALLOW_COPY_AND_ASSIGN(FakeTimerHelper); | 79 DISALLOW_COPY_AND_ASSIGN(FakeTimerHelper); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 263 |
| 260 // Then, following failing task should not extend throttling period. | 264 // Then, following failing task should not extend throttling period. |
| 261 fake_timer->AdvanceToScheduledTime(); | 265 fake_timer->AdvanceToScheduledTime(); |
| 262 fake_client.set_service_state(SYNC_SERVICE_TEMPORARY_UNAVAILABLE); | 266 fake_client.set_service_state(SYNC_SERVICE_TEMPORARY_UNAVAILABLE); |
| 263 fake_runner.CompleteTask(SYNC_STATUS_FAILED); | 267 fake_runner.CompleteTask(SYNC_STATUS_FAILED); |
| 264 EXPECT_EQ(SyncProcessRunner::kSyncDelaySlowInMilliseconds, | 268 EXPECT_EQ(SyncProcessRunner::kSyncDelaySlowInMilliseconds, |
| 265 fake_timer->GetCurrentDelay()); | 269 fake_timer->GetCurrentDelay()); |
| 266 } | 270 } |
| 267 | 271 |
| 268 } // namespace sync_file_system | 272 } // namespace sync_file_system |
| OLD | NEW |