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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 805 url_fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 805 url_fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 806 net::LOAD_DO_NOT_SAVE_COOKIES); | 806 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 807 data_use_measurement::DataUseUserData::AttachToFetcher( | 807 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 808 url_fetcher.get(), data_use_measurement::DataUseUserData::NTP_SNIPPETS); | 808 url_fetcher.get(), data_use_measurement::DataUseUserData::NTP_SNIPPETS); |
| 809 | 809 |
| 810 url_fetcher->SetExtraRequestHeaders(headers); | 810 url_fetcher->SetExtraRequestHeaders(headers); |
| 811 url_fetcher->SetUploadData("application/json", body); | 811 url_fetcher->SetUploadData("application/json", body); |
| 812 | 812 |
| 813 // Fetchers are sometimes cancelled because a network change was detected. | 813 // Fetchers are sometimes cancelled because a network change was detected. |
| 814 url_fetcher->SetAutomaticallyRetryOnNetworkChanges(3); | 814 url_fetcher->SetAutomaticallyRetryOnNetworkChanges(3); |
| 815 // Try to make fetching the files bit more robust even with poor connection. | 815 if (params_.interactive_request) { |
| 816 url_fetcher->SetMaxRetriesOn5xx(3); | 816 // Try to make fetching the files bit more robust even with poor connection. |
| 817 url_fetcher->SetMaxRetriesOn5xx(2); | |
| 818 } else { | |
| 819 // Don't retry immediately if a scheduled fetch fails. | |
| 820 // TODO(fhorschig): back off for 1h (+1h jitter) and then retry. | |
|
Marc Treib
2016/12/06 16:06:56
I'm not convinced we actually want to do this :)
M
fhorschig
2016/12/08 10:20:58
Done already. I removed this comment for now as I
| |
| 821 url_fetcher->SetMaxRetriesOn5xx(0); | |
|
Marc Treib
2016/12/06 16:06:56
As discussed offline: Should we introduce a variat
fhorschig
2016/12/08 10:20:58
Done.
| |
| 822 } | |
| 817 return url_fetcher; | 823 return url_fetcher; |
| 818 } | 824 } |
| 819 | 825 |
| 820 void NTPSnippetsFetcher::RequestBuilder::PrepareLanguages( | 826 void NTPSnippetsFetcher::RequestBuilder::PrepareLanguages( |
| 821 translate::LanguageModel::LanguageInfo* ui_language, | 827 translate::LanguageModel::LanguageInfo* ui_language, |
| 822 translate::LanguageModel::LanguageInfo* other_top_language) const { | 828 translate::LanguageModel::LanguageInfo* other_top_language) const { |
| 823 // TODO(jkrcal): Add language model factory for iOS and add fakes to tests so | 829 // TODO(jkrcal): Add language model factory for iOS and add fakes to tests so |
| 824 // that |language_model| is never nullptr. Remove this check and add a DCHECK | 830 // that |language_model| is never nullptr. Remove this check and add a DCHECK |
| 825 // into the constructor. | 831 // into the constructor. |
| 826 if (!language_model_ || !IsSendingTopLanguagesEnabled()) { | 832 if (!language_model_ || !IsSendingTopLanguagesEnabled()) { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1097 NOTREACHED(); | 1103 NOTREACHED(); |
| 1098 return false; | 1104 return false; |
| 1099 } | 1105 } |
| 1100 | 1106 |
| 1101 bool NTPSnippetsFetcher::NeedsAuthentication() const { | 1107 bool NTPSnippetsFetcher::NeedsAuthentication() const { |
| 1102 return (personalization_ == Personalization::kPersonal || | 1108 return (personalization_ == Personalization::kPersonal || |
| 1103 personalization_ == Personalization::kBoth); | 1109 personalization_ == Personalization::kBoth); |
| 1104 } | 1110 } |
| 1105 | 1111 |
| 1106 } // namespace ntp_snippets | 1112 } // namespace ntp_snippets |
| OLD | NEW |