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

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 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 FetchFinished(std::move(categories), std::move(callback), 990 FetchFinished(std::move(categories), std::move(callback),
991 FetchResult::SUCCESS, std::string()); 991 FetchResult::SUCCESS, std::string());
992 } 992 }
993 993
994 void NTPSnippetsFetcher::FetchFinished(OptionalFetchedCategories categories, 994 void NTPSnippetsFetcher::FetchFinished(OptionalFetchedCategories categories,
995 SnippetsAvailableCallback callback, 995 SnippetsAvailableCallback callback,
996 FetchResult status_code, 996 FetchResult status_code,
997 const std::string& error_details) { 997 const std::string& error_details) {
998 DCHECK(status_code == FetchResult::SUCCESS || !categories.has_value()); 998 DCHECK(status_code == FetchResult::SUCCESS || !categories.has_value());
999 999
1000 LOG(ERROR) << " ================ ststus_code="
markusheintz_ 2016/12/08 09:50:24 Removed
1001 << static_cast<int>(status_code);
1002
1000 last_status_ = FetchResultToString(status_code) + error_details; 1003 last_status_ = FetchResultToString(status_code) + error_details;
1001 1004
1002 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", 1005 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult",
1003 static_cast<int>(status_code), 1006 static_cast<int>(status_code),
1004 static_cast<int>(FetchResult::RESULT_MAX)); 1007 static_cast<int>(FetchResult::RESULT_MAX));
1005 1008
1006 DVLOG(1) << "Fetch finished: " << last_status_; 1009 DVLOG(1) << "Fetch finished: " << last_status_;
1007 1010
1008 std::move(callback).Run(std::move(categories)); 1011 std::move(callback).Run(std::move(categories), status_code);
1009 } 1012 }
1010 1013
1011 bool NTPSnippetsFetcher::JsonToSnippets(const base::Value& parsed, 1014 bool NTPSnippetsFetcher::JsonToSnippets(const base::Value& parsed,
1012 FetchedCategoriesVector* categories) { 1015 FetchedCategoriesVector* categories) {
1013 const base::DictionaryValue* top_dict = nullptr; 1016 const base::DictionaryValue* top_dict = nullptr;
1014 if (!parsed.GetAsDictionary(&top_dict)) { 1017 if (!parsed.GetAsDictionary(&top_dict)) {
1015 return false; 1018 return false;
1016 } 1019 }
1017 1020
1018 switch (fetch_api_) { 1021 switch (fetch_api_) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 NOTREACHED(); 1100 NOTREACHED();
1098 return false; 1101 return false;
1099 } 1102 }
1100 1103
1101 bool NTPSnippetsFetcher::NeedsAuthentication() const { 1104 bool NTPSnippetsFetcher::NeedsAuthentication() const {
1102 return (personalization_ == Personalization::kPersonal || 1105 return (personalization_ == Personalization::kPersonal ||
1103 personalization_ == Personalization::kBoth); 1106 personalization_ == Personalization::kBoth);
1104 } 1107 }
1105 1108
1106 } // namespace ntp_snippets 1109 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/remote/ntp_snippets_fetcher.h ('k') | components/ntp_snippets/remote/ntp_snippets_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698