Use the shared instance of base::Default{,Tick}Clock in gcm/ and offline_pages/
This CL changes the ownership of base::Clock and base::TickClock from
injectee-owned to injecter-owned. Before this CL, these instances are
owned by the owner of the injectee or one of the injectees themselves.
That makes the ownership handling complex.
After this CL, the injectee of clocks never own the clock. Instead,
injecters owns a clock for testing, and a shared clock is used on the
production code.
Bug: 789079
Change-Id: I98eabd76f378c15bccf637c3d6748c2a2aba417e
Reviewed-on: https://chromium-review.googlesource.com/956167
Commit-Queue: Taiju Tsuiki <[email protected]>
Reviewed-by: Filip Gorski <[email protected]>
Cr-Commit-Position: refs/heads/master@{#544370}diff --git a/components/gcm_driver/gcm_client_impl.h b/components/gcm_driver/gcm_client_impl.h
index 68c9e2e4..84b275b 100644
--- a/components/gcm_driver/gcm_client_impl.h
+++ b/components/gcm_driver/gcm_client_impl.h
@@ -59,7 +59,7 @@
GCMInternalsBuilder();
virtual ~GCMInternalsBuilder();
- virtual std::unique_ptr<base::Clock> BuildClock();
+ virtual base::Clock* GetClock();
virtual std::unique_ptr<MCSClient> BuildMCSClient(
const std::string& version,
base::Clock* clock,
@@ -345,9 +345,8 @@
// Device checkin info (android ID and security token used by device).
CheckinInfo device_checkin_info_;
- // Clock used for timing of retry logic. Passed in for testing. Owned by
- // GCMClientImpl.
- std::unique_ptr<base::Clock> clock_;
+ // Clock used for timing of retry logic. Passed in for testing.
+ base::Clock* clock_;
// Information about the chrome build.
// TODO(fgorski): Check if it can be passed in constructor and made const.