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 #ifndef CHROME_BROWSER_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_ | |
6 #define CHROME_BROWSER_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/scoped_vector.h" | |
12 #include "base/threading/non_thread_safe.h" | |
13 #include "chrome/browser/notifier/synced_notification.h" | |
14 #include "chrome/browser/profiles/profile_keyed_service.h" | |
15 #include "sync/api/syncable_service.h" | |
16 | |
17 class Profile; | |
18 class NotificationUIManager; | |
dcheng
2013/01/28 23:35:09
Minor nit: Most people sort these alphabetically.
Pete Williamson
2013/01/29 00:11:43
Done.
| |
19 | |
20 namespace notifier { | |
21 | |
22 // The ChromeNotifierService holds notifications which represent the state of | |
23 // delivered notifications for chrome. These are obtained from the sync service | |
24 // and kept up to date. | |
25 class ChromeNotifierService : public syncer::SyncableService, | |
26 public ProfileKeyedService { | |
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 const SyncedNotification& notification); | |
50 | |
51 // Convert from SyncData representation to internal representation. | |
52 static scoped_ptr<SyncedNotification> CreateNotificationFromSyncData( | |
53 const syncer::SyncData& sync_data); | |
54 | |
55 // Get a pointer to a notification. ChromeNotifierService owns this pointer. | |
56 // The caller must not free it. | |
57 notifier::SyncedNotification* FindNotificationById(const std::string& id); | |
58 | |
59 // functions for test | |
60 void AddForTest(scoped_ptr<notifier::SyncedNotification> notification) { | |
61 Add(notification.Pass()); | |
62 } | |
63 | |
64 private: | |
65 // Add a notification to our list. This takes ownership of the pointer. | |
66 void Add(scoped_ptr<notifier::SyncedNotification> notification); | |
67 | |
68 void Show(notifier::SyncedNotification* notification); | |
69 | |
70 // Back pointer to the owning profile. | |
71 Profile* profile_; | |
72 NotificationUIManager* notification_manager_; | |
dcheng
2013/01/28 23:35:09
Nit: make these T* const so they don't get reset a
Pete Williamson
2013/01/29 00:11:43
Not done, we use this to call the non-const Notifi
dcheng
2013/01/29 00:28:34
T* const is not the same thing as const T*. In par
Pete Williamson
2013/01/29 00:37:49
Oops, I misread your comment thinking you wanted m
| |
73 | |
74 // TODO(petewil): consider whether a map would better suit our data. | |
75 // If there are many entries, lookup time may trump locality of reference. | |
76 ScopedVector<notifier::SyncedNotification> notification_data_; | |
77 | |
78 DISALLOW_COPY_AND_ASSIGN(ChromeNotifierService); | |
79 }; | |
80 | |
81 } // namespace notifier | |
82 | |
83 #endif // CHROME_BROWSER_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_ | |
OLD | NEW |