Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Unified Diff: chrome/browser/search/suggestions/suggestions_source.cc

Issue 423133003: [Suggestions Service] Add support for expiring the SuggestionsStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more coding style changes and refactoring Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search/suggestions/suggestions_source.cc
diff --git a/chrome/browser/search/suggestions/suggestions_source.cc b/chrome/browser/search/suggestions/suggestions_source.cc
index cb0e17e3f798953121fa0a182c1efc7573b26710..9f34270ff56c67b26be800120964fa6d9b281981 100644
--- a/chrome/browser/search/suggestions/suggestions_source.cc
+++ b/chrome/browser/search/suggestions/suggestions_source.cc
@@ -11,13 +11,18 @@
#include "base/bind.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/string16.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/time/time.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/suggestions/suggestions_service_factory.h"
#include "chrome/common/url_constants.h"
#include "components/suggestions/suggestions_service.h"
#include "net/base/escape.h"
+#include "ui/base/l10n/time_format.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image_skia.h"
#include "url/gurl.h"
@@ -42,9 +47,20 @@ void RenderOutputHtml(const SuggestionsProfile& profile,
out.push_back(kHtmlBody);
out.push_back("<h1>Suggestions</h1>\n<ul>");
+ int64 now = (base::Time::NowFromSystemTime() - base::Time::UnixEpoch())
+ .ToInternalValue();
+
+ int cutoff = -1; // forces two-value output for TimeFormat
manzagop (departed) 2014/08/04 19:02:59 Capitalize 'forces'.
gayane -on leave until 09-2017 2014/08/04 19:26:44 skipped because the variable is removed. If you wa
size_t size = profile.suggestions_size();
for (size_t i = 0; i < size; ++i) {
const ChromeSuggestion& suggestion = profile.suggestions(i);
+
+ int64 diff = (suggestion.expiry_ts() - now);
Mathieu 2014/08/04 18:29:21 inline this expression in FromMicroseconds, below
gayane -on leave until 09-2017 2014/08/04 19:26:44 Done.
+ base::TimeDelta td =base::TimeDelta::FromMicroseconds(diff);
Mathieu 2014/08/04 18:29:21 space after =
gayane -on leave until 09-2017 2014/08/04 19:26:44 Done.
+ base::string16 formatted = ui::TimeFormat::Detailed(
+ ui::TimeFormat::Format::FORMAT_DURATION,
Mathieu 2014/08/04 18:29:21 indent all parameters line by 4 from the previous
gayane -on leave until 09-2017 2014/08/04 19:26:44 Done.
+ ui::TimeFormat::Length::LENGTH_LONG,
+ cutoff, td);
Mathieu 2014/08/04 18:29:21 directly pass -1, here
gayane -on leave until 09-2017 2014/08/04 19:26:44 Done.
std::string line;
line += "<li><a href=\"";
line += net::EscapeForHTML(suggestion.url());
@@ -57,7 +73,9 @@ void RenderOutputHtml(const SuggestionsProfile& profile,
line += it->second;
line += "'>";
}
- line += "</a></li>\n";
+ line += "</a> Expires in ";
+ line += base::UTF16ToUTF8(formatted);
+ line += "</li>\n";
out.push_back(line);
}
out.push_back("</ul>");
« no previous file with comments | « no previous file | components/suggestions/proto/suggestions.proto » ('j') | components/suggestions/suggestions_service.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698