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

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

Issue 1965333002: Fix a memory error introduced by issue 1922083004, revealed by the (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
« 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 fetch_start_time_ = tick_clock_->NowTicks(); 166 fetch_start_time_ = tick_clock_->NowTicks();
167 167
168 if (UseHostRestriction() && hosts_.empty()) { 168 if (UseHostRestriction() && hosts_.empty()) {
169 FetchFinished(OptionalSnippets(), FetchResult::EMPTY_HOSTS, 169 FetchFinished(OptionalSnippets(), FetchResult::EMPTY_HOSTS,
170 /*extra_message=*/std::string()); 170 /*extra_message=*/std::string());
171 return; 171 return;
172 } 172 }
173 173
174 // Translate the BCP 47 |language_code| into a posix locale string. 174 // Translate the BCP 47 |language_code| into a posix locale string.
175 char locale[ULOC_FULLNAME_CAPACITY]; 175 char locale[ULOC_FULLNAME_CAPACITY];
176 UErrorCode error; 176 UErrorCode error = U_ZERO_ERROR;
177 uloc_forLanguageTag(language_code.c_str(), locale, ULOC_FULLNAME_CAPACITY, 177 uloc_forLanguageTag(language_code.c_str(), locale, ULOC_FULLNAME_CAPACITY,
178 nullptr, &error); 178 nullptr, &error);
179 DLOG_IF(WARNING, U_ZERO_ERROR != error) 179 DLOG_IF(WARNING, U_ZERO_ERROR != error)
180 << "Error in translating language code to a locale string: " << error; 180 << "Error in translating language code to a locale string: " << error;
181 locale_ = locale; 181 locale_ = locale;
182 182
183 count_to_fetch_ = count; 183 count_to_fetch_ = count;
184 184
185 bool use_authentication = UseAuthentication(); 185 bool use_authentication = UseAuthentication();
186 186
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 tick_clock_->NowTicks() - fetch_start_time_); 395 tick_clock_->NowTicks() - fetch_start_time_);
396 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", 396 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult",
397 static_cast<int>(result), 397 static_cast<int>(result),
398 static_cast<int>(FetchResult::RESULT_MAX)); 398 static_cast<int>(FetchResult::RESULT_MAX));
399 399
400 if (!snippets_available_callback_.is_null()) 400 if (!snippets_available_callback_.is_null())
401 snippets_available_callback_.Run(std::move(snippets)); 401 snippets_available_callback_.Run(std::move(snippets));
402 } 402 }
403 403
404 } // namespace ntp_snippets 404 } // 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