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 "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 // The ChromeNotifierService holds notifications which | |
dcheng
2013/01/18 21:56:13
Optional/preference/nit: I'm just eyeballing this,
Pete Williamson
2013/01/24 01:48:11
Done.
| |
19 // represent the state of delivered notifications for chrome. | |
20 // These are obtained from the sync service and kept up to date. | |
21 class ChromeNotifierService : public syncer::SyncableService, | |
22 public ProfileKeyedService, | |
23 public base::NonThreadSafe { | |
dcheng
2013/01/18 21:56:13
Why not use ThreadChecker (which uses composition)
dcheng
2013/01/23 18:39:43
I think you missed the comments in this file.
Pete Williamson
2013/01/24 01:48:11
OK, removed the inheritance from base::NonThreadSa
| |
24 | |
25 public: | |
26 ChromeNotifierService(Profile* profile, NotificationUIManager* manager); | |
27 virtual ~ChromeNotifierService(); | |
28 | |
29 // Methods from ProfileKeyedService. | |
30 virtual void Shutdown() OVERRIDE; | |
31 | |
32 // syncer::SyncableService implementation. | |
33 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( | |
34 syncer::ModelType type, | |
35 const syncer::SyncDataList& initial_sync_data, | |
36 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | |
37 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE; | |
38 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; | |
39 virtual syncer::SyncDataList GetAllSyncData( | |
40 syncer::ModelType type) const OVERRIDE; | |
41 virtual syncer::SyncError ProcessSyncChanges( | |
42 const tracked_objects::Location& from_here, | |
43 const syncer::SyncChangeList& change_list) OVERRIDE; | |
44 | |
45 // Convert from internal representation to SyncData representation. | |
46 static syncer::SyncData CreateSyncDataFromNotification( | |
47 sync_pb::SyncedNotification& notification); | |
dcheng
2013/01/18 21:56:13
Pass by const reference.
Pete Williamson
2013/01/24 01:48:11
Done.
| |
48 | |
49 // Convert from SyncData representation to internal representation. | |
50 static sync_pb::SyncedNotification* CreateNotificationFromSyncData( | |
51 const syncer::SyncData& sync_data); | |
dcheng
2013/01/18 21:56:13
Optional/preference/nit: I'd personally prefer to
| |
52 | |
53 // Add a notification to our list. This takes ownership of the pointer. | |
54 void Add(scoped_ptr<sync_pb::SyncedNotification> notification); | |
55 | |
56 void Show(sync_pb::SyncedNotification* notification); | |
57 | |
58 // Get a pointer to a notification. ChromeNotifierService owns this pointer. | |
59 // The caller must not free the it. | |
dcheng
2013/01/18 21:56:13
s/the//
Pete Williamson
2013/01/24 01:48:11
Done.
| |
60 sync_pb::SyncedNotification* FindNotificationById(const std::string& id); | |
61 | |
62 private: | |
63 // Backpointer to the owning profile, do not free at shutdown. | |
dcheng
2013/01/18 21:56:13
Back pointer. I also feel that "do not free" is re
Pete Williamson
2013/01/24 01:48:11
Done.
| |
64 Profile* profile_; | |
65 NotificationUIManager* notification_manager_; | |
66 | |
67 // TODO(petewil): consider whether a map would better suit our data. | |
68 // If there are many entries, lookup time may trump locality of reference. | |
69 ScopedVector<sync_pb::SyncedNotification> notification_data_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(ChromeNotifierService); | |
72 }; | |
73 | |
74 #endif // CHROME_BROWSER_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_ | |
OLD | NEW |