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

Side by Side Diff: components/ntp_snippets/remote/ntp_snippets_fetcher.cc

Issue 2549163002: RemoteContentSuggestions: Stores the time of the last successful background fetch in a pref (Closed)
Patch Set: Address comments treib Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "components/ntp_snippets/remote/ntp_snippets_fetcher.h" 5 #include "components/ntp_snippets/remote/ntp_snippets_fetcher.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 DCHECK(status_code == FetchResult::SUCCESS || !categories.has_value()); 998 DCHECK(status_code == FetchResult::SUCCESS || !categories.has_value());
999 999
1000 last_status_ = FetchResultToString(status_code) + error_details; 1000 last_status_ = FetchResultToString(status_code) + error_details;
1001 1001
1002 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", 1002 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult",
1003 static_cast<int>(status_code), 1003 static_cast<int>(status_code),
1004 static_cast<int>(FetchResult::RESULT_MAX)); 1004 static_cast<int>(FetchResult::RESULT_MAX));
1005 1005
1006 DVLOG(1) << "Fetch finished: " << last_status_; 1006 DVLOG(1) << "Fetch finished: " << last_status_;
1007 1007
1008 std::move(callback).Run(std::move(categories)); 1008 std::move(callback).Run(status_code, std::move(categories));
1009 } 1009 }
1010 1010
1011 bool NTPSnippetsFetcher::JsonToSnippets(const base::Value& parsed, 1011 bool NTPSnippetsFetcher::JsonToSnippets(const base::Value& parsed,
1012 FetchedCategoriesVector* categories) { 1012 FetchedCategoriesVector* categories) {
1013 const base::DictionaryValue* top_dict = nullptr; 1013 const base::DictionaryValue* top_dict = nullptr;
1014 if (!parsed.GetAsDictionary(&top_dict)) { 1014 if (!parsed.GetAsDictionary(&top_dict)) {
1015 return false; 1015 return false;
1016 } 1016 }
1017 1017
1018 switch (fetch_api_) { 1018 switch (fetch_api_) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 NOTREACHED(); 1097 NOTREACHED();
1098 return false; 1098 return false;
1099 } 1099 }
1100 1100
1101 bool NTPSnippetsFetcher::NeedsAuthentication() const { 1101 bool NTPSnippetsFetcher::NeedsAuthentication() const {
1102 return (personalization_ == Personalization::kPersonal || 1102 return (personalization_ == Personalization::kPersonal ||
1103 personalization_ == Personalization::kBoth); 1103 personalization_ == Personalization::kBoth);
1104 } 1104 }
1105 1105
1106 } // namespace ntp_snippets 1106 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698