Chromium Code Reviews| 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/remote/ntp_snippets_fetcher.h" | 5 #include "components/ntp_snippets/remote/ntp_snippets_fetcher.h" |
| 6 | 6 |
| 7 #include <cstdlib> | 7 #include <cstdlib> |
| 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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 | 538 |
| 539 params->ui_language.language_code = ISO639FromPosixLocale(locale_); | 539 params->ui_language.language_code = ISO639FromPosixLocale(locale_); |
| 540 params->ui_language.frequency = | 540 params->ui_language.frequency = |
| 541 language_model_->GetLanguageFrequency(params->ui_language.language_code); | 541 language_model_->GetLanguageFrequency(params->ui_language.language_code); |
| 542 | 542 |
| 543 std::vector<LanguageModel::LanguageInfo> top_languages = | 543 std::vector<LanguageModel::LanguageInfo> top_languages = |
| 544 language_model_->GetTopLanguages(); | 544 language_model_->GetTopLanguages(); |
| 545 for (const LanguageModel::LanguageInfo& info : top_languages) { | 545 for (const LanguageModel::LanguageInfo& info : top_languages) { |
| 546 if (info.language_code != params->ui_language.language_code) { | 546 if (info.language_code != params->ui_language.language_code) { |
| 547 params->other_top_language = info; | 547 params->other_top_language = info; |
| 548 | |
| 549 // Report to UMA how important the UI language is. | |
| 550 DCHECK(params->other_top_language.frequency > 0) | |
|
Marc Treib
2016/10/14 15:32:56
DCHECK_GT
jkrcal
2016/10/14 16:34:15
Done.
| |
| 551 << "GetTopLanguages() should not return languages with 0 frequency"; | |
| 552 float ratio_ui_to_other_top_language = | |
| 553 params->ui_language.frequency / params->other_top_language.frequency; | |
|
Marc Treib
2016/10/14 15:32:56
Should this be "ui_freq / (ui_freq + other_freq)"
jkrcal
2016/10/14 16:34:15
Well, I meant it as it was. Your suggestion actual
| |
| 554 UMA_HISTOGRAM_COUNTS_1000( | |
|
Alexei Svitkine (slow)
2016/10/14 15:30:15
I think you probably want to use UMA_HISTOGRAM_PER
jkrcal
2016/10/14 16:34:15
This is what I wanted because the result was not s
| |
| 555 "NewTabPage.Languages.UILanguageToOtherTopLanguageRatio", | |
| 556 ratio_ui_to_other_top_language * 100); | |
| 548 break; | 557 break; |
| 549 } | 558 } |
| 550 } | 559 } |
| 551 } | 560 } |
| 552 | 561 |
| 553 void NTPSnippetsFetcher::FetchSnippetsNonAuthenticated() { | 562 void NTPSnippetsFetcher::FetchSnippetsNonAuthenticated() { |
| 554 // When not providing OAuth token, we need to pass the Google API key. | 563 // When not providing OAuth token, we need to pass the Google API key. |
| 555 GURL url(base::StringPrintf(kSnippetsServerNonAuthorizedFormat, | 564 GURL url(base::StringPrintf(kSnippetsServerNonAuthorizedFormat, |
| 556 fetch_url_.spec().c_str(), api_key_.c_str())); | 565 fetch_url_.spec().c_str(), api_key_.c_str())); |
| 557 | 566 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 interactive_request); | 792 interactive_request); |
| 784 case UserClassifier::UserClass::ACTIVE_SUGGESTIONS_CONSUMER: | 793 case UserClassifier::UserClass::ACTIVE_SUGGESTIONS_CONSUMER: |
| 785 return request_throttler_active_suggestions_consumer_ | 794 return request_throttler_active_suggestions_consumer_ |
| 786 .DemandQuotaForRequest(interactive_request); | 795 .DemandQuotaForRequest(interactive_request); |
| 787 } | 796 } |
| 788 NOTREACHED(); | 797 NOTREACHED(); |
| 789 return false; | 798 return false; |
| 790 } | 799 } |
| 791 | 800 |
| 792 } // namespace ntp_snippets | 801 } // namespace ntp_snippets |
| OLD | NEW |