| Index: chrome/browser/chromeos/night_light/night_light_client.h
|
| diff --git a/chrome/browser/chromeos/night_light/night_light_client.h b/chrome/browser/chromeos/night_light/night_light_client.h
|
| index 0f8580dfacd3c9e8766fd7e91f84d96ada9a8697..04823063f66a940efe42339d18f9d4c857e85799 100644
|
| --- a/chrome/browser/chromeos/night_light/night_light_client.h
|
| +++ b/chrome/browser/chromeos/night_light/night_light_client.h
|
| @@ -12,6 +12,11 @@
|
| #include "chromeos/geolocation/simple_geolocation_provider.h"
|
| #include "mojo/public/cpp/bindings/binding.h"
|
|
|
| +namespace base {
|
| +class Clock;
|
| +class TickClock;
|
| +} // namespace base
|
| +
|
| namespace net {
|
| class URLRequestContextGetter;
|
| }
|
| @@ -21,7 +26,10 @@ class URLRequestContextGetter;
|
| class NightLightClient
|
| : public NON_EXPORTED_BASE(ash::mojom::NightLightClient) {
|
| public:
|
| - explicit NightLightClient(net::URLRequestContextGetter* url_context_getter);
|
| + // Pass nullptr for |tick_clock| and |clock| to use the default system clocks.
|
| + NightLightClient(net::URLRequestContextGetter* url_context_getter,
|
| + base::TickClock* tick_clock,
|
| + base::Clock* clock);
|
| ~NightLightClient() override;
|
|
|
| // Starts watching changes in the Night Light schedule type in order to begin
|
| @@ -33,8 +41,16 @@ class NightLightClient
|
| void OnScheduleTypeChanged(
|
| ash::mojom::NightLightController::ScheduleType new_type) override;
|
|
|
| + const base::OneShotTimer& timer() const { return timer_; }
|
| +
|
| + base::Time last_successful_geo_request_time() const {
|
| + return last_successful_geo_request_time_;
|
| + }
|
| +
|
| bool using_geoposition() const { return using_geoposition_; }
|
|
|
| + static base::TimeDelta GetNextRequestDelayAfterSuccessForTesting();
|
| +
|
| void SetNightLightControllerPtrForTesting(
|
| ash::mojom::NightLightControllerPtr controller);
|
|
|
| @@ -46,6 +62,11 @@ class NightLightClient
|
| const base::TimeDelta elapsed);
|
|
|
| private:
|
| + base::Time GetNow() const;
|
| +
|
| + // Sends the most recent valid geoposition to NightLightController in ash.
|
| + void SendCurrentGeoposition();
|
| +
|
| void ScheduleNextRequest(base::TimeDelta delay);
|
|
|
| // Virtual so that it can be overriden by a fake implementation in unit tests
|
| @@ -63,6 +84,14 @@ class NightLightClient
|
|
|
| base::OneShotTimer timer_;
|
|
|
| + // Optional Used in tests to override the time of "Now".
|
| + base::Clock* clock_; // Not owned.
|
| +
|
| + // Last successful geoposition coordinates and its timestamp.
|
| + base::Time last_successful_geo_request_time_;
|
| + double latitude_ = 0.0;
|
| + double longitude_ = 0.0;
|
| +
|
| // True as long as the schedule type is set to "sunset to sunrise", which
|
| // means this client will be retrieving the IP-based geoposition once per day.
|
| bool using_geoposition_ = false;
|
|
|