Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // This class represents the data for a single Synced Notification. | |
| 6 // It should map 1-1 to all the data in synced_notification_sepcifics.proto, | |
| 7 // and the data and render protobufs that the specifics protobuf contains. | |
| 8 | |
| 9 #ifndef CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ | |
| 10 #define CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ | |
| 11 | |
| 12 #include "sync/api/sync_data.h" | |
| 13 #include "sync/protocol/sync.pb.h" | |
| 14 #include "sync/protocol/synced_notification_specifics.pb.h" | |
| 15 | |
| 16 namespace sync_pb { | |
| 17 | |
| 18 class SyncedNotificationSpecifics; | |
| 19 | |
| 20 class SyncedNotification { | |
| 21 public: | |
| 22 explicit SyncedNotification(const syncer::SyncData sync_data); | |
|
dcheng
2013/01/18 21:56:13
Pass by const reference please.
Pete Williamson
2013/01/23 01:45:55
Done.
| |
| 23 | |
| 24 ~SyncedNotification(); | |
| 25 | |
| 26 // Here are some helper functions to get individual data parts out of a | |
| 27 // syncedNotification protobuf. | |
| 28 const std::string get_title() const; | |
|
dcheng
2013/01/18 21:56:13
GetTitle. Ditto for everything else.
Pete Williamson
2013/01/23 01:45:55
Done.
| |
| 29 const std::string get_app_id() const; | |
| 30 const std::string get_coalescing_key() const; | |
| 31 const std::string get_origin_url() const; | |
| 32 const std::string get_icon_url() const; | |
| 33 | |
| 34 const std::string get_first_external_id() const; | |
| 35 const std::string get_notification_id() const; | |
| 36 const std::string get_body() const; | |
| 37 | |
| 38 bool Equals(const SyncedNotification& other) const; | |
| 39 | |
| 40 void set_has_local_changes(bool has_local_changes) { | |
| 41 has_local_changes_ = has_local_changes; | |
| 42 } | |
| 43 | |
| 44 bool has_local_changes() const { | |
| 45 return has_local_changes_; | |
| 46 } | |
| 47 | |
| 48 syncer::SyncData* mutable_sync_data() { | |
| 49 return &sync_data_; | |
| 50 } | |
| 51 | |
| 52 void NotificationHasBeenRead(); | |
| 53 | |
| 54 void NotificationHasBeenDeleted(); | |
| 55 | |
| 56 // This gets a pointer to the SyncedNotificationSpecifics part | |
| 57 // of the sync data. This is owned by the SyncedNotification class | |
| 58 // (actually refcounted, so it is jointly owned with sync). | |
| 59 // Don't free this pointer! | |
| 60 const sync_pb::SyncedNotificationSpecifics* GetSyncedNotificationSpecifics(); | |
| 61 | |
| 62 private: | |
| 63 // helper function to mark a notification as read or dismissed. | |
| 64 bool SetReadState( | |
| 65 SyncedNotificationCoalescedNotification_ReadState readState); | |
| 66 // This keeps the SyncNotificationSpecifics alive by putting | |
| 67 // it into the contained sync entity. | |
|
dcheng
2013/01/18 21:56:13
I really don't understand what this comment means.
Nicolas Zea
2013/01/18 23:09:25
Is the only reason you keep around the sync data t
Pete Williamson
2013/01/23 01:45:55
Moved comment to the .cc file
Pete Williamson
2013/01/23 01:45:55
My thinking in keeping it around is that I need to
Nicolas Zea
2013/01/25 00:18:45
I think it would be better to compare by having tw
Pete Williamson
2013/01/25 19:58:36
As it turns out, there is another reason to keep t
| |
| 68 syncer::SyncData sync_data_; | |
|
dcheng
2013/01/18 21:56:13
Extra space.
Pete Williamson
2013/01/23 01:45:55
Done.
| |
| 69 // Set this to true if we make any changes to the client data. | |
| 70 bool has_local_changes_; | |
|
dcheng
2013/01/18 21:56:13
DISALLOW_COPY_AND_ASSIGN.
Pete Williamson
2013/01/23 01:45:55
Done.
| |
| 71 }; | |
| 72 | |
| 73 | |
| 74 } // namespace sync_pb | |
| 75 | |
| 76 #endif // CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ | |
| OLD | NEW |