| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |