Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Unified Diff: components/ntp_snippets/ntp_snippets_fetcher.h

Issue 1961943002: [NTP Snippets] Add histogram with fetch time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@json_to_fetcher_5
Patch Set: Rebased. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/ntp_snippets/ntp_snippets_fetcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | components/ntp_snippets/ntp_snippets_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698