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

Unified Diff: components/ntp_snippets/remote/json_request.cc

Issue 2686063003: [remote suggestions] Attach the fetch time to RemoteSnippets, ContentSnippets and SnippetArticle (Closed)
Patch Set: rebase Created 3 years, 10 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
Index: components/ntp_snippets/remote/json_request.cc
diff --git a/components/ntp_snippets/remote/json_request.cc b/components/ntp_snippets/remote/json_request.cc
index ad14bbd56b36e1d5b372d2f7d985d6b103835796..c22e35c9ee9ec0f965fcab85b8c67cb1d03e8e53 100644
--- a/components/ntp_snippets/remote/json_request.cc
+++ b/components/ntp_snippets/remote/json_request.cc
@@ -14,8 +14,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/metrics/sparse_histogram.h"
#include "base/strings/stringprintf.h"
-#include "base/time/tick_clock.h"
-#include "base/time/time.h"
+#include "base/time/clock.h"
#include "base/values.h"
#include "components/data_use_measurement/core/data_use_user_data.h"
#include "components/ntp_snippets/category_info.h"
@@ -160,13 +159,13 @@ CategoryInfo BuildRemoteCategoryInfo(const base::string16& title,
JsonRequest::JsonRequest(
base::Optional<Category> exclusive_category,
- base::TickClock* tick_clock, // Needed until destruction of the request.
+ base::Clock* clock, // Needed until destruction of the request.
const ParseJSONCallback& callback)
: exclusive_category_(exclusive_category),
- tick_clock_(tick_clock),
+ clock_(clock),
parse_json_callback_(callback),
weak_ptr_factory_(this) {
- creation_time_ = tick_clock_->NowTicks();
+ creation_time_ = clock_->Now();
}
JsonRequest::~JsonRequest() {
@@ -180,7 +179,7 @@ void JsonRequest::Start(CompletedCallback callback) {
}
base::TimeDelta JsonRequest::GetFetchDuration() const {
- return tick_clock_->NowTicks() - creation_time_;
+ return clock_->Now() - creation_time_;
}
std::string JsonRequest::GetResponseString() const {
@@ -253,9 +252,9 @@ JsonRequest::Builder::~Builder() = default;
std::unique_ptr<JsonRequest> JsonRequest::Builder::Build() const {
DCHECK(!url_.is_empty());
DCHECK(url_request_context_getter_);
- DCHECK(tick_clock_);
- auto request = base::MakeUnique<JsonRequest>(
- params_.exclusive_category, tick_clock_, parse_json_callback_);
+ DCHECK(clock_);
+ auto request = base::MakeUnique<JsonRequest>(params_.exclusive_category,
+ clock_, parse_json_callback_);
std::string body = BuildBody();
std::string headers = BuildHeaders();
request->url_fetcher_ = BuildURLFetcher(request.get(), headers, body);
@@ -299,9 +298,8 @@ JsonRequest::Builder& JsonRequest::Builder::SetParseJsonCallback(
return *this;
}
-JsonRequest::Builder& JsonRequest::Builder::SetTickClock(
- base::TickClock* tick_clock) {
- tick_clock_ = tick_clock;
+JsonRequest::Builder& JsonRequest::Builder::SetClock(base::Clock* clock) {
+ clock_ = clock;
return *this;
}
« no previous file with comments | « components/ntp_snippets/remote/json_request.h ('k') | components/ntp_snippets/remote/json_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698