Chromium Code Reviews| Index: chrome/browser/notifier/synced_notification.h |
| diff --git a/chrome/browser/notifier/synced_notification.h b/chrome/browser/notifier/synced_notification.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..29224c5dd8048e934b9391b278c5e6c4b542b35a |
| --- /dev/null |
| +++ b/chrome/browser/notifier/synced_notification.h |
| @@ -0,0 +1,103 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// This class represents the data for a single Synced Notification. |
| +// It should map 1-1 to all the data in synced_notification_sepcifics.proto, |
| +// and the data and render protobufs that the specifics protobuf contains. |
| + |
| +#ifndef CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ |
| +#define CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ |
| + |
| +#include <string> |
| + |
| +#include "googleurl/src/gurl.h" |
| +#include "sync/api/sync_data.h" |
| +#include "sync/protocol/sync.pb.h" |
| +#include "sync/protocol/synced_notification_specifics.pb.h" |
|
Nicolas Zea
2013/01/29 01:17:02
I think you can forward declare any protobuffers n
Pete Williamson
2013/01/29 02:10:37
Done.
|
| + |
| +namespace notifier { |
| + |
| +class SyncedNotification { |
| + public: |
| + explicit SyncedNotification(const syncer::SyncData& sync_data); |
| + |
| + ~SyncedNotification(); |
| + |
| + // Here are some helper functions to get individual data parts out of a |
| + // SyncedNotification. |
| + const std::string& title() const { return title_; } |
| + const std::string& app_id() const { return app_id_; } |
| + const std::string& coalescing_key() const { return coalescing_key_; } |
| + const GURL& origin_url() const { return origin_url_; } |
| + const GURL& icon_url() const { return icon_url_; } |
| + const GURL& image_url() const { return image_url_; } |
| + const std::string& first_external_id() const { return first_external_id_; } |
| + const std::string& notification_id() const { return notification_id_; } |
| + const std::string& body() const { return body_; } |
| + |
| + bool Equals(const SyncedNotification& other) const; |
| + |
| + void set_has_local_changes(bool has_local_changes) { |
| + has_local_changes_ = has_local_changes; |
| + } |
| + |
| + bool has_local_changes() const { |
| + return has_local_changes_; |
| + } |
| + |
| + const syncer::SyncData* sync_data() const { |
| + return &sync_data_; |
| + } |
| + |
| + void NotificationHasBeenRead(); |
| + |
| + void NotificationHasBeenDeleted(); |
| + |
| + // This gets a pointer to the SyncedNotificationSpecifics part |
| + // of the sync data. This is owned by the SyncedNotification class |
| + // (actually refcounted, so it is jointly owned with sync). |
| + // Don't free this pointer! |
| + const sync_pb::SyncedNotificationSpecifics* GetSyncedNotificationSpecifics(); |
| + |
| + private: |
| + // helper function to mark a notification as read or dismissed. |
|
Nicolas Zea
2013/01/29 01:17:02
helper -> Helper
Pete Williamson
2013/01/29 02:10:37
Done.
|
| + bool SetReadState( |
| + sync_pb::CoalescedSyncedNotification_ReadState readState); |
|
Nicolas Zea
2013/01/29 01:17:02
pass as const ref
dcheng
2013/01/29 01:33:48
Btw... I missed this, but naming (should be read_s
Pete Williamson
2013/01/29 02:10:37
Done.
Pete Williamson
2013/01/29 02:10:37
Done.
|
| + |
| + // Parsing functions to get this information out of the sync_data and into |
| + // our local variables. |
| + std::string ExtractTitle(const syncer::SyncData& sync_data) const; |
| + std::string ExtractAppId(const syncer::SyncData& sync_data) const; |
| + std::string ExtractCoalescingKey(const syncer::SyncData& sync_data) const; |
| + GURL ExtractOriginUrl(const syncer::SyncData& sync_data) const; |
| + GURL ExtractIconUrl(const syncer::SyncData& sync_data) const; |
| + GURL ExtractImageUrl(const syncer::SyncData& sync_data) const; |
| + std::string ExtractFirstExternalId(const syncer::SyncData& sync_data) const; |
| + std::string ExtractNotificationId(const syncer::SyncData& sync_data) const; |
| + std::string ExtractBody(const syncer::SyncData& sync_data) const; |
| + |
| + // Set this to true if we make any changes to the client data. |
| + bool has_local_changes_; |
| + |
| + // We need to hold onto the sync data object because GetAllSyncData |
| + // may ask for it back. |
| + syncer::SyncData sync_data_; |
| + |
| + // TODO(petewil): this list is not all inclusive, add the remaining fields. |
| + const std::string title_; |
| + const std::string app_id_; |
| + const std::string coalescing_key_; |
| + const std::string first_external_id_; |
| + const std::string notification_id_; |
| + const std::string body_; |
| + const GURL origin_url_; |
| + const GURL icon_url_; |
| + const GURL image_url_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SyncedNotification); |
| +}; |
| + |
| +} // namespace notifier |
| + |
| +#endif // CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ |