| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_CHECK_SCHEDULER_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_CHECK_SCHEDULER_H__ |
| 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_CHECK_SCHEDULER_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_CHECK_SCHEDULER_H__ |
| 7 | 7 |
| 8 #include <base/basictypes.h> | 8 #include <base/basictypes.h> |
| 9 #include <glib.h> | 9 #include <glib.h> |
| 10 #include <gtest/gtest_prod.h> // for FRIEND_TEST | 10 #include <gtest/gtest_prod.h> // for FRIEND_TEST |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 friend class UpdateCheckSchedulerTest; | 55 friend class UpdateCheckSchedulerTest; |
| 56 FRIEND_TEST(UpdateCheckSchedulerTest, CanScheduleTest); | 56 FRIEND_TEST(UpdateCheckSchedulerTest, CanScheduleTest); |
| 57 FRIEND_TEST(UpdateCheckSchedulerTest, ComputeNextIntervalAndFuzzBackoffTest); | 57 FRIEND_TEST(UpdateCheckSchedulerTest, ComputeNextIntervalAndFuzzBackoffTest); |
| 58 FRIEND_TEST(UpdateCheckSchedulerTest, ComputeNextIntervalAndFuzzPollTest); | 58 FRIEND_TEST(UpdateCheckSchedulerTest, ComputeNextIntervalAndFuzzPollTest); |
| 59 FRIEND_TEST(UpdateCheckSchedulerTest, ComputeNextIntervalAndFuzzPriorityTest); | 59 FRIEND_TEST(UpdateCheckSchedulerTest, ComputeNextIntervalAndFuzzPriorityTest); |
| 60 FRIEND_TEST(UpdateCheckSchedulerTest, ComputeNextIntervalAndFuzzTest); | 60 FRIEND_TEST(UpdateCheckSchedulerTest, ComputeNextIntervalAndFuzzTest); |
| 61 FRIEND_TEST(UpdateCheckSchedulerTest, GTimeoutAddSecondsTest); | 61 FRIEND_TEST(UpdateCheckSchedulerTest, GTimeoutAddSecondsTest); |
| 62 FRIEND_TEST(UpdateCheckSchedulerTest, IsBootDeviceRemovableTest); | 62 FRIEND_TEST(UpdateCheckSchedulerTest, IsBootDeviceRemovableTest); |
| 63 FRIEND_TEST(UpdateCheckSchedulerTest, IsOOBECompleteTest); |
| 63 FRIEND_TEST(UpdateCheckSchedulerTest, IsOfficialBuildTest); | 64 FRIEND_TEST(UpdateCheckSchedulerTest, IsOfficialBuildTest); |
| 64 FRIEND_TEST(UpdateCheckSchedulerTest, RunBootDeviceRemovableTest); | 65 FRIEND_TEST(UpdateCheckSchedulerTest, RunBootDeviceRemovableTest); |
| 65 FRIEND_TEST(UpdateCheckSchedulerTest, RunNonOfficialBuildTest); | 66 FRIEND_TEST(UpdateCheckSchedulerTest, RunNonOfficialBuildTest); |
| 66 FRIEND_TEST(UpdateCheckSchedulerTest, RunTest); | 67 FRIEND_TEST(UpdateCheckSchedulerTest, RunTest); |
| 67 FRIEND_TEST(UpdateCheckSchedulerTest, ScheduleCheckDisabledTest); | 68 FRIEND_TEST(UpdateCheckSchedulerTest, ScheduleCheckDisabledTest); |
| 68 FRIEND_TEST(UpdateCheckSchedulerTest, ScheduleCheckEnabledTest); | 69 FRIEND_TEST(UpdateCheckSchedulerTest, ScheduleCheckEnabledTest); |
| 69 FRIEND_TEST(UpdateCheckSchedulerTest, ScheduleCheckNegativeIntervalTest); | 70 FRIEND_TEST(UpdateCheckSchedulerTest, ScheduleCheckNegativeIntervalTest); |
| 70 FRIEND_TEST(UpdateCheckSchedulerTest, ScheduleNextCheckDisabledTest); | 71 FRIEND_TEST(UpdateCheckSchedulerTest, ScheduleNextCheckDisabledTest); |
| 71 FRIEND_TEST(UpdateCheckSchedulerTest, ScheduleNextCheckEnabledTest); | 72 FRIEND_TEST(UpdateCheckSchedulerTest, ScheduleNextCheckEnabledTest); |
| 72 FRIEND_TEST(UpdateCheckSchedulerTest, SetUpdateStatusIdleDisabledTest); | 73 FRIEND_TEST(UpdateCheckSchedulerTest, SetUpdateStatusIdleDisabledTest); |
| 73 FRIEND_TEST(UpdateCheckSchedulerTest, SetUpdateStatusIdleEnabledTest); | 74 FRIEND_TEST(UpdateCheckSchedulerTest, SetUpdateStatusIdleEnabledTest); |
| 74 FRIEND_TEST(UpdateCheckSchedulerTest, SetUpdateStatusNonIdleTest); | 75 FRIEND_TEST(UpdateCheckSchedulerTest, SetUpdateStatusNonIdleTest); |
| 75 FRIEND_TEST(UpdateCheckSchedulerTest, StaticCheckTest); | 76 FRIEND_TEST(UpdateCheckSchedulerTest, StaticCheckOOBECompleteTest); |
| 77 FRIEND_TEST(UpdateCheckSchedulerTest, StaticCheckOOBENotCompleteTest); |
| 76 | 78 |
| 77 // Wraps GLib's g_timeout_add_seconds so that it can be mocked in tests. | 79 // Wraps GLib's g_timeout_add_seconds so that it can be mocked in tests. |
| 78 virtual guint GTimeoutAddSeconds(guint interval, GSourceFunc function); | 80 virtual guint GTimeoutAddSeconds(guint interval, GSourceFunc function); |
| 79 | 81 |
| 80 // Wrappers for utils functions so that they can be mocked in tests. | 82 // Wrappers for utils functions so that they can be mocked in tests. |
| 81 virtual bool IsBootDeviceRemovable(); | 83 virtual bool IsBootDeviceRemovable(); |
| 84 virtual bool IsOOBEComplete(); |
| 82 virtual bool IsOfficialBuild(); | 85 virtual bool IsOfficialBuild(); |
| 83 | 86 |
| 84 // Returns true if an update check can be scheduled. An update check should | 87 // Returns true if an update check can be scheduled. An update check should |
| 85 // not be scheduled if periodic update checks are disabled or if one is | 88 // not be scheduled if periodic update checks are disabled or if one is |
| 86 // already scheduled. | 89 // already scheduled. |
| 87 bool CanSchedule() { return enabled_ && !scheduled_; } | 90 bool CanSchedule() { return enabled_ && !scheduled_; } |
| 88 | 91 |
| 89 // Schedules the next periodic update check |interval| seconds from now | 92 // Schedules the next periodic update check |interval| seconds from now |
| 90 // randomized by +/- |fuzz|/2. | 93 // randomized by +/- |fuzz|/2. |
| 91 void ScheduleCheck(int interval, int fuzz); | 94 void ScheduleCheck(int interval, int fuzz); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 116 | 119 |
| 117 // Server dictated poll interval in seconds, if positive. | 120 // Server dictated poll interval in seconds, if positive. |
| 118 int poll_interval_; | 121 int poll_interval_; |
| 119 | 122 |
| 120 DISALLOW_COPY_AND_ASSIGN(UpdateCheckScheduler); | 123 DISALLOW_COPY_AND_ASSIGN(UpdateCheckScheduler); |
| 121 }; | 124 }; |
| 122 | 125 |
| 123 } // namespace chromeos_update_engine | 126 } // namespace chromeos_update_engine |
| 124 | 127 |
| 125 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_CHECK_SCHEDULER_H__ | 128 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_CHECK_SCHEDULER_H__ |
| OLD | NEW |