Chromium Code Reviews| Index: components/suggestions/suggestions_service.cc |
| diff --git a/components/suggestions/suggestions_service.cc b/components/suggestions/suggestions_service.cc |
| index 181a3d8c8c1865239df5419da5fb104e94db52ea..6101f09cd96582c4c09bcdd751d4ac882db96fd4 100644 |
| --- a/components/suggestions/suggestions_service.cc |
| +++ b/components/suggestions/suggestions_service.cc |
| @@ -101,6 +101,8 @@ const char kSuggestionsFieldTrialControlParam[] = "control"; |
| const char kSuggestionsFieldTrialStateEnabled[] = "enabled"; |
| const char kSuggestionsFieldTrialTimeoutMs[] = "timeout_ms"; |
| +const int64 kDefaultExpiryUsec = 72 * base::Time::kMicrosecondsPerHour; |
|
Mathieu
2014/08/04 19:54:55
Add a comment above saying that the default expiry
gayane -on leave until 09-2017
2014/08/05 14:39:15
Done.
gayane -on leave until 09-2017
2014/08/05 14:39:15
Done.
|
| + |
| namespace { |
| std::string GetBlacklistUrlPrefix() { |
| @@ -304,7 +306,7 @@ void SuggestionsService::OnURLFetchComplete(const net::URLFetcher* source) { |
| bool success = request->GetResponseAsString(&suggestions_data); |
| DCHECK(success); |
| - // Compute suggestions, and dispatch then to requestors. On error still |
| + // Compute suggestions, and dispatch them to requestors. On error still |
| // dispatch empty suggestions. |
| SuggestionsProfile suggestions; |
| if (suggestions_data.empty()) { |
| @@ -313,6 +315,10 @@ void SuggestionsService::OnURLFetchComplete(const net::URLFetcher* source) { |
| } else if (suggestions.ParseFromString(suggestions_data)) { |
| LogResponseState(RESPONSE_VALID); |
| thumbnail_manager_->Initialize(suggestions); |
| + |
| + int64 now_usec = (base::Time::NowFromSystemTime() - base::Time::UnixEpoch()) |
| + .ToInternalValue(); |
| + SetDefaultExpiryTimestamps(&suggestions, now_usec + kDefaultExpiryUsec); |
| suggestions_store_->StoreSuggestions(suggestions); |
| } else { |
| LogResponseState(RESPONSE_INVALID); |
| @@ -323,6 +329,18 @@ void SuggestionsService::OnURLFetchComplete(const net::URLFetcher* source) { |
| ScheduleBlacklistUpload(true); |
| } |
| +void SuggestionsService::SetDefaultExpiryTimestamps( |
| + SuggestionsProfile* suggestions, int64 default_timestamp_usec) { |
| + for (int i = 0; i < suggestions->suggestions_size(); ++i) { |
| + ChromeSuggestion* suggestion = suggestions->mutable_suggestions(i); |
| + // Do not set expiry if the server has already provided a more specific |
| + // expiry time for this suggestions. |
|
Mathieu
2014/08/04 19:54:54
*this suggestion
gayane -on leave until 09-2017
2014/08/05 14:39:15
Done.
|
| + if (!suggestion->has_expiry_ts()){ |
|
Mathieu
2014/08/04 19:54:54
space before {
|
| + suggestion->set_expiry_ts(default_timestamp_usec); |
| + } |
| + } |
| +} |
| + |
| void SuggestionsService::Shutdown() { |
| // Cancel pending request and timeout closure, then serve existing requestors |
| // from cache. |