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

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

Issue 11745024: Synced Notification Sync Change Processor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Synced Notifications - CR changes per Zea and DCheng Created 7 years, 11 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 #ifndef CHROME_BROWSER_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_
6 #define CHROME_BROWSER_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_vector.h"
10 #include "base/threading/non_thread_safe.h"
11 #include "chrome/browser/notifier/synced_notification.h"
12 #include "chrome/browser/profiles/profile_keyed_service.h"
13 #include "sync/api/syncable_service.h"
14
15 class Profile;
16 class NotificationUIManager;
17
18 namespace notifier {
19
20 // The ChromeNotifierService holds notifications which
21 // represent the state of delivered notifications for chrome.
22 // These are obtained from the sync service and kept up to date.
23 class ChromeNotifierService : public syncer::SyncableService,
24 public ProfileKeyedService,
25 public base::NonThreadSafe {
26
27 public:
28 ChromeNotifierService(Profile* profile, NotificationUIManager* manager);
29 virtual ~ChromeNotifierService();
30
31 // Methods from ProfileKeyedService.
32 virtual void Shutdown() OVERRIDE;
33
34 // syncer::SyncableService implementation.
35 virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
36 syncer::ModelType type,
37 const syncer::SyncDataList& initial_sync_data,
38 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
39 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE;
40 virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
41 virtual syncer::SyncDataList GetAllSyncData(
42 syncer::ModelType type) const OVERRIDE;
43 virtual syncer::SyncError ProcessSyncChanges(
44 const tracked_objects::Location& from_here,
45 const syncer::SyncChangeList& change_list) OVERRIDE;
46
47 // Convert from internal representation to SyncData representation.
48 static syncer::SyncData CreateSyncDataFromNotification(
49 SyncedNotification& notification);
50
51 // Convert from SyncData representation to internal representation.
52 static SyncedNotification* CreateNotificationFromSyncData(
53 const syncer::SyncData& sync_data);
54
55 // Add a notification to our list. This takes ownership of the pointer.
56 void Add(scoped_ptr<notifier::SyncedNotification> notification);
57
58 void Show(notifier::SyncedNotification* notification);
59
60 // Get a pointer to a notification. ChromeNotifierService owns this pointer.
61 // The caller must not free the it.
62 notifier::SyncedNotification* FindNotificationById(const std::string& id);
63
64 private:
65 // Backpointer to the owning profile, do not free at shutdown.
66 Profile* profile_;
67 NotificationUIManager* notification_manager_;
68
69 // TODO(petewil): consider whether a map would better suit our data.
70 // If there are many entries, lookup time may trump locality of reference.
71 ScopedVector<notifier::SyncedNotification> notification_data_;
72
73 DISALLOW_COPY_AND_ASSIGN(ChromeNotifierService);
74 };
75
76 } // namespace notifier
77
78 #endif // CHROME_BROWSER_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698