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..0c299ff108a72f2cbcf814dbb2162803d0a41317 100644 |
| --- a/components/suggestions/suggestions_service.cc |
| +++ b/components/suggestions/suggestions_service.cc |
| @@ -101,6 +101,7 @@ const char kSuggestionsFieldTrialControlParam[] = "control"; |
| const char kSuggestionsFieldTrialStateEnabled[] = "enabled"; |
| const char kSuggestionsFieldTrialTimeoutMs[] = "timeout_ms"; |
| +const int64 kDefaultExpiryUsec = 72 * base::Time::kMicrosecondsPerHour; |
|
Mathieu
2014/08/04 18:29:21
new line after this.
gayane -on leave until 09-2017
2014/08/04 19:26:44
Done.
|
| namespace { |
| std::string GetBlacklistUrlPrefix() { |
| @@ -304,7 +305,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 +314,11 @@ 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(); |
| + int64 timestamp_usec = now_usec + kDefaultExpiryUsec; |
| + SetDefaultExpiryTimestamps(&suggestions, timestamp_usec); |
|
Mathieu
2014/08/04 18:29:21
inline now_usec + kDefaultExpiryUsec here
gayane -on leave until 09-2017
2014/08/04 19:26:44
Done.
|
| suggestions_store_->StoreSuggestions(suggestions); |
| } else { |
| LogResponseState(RESPONSE_INVALID); |
| @@ -323,6 +329,16 @@ 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); |
| + if (!suggestion->has_expiry_ts()){ |
|
Mathieu
2014/08/04 18:29:21
add a comment above this line:
// Do not set expi
gayane -on leave until 09-2017
2014/08/04 19:26:44
Done.
|
| + suggestion->set_expiry_ts(default_timestamp_usec); |
| + } |
| + } |
| +} |
| + |
| void SuggestionsService::Shutdown() { |
| // Cancel pending request and timeout closure, then serve existing requestors |
| // from cache. |