Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef CHROME_BROWSER_CHROMEOS_NIGHT_LIGHT_NIGHT_LIGHT_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NIGHT_LIGHT_NIGHT_LIGHT_CLIENT_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_NIGHT_LIGHT_NIGHT_LIGHT_CLIENT_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NIGHT_LIGHT_NIGHT_LIGHT_CLIENT_H_ |
| 7 | 7 |
| 8 #include "ash/public/interfaces/night_light_controller.mojom.h" | 8 #include "ash/public/interfaces/night_light_controller.mojom.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 ash::mojom::NightLightControllerPtr controller); | 39 ash::mojom::NightLightControllerPtr controller); |
| 40 | 40 |
| 41 void FlushNightLightControllerForTesting(); | 41 void FlushNightLightControllerForTesting(); |
| 42 | 42 |
| 43 protected: | 43 protected: |
| 44 void OnGeoposition(const chromeos::Geoposition& position, | 44 void OnGeoposition(const chromeos::Geoposition& position, |
| 45 bool server_error, | 45 bool server_error, |
| 46 const base::TimeDelta elapsed); | 46 const base::TimeDelta elapsed); |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 void SendCurrentGeoposition(); | |
|
James Cook
2017/06/30 19:12:26
nit: docs (send to who?)
afakhry
2017/06/30 22:28:28
Done.
| |
| 50 | |
| 49 void ScheduleNextRequest(base::TimeDelta delay); | 51 void ScheduleNextRequest(base::TimeDelta delay); |
| 50 | 52 |
| 51 // Virtual so that it can be overriden by a fake implementation in unit tests | 53 // Virtual so that it can be overriden by a fake implementation in unit tests |
| 52 // that doesn't request actual geopositions. | 54 // that doesn't request actual geopositions. |
| 53 virtual void RequestGeoposition(); | 55 virtual void RequestGeoposition(); |
| 54 | 56 |
| 55 // The IP-based geolocation provider. | 57 // The IP-based geolocation provider. |
| 56 chromeos::SimpleGeolocationProvider provider_; | 58 chromeos::SimpleGeolocationProvider provider_; |
| 57 | 59 |
| 58 ash::mojom::NightLightControllerPtr night_light_controller_; | 60 ash::mojom::NightLightControllerPtr night_light_controller_; |
| 59 mojo::Binding<ash::mojom::NightLightClient> binding_; | 61 mojo::Binding<ash::mojom::NightLightClient> binding_; |
| 60 | 62 |
| 61 // Delay after which a new request is retried after a failed one. | 63 // Delay after which a new request is retried after a failed one. |
| 62 base::TimeDelta backoff_delay_; | 64 base::TimeDelta backoff_delay_; |
| 63 | 65 |
| 64 base::OneShotTimer timer_; | 66 base::OneShotTimer timer_; |
| 65 | 67 |
| 68 // Last successful geoposition coordinates and its timestamp. | |
| 69 base::Time last_successful_request_; | |
|
James Cook
2017/06/30 19:12:26
optional: maybe |last_successful_geo_request_|?
afakhry
2017/06/30 22:28:28
Done. Actually named it |last_successful_geo_reque
| |
| 70 double latitude_ = 0.0; | |
| 71 double longitude_ = 0.0; | |
| 72 | |
| 66 // True as long as the schedule type is set to "sunset to sunrise", which | 73 // True as long as the schedule type is set to "sunset to sunrise", which |
| 67 // means this client will be retrieving the IP-based geoposition once per day. | 74 // means this client will be retrieving the IP-based geoposition once per day. |
| 68 bool using_geoposition_ = false; | 75 bool using_geoposition_ = false; |
| 69 | 76 |
| 70 DISALLOW_COPY_AND_ASSIGN(NightLightClient); | 77 DISALLOW_COPY_AND_ASSIGN(NightLightClient); |
| 71 }; | 78 }; |
| 72 | 79 |
| 73 #endif // CHROME_BROWSER_CHROMEOS_NIGHT_LIGHT_NIGHT_LIGHT_CLIENT_H_ | 80 #endif // CHROME_BROWSER_CHROMEOS_NIGHT_LIGHT_NIGHT_LIGHT_CLIENT_H_ |
| OLD | NEW |