| Index: components/ntp_snippets/ntp_snippets_fetcher.h
|
| diff --git a/components/ntp_snippets/ntp_snippets_fetcher.h b/components/ntp_snippets/ntp_snippets_fetcher.h
|
| index 9526da9444c934a0fe5ff85a88585a4afdd0ab01..b7e98e9e8da8a57df87571f23b3154426daa1e74 100644
|
| --- a/components/ntp_snippets/ntp_snippets_fetcher.h
|
| +++ b/components/ntp_snippets/ntp_snippets_fetcher.h
|
| @@ -13,6 +13,8 @@
|
| #include "base/callback.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/optional.h"
|
| +#include "base/time/tick_clock.h"
|
| +#include "base/time/time.h"
|
| #include "components/ntp_snippets/ntp_snippet.h"
|
| #include "net/url_request/url_fetcher_delegate.h"
|
| #include "net/url_request/url_request_context_getter.h"
|
| @@ -78,6 +80,11 @@ class NTPSnippetsFetcher : public net::URLFetcherDelegate {
|
| return last_fetch_json_;
|
| }
|
|
|
| + // Overrides internal clock for testing purposes.
|
| + void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock) {
|
| + tick_clock_ = std::move(tick_clock);
|
| + }
|
| +
|
| private:
|
| // URLFetcherDelegate implementation.
|
| void OnURLFetchComplete(const net::URLFetcher* source) override;
|
| @@ -92,6 +99,7 @@ class NTPSnippetsFetcher : public net::URLFetcherDelegate {
|
| scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
|
|
|
| const ParseJSONCallback parse_json_callback_;
|
| + base::TimeTicks fetch_start_time_;
|
| std::string last_status_;
|
| std::string last_fetch_json_;
|
|
|
| @@ -104,6 +112,9 @@ class NTPSnippetsFetcher : public net::URLFetcherDelegate {
|
| // Flag for picking the right (stable/non-stable) API key for Chrome Reader
|
| bool is_stable_channel_;
|
|
|
| + // Allow for an injectable tick clock for testing.
|
| + std::unique_ptr<base::TickClock> tick_clock_;
|
| +
|
| base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher);
|
|
|