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

Side by Side Diff: chrome/browser/extensions/app_notification_manager.h

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/app_notification_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_MANAGER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_MANAGER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/sequenced_task_runner_helpers.h" 15 #include "base/sequenced_task_runner_helpers.h"
16 #include "base/synchronization/waitable_event.h" 16 #include "base/synchronization/waitable_event.h"
17 #include "chrome/browser/extensions/app_notification.h" 17 #include "chrome/browser/extensions/app_notification.h"
18 #include "chrome/browser/extensions/app_notification_storage.h" 18 #include "chrome/browser/extensions/app_notification_storage.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/notification_details.h" 20 #include "content/public/browser/notification_details.h"
21 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
23 #include "sync/api/sync_change.h" 23 #include "sync/api/sync_change.h"
24 #include "sync/api/syncable_service.h" 24 #include "sync/api/syncable_service.h"
25 25
26 class PerfTimer; 26 class PerfTimer;
27 class Profile; 27 class Profile;
28 28
29 namespace csync { 29 namespace syncer {
30 class SyncErrorFactory; 30 class SyncErrorFactory;
31 } 31 }
32 32
33 // This class keeps track of notifications for installed apps. 33 // This class keeps track of notifications for installed apps.
34 class AppNotificationManager 34 class AppNotificationManager
35 : public base::RefCountedThreadSafe< 35 : public base::RefCountedThreadSafe<
36 AppNotificationManager, 36 AppNotificationManager,
37 content::BrowserThread::DeleteOnUIThread>, 37 content::BrowserThread::DeleteOnUIThread>,
38 public content::NotificationObserver, 38 public content::NotificationObserver,
39 public csync::SyncableService { 39 public syncer::SyncableService {
40 public: 40 public:
41 static const unsigned int kMaxNotificationPerApp; 41 static const unsigned int kMaxNotificationPerApp;
42 explicit AppNotificationManager(Profile* profile); 42 explicit AppNotificationManager(Profile* profile);
43 43
44 // Starts up the process of reading from persistent storage. 44 // Starts up the process of reading from persistent storage.
45 void Init(); 45 void Init();
46 46
47 // Returns whether add was succcessful. 47 // Returns whether add was succcessful.
48 // Takes ownership of |item| in all cases. 48 // Takes ownership of |item| in all cases.
49 bool Add(AppNotification* item); 49 bool Add(AppNotification* item);
50 50
51 const AppNotificationList* GetAll(const std::string& extension_id) const; 51 const AppNotificationList* GetAll(const std::string& extension_id) const;
52 52
53 // Returns the most recently added notification for |extension_id| if there 53 // Returns the most recently added notification for |extension_id| if there
54 // are any, or NULL otherwise. 54 // are any, or NULL otherwise.
55 const AppNotification* GetLast(const std::string& extension_id); 55 const AppNotification* GetLast(const std::string& extension_id);
56 56
57 // Clears all notifications for |extension_id|. 57 // Clears all notifications for |extension_id|.
58 void ClearAll(const std::string& extension_id); 58 void ClearAll(const std::string& extension_id);
59 59
60 // Implementing content::NotificationObserver interface. 60 // Implementing content::NotificationObserver interface.
61 virtual void Observe(int type, 61 virtual void Observe(int type,
62 const content::NotificationSource& source, 62 const content::NotificationSource& source,
63 const content::NotificationDetails& details) OVERRIDE; 63 const content::NotificationDetails& details) OVERRIDE;
64 64
65 bool loaded() const { return notifications_.get() != NULL; } 65 bool loaded() const { return notifications_.get() != NULL; }
66 66
67 // csync::SyncableService implementation. 67 // syncer::SyncableService implementation.
68 68
69 // Returns all syncable notifications from this model as csync::SyncData. 69 // Returns all syncable notifications from this model as syncer::SyncData.
70 virtual csync::SyncDataList GetAllSyncData( 70 virtual syncer::SyncDataList GetAllSyncData(
71 syncable::ModelType type) const OVERRIDE; 71 syncable::ModelType type) const OVERRIDE;
72 // Process notifications related changes from Sync, merging them into 72 // Process notifications related changes from Sync, merging them into
73 // our model. 73 // our model.
74 virtual csync::SyncError ProcessSyncChanges( 74 virtual syncer::SyncError ProcessSyncChanges(
75 const tracked_objects::Location& from_here, 75 const tracked_objects::Location& from_here,
76 const csync::SyncChangeList& change_list) OVERRIDE; 76 const syncer::SyncChangeList& change_list) OVERRIDE;
77 // Associate and merge sync data model with our data model. 77 // Associate and merge sync data model with our data model.
78 virtual csync::SyncError MergeDataAndStartSyncing( 78 virtual syncer::SyncError MergeDataAndStartSyncing(
79 syncable::ModelType type, 79 syncable::ModelType type,
80 const csync::SyncDataList& initial_sync_data, 80 const syncer::SyncDataList& initial_sync_data,
81 scoped_ptr<csync::SyncChangeProcessor> sync_processor, 81 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
82 scoped_ptr<csync::SyncErrorFactory> sync_error_factory) OVERRIDE; 82 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE;
83 virtual void StopSyncing(syncable::ModelType type) OVERRIDE; 83 virtual void StopSyncing(syncable::ModelType type) OVERRIDE;
84 84
85 private: 85 private:
86 friend class AppNotificationManagerSyncTest; 86 friend class AppNotificationManagerSyncTest;
87 friend class base::DeleteHelper<AppNotificationManager>; 87 friend class base::DeleteHelper<AppNotificationManager>;
88 friend struct content::BrowserThread::DeleteOnThread< 88 friend struct content::BrowserThread::DeleteOnThread<
89 content::BrowserThread::UI>; 89 content::BrowserThread::UI>;
90 FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, 90 FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest,
91 NotificationToSyncDataToNotification); 91 NotificationToSyncDataToNotification);
92 FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, 92 FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 // Sends a change to syncer to add the given notification. 144 // Sends a change to syncer to add the given notification.
145 void SyncAddChange(const AppNotification& notif); 145 void SyncAddChange(const AppNotification& notif);
146 146
147 // Sends a change to syncer to remove the given notification. 147 // Sends a change to syncer to remove the given notification.
148 void SyncRemoveChange(const AppNotification& notif); 148 void SyncRemoveChange(const AppNotification& notif);
149 149
150 // Sends changes to syncer to remove all notifications in the given list. 150 // Sends changes to syncer to remove all notifications in the given list.
151 void SyncClearAllChange(const AppNotificationList& list); 151 void SyncClearAllChange(const AppNotificationList& list);
152 152
153 // Converters from AppNotification to csync::SyncData and vice versa. 153 // Converters from AppNotification to syncer::SyncData and vice versa.
154 static csync::SyncData CreateSyncDataFromNotification( 154 static syncer::SyncData CreateSyncDataFromNotification(
155 const AppNotification& notification); 155 const AppNotification& notification);
156 static AppNotification* CreateNotificationFromSyncData( 156 static AppNotification* CreateNotificationFromSyncData(
157 const csync::SyncData& sync_data); 157 const syncer::SyncData& sync_data);
158 158
159 Profile* profile_; 159 Profile* profile_;
160 content::NotificationRegistrar registrar_; 160 content::NotificationRegistrar registrar_;
161 scoped_ptr<NotificationMap> notifications_; 161 scoped_ptr<NotificationMap> notifications_;
162 162
163 // This should only be used on the FILE thread. 163 // This should only be used on the FILE thread.
164 scoped_ptr<AppNotificationStorage> storage_; 164 scoped_ptr<AppNotificationStorage> storage_;
165 165
166 // Sync change processor we use to push all our changes. 166 // Sync change processor we use to push all our changes.
167 scoped_ptr<csync::SyncChangeProcessor> sync_processor_; 167 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
168 168
169 // Sync error handler that we use to create errors from. 169 // Sync error handler that we use to create errors from.
170 scoped_ptr<csync::SyncErrorFactory> sync_error_factory_; 170 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_;
171 171
172 // Whether the sync model is associated with the local model. 172 // Whether the sync model is associated with the local model.
173 // In other words, whether we are ready to apply sync changes. 173 // In other words, whether we are ready to apply sync changes.
174 bool models_associated_; 174 bool models_associated_;
175 // Whether syncer changes are being processed right now. 175 // Whether syncer changes are being processed right now.
176 bool processing_syncer_changes_; 176 bool processing_syncer_changes_;
177 177
178 // Used for a histogram of load time. 178 // Used for a histogram of load time.
179 scoped_ptr<PerfTimer> load_timer_; 179 scoped_ptr<PerfTimer> load_timer_;
180 180
181 DISALLOW_COPY_AND_ASSIGN(AppNotificationManager); 181 DISALLOW_COPY_AND_ASSIGN(AppNotificationManager);
182 }; 182 };
183 183
184 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_MANAGER_H_ 184 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/app_notification_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698