offline_clock.h 930 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (c) 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_CLOCK_H_
  5. #define COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_CLOCK_H_
  6. namespace base {
  7. class Clock;
  8. class Time;
  9. }
  10. namespace offline_pages {
  11. // Returns the clock to be used for obtaining the current time. This function
  12. // can be called from any threads.
  13. const base::Clock* OfflineClock();
  14. // Allows tests to override the clock returned by |OfflineClock()|. For safety,
  15. // use |TestScopedOfflineClock| instead if possible.
  16. void SetOfflineClockForTesting(const base::Clock* clock);
  17. // Returns the current time given by |OfflineClock|. This used as a shortcut
  18. // for calls to |OfflineClock()->Now()|
  19. base::Time OfflineTimeNow();
  20. } // namespace offline_pages
  21. #endif // COMPONENTS_OFFLINE_PAGES_CORE_OFFLINE_CLOCK_H_