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

Side by Side Diff: chrome/browser/notifier/synced_notification.h

Issue 11745024: Synced Notification Sync Change Processor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Synced Notifications Change Processor CR fixes per Zea Created 7 years, 10 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 unified diff | Download patch
OLDNEW
(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 <string>
13
14 #include "googleurl/src/gurl.h"
15 #include "sync/api/sync_data.h"
16
17
18 namespace sync_pb {
19 enum CoalescedSyncedNotification_ReadState;
20 class SyncedNotificationSpecifics;
21 } // namespace sync_pb
22
23 namespace notifier {
24
25 class SyncedNotification {
26 public:
27 explicit SyncedNotification(const syncer::SyncData& sync_data);
28
29 ~SyncedNotification();
30
31 // Here are some helper functions to get individual data parts out of a
32 // SyncedNotification.
33 const std::string& title() const { return title_; }
34 const std::string& app_id() const { return app_id_; }
35 const std::string& coalescing_key() const { return coalescing_key_; }
36 const GURL& origin_url() const { return origin_url_; }
37 const GURL& icon_url() const { return icon_url_; }
38 const GURL& image_url() const { return image_url_; }
39 const std::string& first_external_id() const { return first_external_id_; }
40 const std::string& notification_id() const { return notification_id_; }
41 const std::string& body() const { return body_; }
42
43 bool Equals(const SyncedNotification& other) const;
44
45 void set_has_local_changes(bool has_local_changes) {
46 has_local_changes_ = has_local_changes;
47 }
48
49 bool has_local_changes() const {
50 return has_local_changes_;
51 }
52
53 const syncer::SyncData* sync_data() const {
54 return &sync_data_;
55 }
56
57 void NotificationHasBeenRead();
58
59 void NotificationHasBeenDeleted();
60
61 // This gets a pointer to the SyncedNotificationSpecifics part
62 // of the sync data. This is owned by the SyncedNotification class
63 // (actually refcounted, so it is jointly owned with sync).
64 // Don't free this pointer!
65 const sync_pb::SyncedNotificationSpecifics* GetSyncedNotificationSpecifics();
66
67 private:
68 // Helper function to mark a notification as read or dismissed.
69 bool SetReadState(
70 const sync_pb::CoalescedSyncedNotification_ReadState& read_state);
71
72 // Parsing functions to get this information out of the sync_data and into
73 // our local variables.
74 std::string ExtractTitle(const syncer::SyncData& sync_data) const;
75 std::string ExtractAppId(const syncer::SyncData& sync_data) const;
76 std::string ExtractCoalescingKey(const syncer::SyncData& sync_data) const;
77 GURL ExtractOriginUrl(const syncer::SyncData& sync_data) const;
78 GURL ExtractIconUrl(const syncer::SyncData& sync_data) const;
79 GURL ExtractImageUrl(const syncer::SyncData& sync_data) const;
80 std::string ExtractFirstExternalId(const syncer::SyncData& sync_data) const;
81 std::string ExtractNotificationId(const syncer::SyncData& sync_data) const;
82 std::string ExtractBody(const syncer::SyncData& sync_data) const;
83
84 // Set this to true if we make any changes to the client data.
85 bool has_local_changes_;
86
87 // We need to hold onto the sync data object because GetAllSyncData
88 // may ask for it back.
89 syncer::SyncData sync_data_;
90
91 // TODO(petewil): this list is not all inclusive, add the remaining fields.
92 const std::string title_;
93 const std::string app_id_;
94 const std::string coalescing_key_;
95 const std::string first_external_id_;
96 const std::string notification_id_;
97 const std::string body_;
98 const GURL origin_url_;
99 const GURL icon_url_;
100 const GURL image_url_;
101
102 DISALLOW_COPY_AND_ASSIGN(SyncedNotification);
103 };
104
105 } // namespace notifier
106
107 #endif // CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698