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

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

Issue 1942913002: Revert of [NTP Snippets] Add unit tests for NTPSnippetsFetcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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/ntp_snippets_fetcher.h" 5 #include "components/ntp_snippets/ntp_snippets_fetcher.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 NTPSnippetsFetcher::~NTPSnippetsFetcher() {} 80 NTPSnippetsFetcher::~NTPSnippetsFetcher() {}
81 81
82 std::unique_ptr<NTPSnippetsFetcher::SnippetsAvailableCallbackList::Subscription> 82 std::unique_ptr<NTPSnippetsFetcher::SnippetsAvailableCallbackList::Subscription>
83 NTPSnippetsFetcher::AddCallback(const SnippetsAvailableCallback& callback) { 83 NTPSnippetsFetcher::AddCallback(const SnippetsAvailableCallback& callback) {
84 return callback_list_.Add(callback); 84 return callback_list_.Add(callback);
85 } 85 }
86 86
87 void NTPSnippetsFetcher::FetchSnippets(const std::set<std::string>& hosts, 87 void NTPSnippetsFetcher::FetchSnippets(const std::set<std::string>& hosts,
88 int count) { 88 int count) {
89 // TODO(treib): What to do if there's already a pending request?
89 const std::string& key = is_stable_channel_ 90 const std::string& key = is_stable_channel_
90 ? google_apis::GetAPIKey() 91 ? google_apis::GetAPIKey()
91 : google_apis::GetNonStableAPIKey(); 92 : google_apis::GetNonStableAPIKey();
92 std::string url = 93 std::string url =
93 base::StringPrintf(kContentSnippetsServerFormat, key.c_str()); 94 base::StringPrintf(kContentSnippetsServerFormat, key.c_str());
94 url_fetcher_ = URLFetcher::Create(GURL(url), URLFetcher::POST, this); 95 url_fetcher_ = URLFetcher::Create(GURL(url), URLFetcher::POST, this);
95 url_fetcher_->SetRequestContext(url_request_context_getter_.get()); 96 url_fetcher_->SetRequestContext(url_request_context_getter_.get());
96 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 97 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
97 net::LOAD_DO_NOT_SAVE_COOKIES); 98 net::LOAD_DO_NOT_SAVE_COOKIES);
98 HttpRequestHeaders headers; 99 HttpRequestHeaders headers;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 136
136 } else { 137 } else {
137 bool stores_result_to_string = source->GetResponseAsString(&response); 138 bool stores_result_to_string = source->GetResponseAsString(&response);
138 DCHECK(stores_result_to_string); 139 DCHECK(stores_result_to_string);
139 } 140 }
140 141
141 callback_list_.Notify(response, message); 142 callback_list_.Notify(response, message);
142 } 143 }
143 144
144 } // namespace ntp_snippets 145 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/ntp_snippets_fetcher.h ('k') | components/ntp_snippets/ntp_snippets_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698