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

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

Issue 2083933004: Logging the NTP snippets request when verbose. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After code review Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 data_use_measurement::DataUseUserData::AttachToFetcher( 249 data_use_measurement::DataUseUserData::AttachToFetcher(
250 url_fetcher_.get(), data_use_measurement::DataUseUserData::NTP_SNIPPETS); 250 url_fetcher_.get(), data_use_measurement::DataUseUserData::NTP_SNIPPETS);
251 251
252 HttpRequestHeaders headers; 252 HttpRequestHeaders headers;
253 if (!auth_header.empty()) 253 if (!auth_header.empty())
254 headers.SetHeader("Authorization", auth_header); 254 headers.SetHeader("Authorization", auth_header);
255 headers.SetHeader("Content-Type", "application/json; charset=UTF-8"); 255 headers.SetHeader("Content-Type", "application/json; charset=UTF-8");
256 url_fetcher_->SetExtraRequestHeaders(headers.ToString()); 256 url_fetcher_->SetExtraRequestHeaders(headers.ToString());
257 url_fetcher_->SetUploadData("application/json", request); 257 url_fetcher_->SetUploadData("application/json", request);
258 // Log the request for debugging network issues.
259 VLOG(1) << "Sending a NTP snippets request to " << url << ":" << std::endl
260 << headers.ToString() << std::endl << request;
258 // Fetchers are sometimes cancelled because a network change was detected. 261 // Fetchers are sometimes cancelled because a network change was detected.
259 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3); 262 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3);
260 // Try to make fetching the files bit more robust even with poor connection. 263 // Try to make fetching the files bit more robust even with poor connection.
261 url_fetcher_->SetMaxRetriesOn5xx(3); 264 url_fetcher_->SetMaxRetriesOn5xx(3);
262 url_fetcher_->Start(); 265 url_fetcher_->Start();
263 } 266 }
264 267
265 std::string NTPSnippetsFetcher::GetHostRestricts() const { 268 std::string NTPSnippetsFetcher::GetHostRestricts() const {
266 std::string host_restricts; 269 std::string host_restricts;
267 if (UsesHostRestrictions()) { 270 if (UsesHostRestrictions()) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 tick_clock_->NowTicks() - fetch_start_time_); 436 tick_clock_->NowTicks() - fetch_start_time_);
434 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", 437 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult",
435 static_cast<int>(result), 438 static_cast<int>(result),
436 static_cast<int>(FetchResult::RESULT_MAX)); 439 static_cast<int>(FetchResult::RESULT_MAX));
437 440
438 if (!snippets_available_callback_.is_null()) 441 if (!snippets_available_callback_.is_null())
439 snippets_available_callback_.Run(std::move(snippets)); 442 snippets_available_callback_.Run(std::move(snippets));
440 } 443 }
441 444
442 } // namespace ntp_snippets 445 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698