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

Unified Diff: chrome/browser/extensions/app_notification.cc

Issue 8567018: Limit number of notifications that can be received by the client. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 1 month 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/extensions/app_notification.cc
===================================================================
--- chrome/browser/extensions/app_notification.cc (revision 109957)
+++ chrome/browser/extensions/app_notification.cc (working copy)
@@ -10,6 +10,7 @@
namespace {
const char* kIsLocalKey = "is_local";
+const char* kCreationKey= "creation_timestamp_ms";
Munjal (Google) 2011/11/17 19:45:32 Nit: name nit. Here and in the rest of the file.
elvin 2011/11/17 22:28:17 Done.
const char* kGuidKey = "guid";
const char* kExtensionIdKey = "extension_id";
const char* kTitleKey = "title";
@@ -20,11 +21,13 @@
} // namespace
AppNotification::AppNotification(bool is_local,
+ double creation_timestamp_ms,
const std::string& guid,
const std::string& extension_id,
const std::string& title,
const std::string& body)
: is_local_(is_local),
+ creation_timestamp_ms_(creation_timestamp_ms),
extension_id_(extension_id),
title_(title),
body_(body) {
@@ -35,7 +38,8 @@
AppNotification* AppNotification::Copy() {
AppNotification* copy = new AppNotification(
- this->is_local(), this->guid(), this->extension_id(),
+ this->is_local(), this->creation_timestamp_ms(),
+ this->guid(), this->extension_id(),
this->title(), this->body());
copy->set_link_url(this->link_url());
copy->set_link_text(this->link_text());
@@ -45,6 +49,7 @@
void AppNotification::ToDictionaryValue(DictionaryValue* result) {
CHECK(result);
result->SetBoolean(kIsLocalKey, is_local_);
+ result->SetDouble(kCreationKey, creation_timestamp_ms_);
asargent_no_longer_on_chrome 2011/11/17 22:36:24 for a Time, you can serialize it as a string like
elvin 2011/11/17 22:52:58 Done On 2011/11/17 22:36:24, Antony Sargent wrote:
if (!guid_.empty())
result->SetString(kGuidKey, guid_);
if (!extension_id_.empty())
@@ -62,12 +67,17 @@
// static
AppNotification* AppNotification::FromDictionaryValue(
const DictionaryValue& value) {
- scoped_ptr<AppNotification> result(new AppNotification(true, "", "", "", ""));
+ scoped_ptr<AppNotification> result(
+ new AppNotification(true, 0, "", "", "", ""));
if (value.HasKey(kIsLocalKey) && !value.GetBoolean(
kIsLocalKey, &result->is_local_)) {
return NULL;
}
+ if (value.HasKey(kCreationKey) && !value.GetDouble(
Munjal (Google) 2011/11/17 19:45:32 Nit: take !value.GetDouble in the next line.
elvin 2011/11/17 22:28:17 Done.
+ kCreationKey, &result->creation_timestamp_ms_)) {
+ return NULL;
+ }
if (value.HasKey(kGuidKey) && !value.GetString(kGuidKey, &result->guid_))
return NULL;
if (value.HasKey(kExtensionIdKey) &&
@@ -96,6 +106,7 @@
bool AppNotification::Equals(const AppNotification& other) const {
return (is_local_ == other.is_local_ &&
+ creation_timestamp_ms_ == other.creation_timestamp_ms_ &&
guid_ == other.guid_ &&
extension_id_ == other.extension_id_ &&
title_ == other.title_ &&

Powered by Google App Engine
This is Rietveld 408576698