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 { | |
|
Nicolas Zea
2013/01/05 01:18:48
This shouldn't be inside of the sync_pb namespace.
Pete Williamson
2013/01/18 18:58:39
What namespace would be better? None? A new name
Nicolas Zea
2013/01/18 23:09:25
Notifier perhaps? Might also make sense to have th
Pete Williamson
2013/01/23 01:45:55
Done.
| |
| 17 | |
| 18 class SyncedNotificationSpecifics; | |
| 19 | |
| 20 class SyncedNotification { | |
|
Nicolas Zea
2013/01/05 01:18:48
What are you trying to accomplish with this class?
Pete Williamson
2013/01/18 18:58:39
The primary point of this class is to do all the g
| |
| 21 public: | |
| 22 explicit SyncedNotification(const syncer::SyncData sync_data); | |
| 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 title() const; | |
|
dcheng
2013/01/07 20:42:10
Why return a const string?
Pete Williamson
2013/01/18 18:58:39
Would you prefer a const string&?
I don't think I
dcheng
2013/01/18 21:56:13
Returning a const string doesn't guarantee that, a
Pete Williamson
2013/01/23 01:45:55
Done.
| |
| 29 const std::string app_id() const; | |
| 30 const std::string coalescing_key() const; | |
| 31 | |
| 32 const std::string get_first_external_id() const; | |
| 33 | |
| 34 // TODO(petewil): Revisit this when I add more data. | |
| 35 bool Equals(const SyncedNotification& other) { | |
| 36 // Two notifications are equal if the <appId/coalescingKey> pair matches | |
| 37 return true; | |
| 38 } | |
| 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() { | |
|
dcheng
2013/01/07 20:42:10
This method should be const.
Pete Williamson
2013/01/18 18:58:39
Done.
| |
| 45 return has_local_changes_; | |
| 46 } | |
| 47 | |
| 48 syncer::SyncData* sync_data() { | |
|
dcheng
2013/01/07 20:42:10
Should this return a const pointer instead? If not
Pete Williamson
2013/01/18 18:58:39
Done.
| |
| 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 // This keeps the SyncNotificationSpecifics alive. | |
|
dcheng
2013/01/07 20:42:10
How does it keep it alive?
Pete Williamson
2013/01/18 18:58:39
Comment updated to explain how it is kept alive.
| |
| 64 syncer::SyncData sync_data_; | |
| 65 // Set this to true if we make any changes to the client data. | |
| 66 bool has_local_changes_; | |
| 67 }; | |
| 68 | |
| 69 | |
| 70 } // namespace sync_pb | |
| 71 | |
| 72 #endif // CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ | |
| OLD | NEW |