OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
16 #include "chrome/browser/extensions/app_notification.h" | 16 #include "chrome/browser/extensions/app_notification.h" |
17 #include "chrome/browser/extensions/app_notification_storage.h" | 17 #include "chrome/browser/extensions/app_notification_storage.h" |
18 #include "chrome/browser/sync/api/sync_change.h" | 18 #include "chrome/browser/sync/api/sync_change.h" |
19 #include "chrome/browser/sync/api/syncable_service.h" | 19 #include "chrome/browser/sync/api/syncable_service.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 namespace notification_manager_constants { | |
Munjal (Google)
2011/11/17 19:45:32
Add one empty line before namespace.
elvin
2011/11/17 22:28:17
Done.
| |
24 const unsigned int kMaxNotificationPerApp = 5; | |
Munjal (Google)
2011/11/17 19:45:32
Actually this constant is not used in header, and
elvin
2011/11/17 22:28:17
It's used in the test file?
On 2011/11/17 19:45:32
| |
25 } | |
23 | 26 |
24 class Profile; | 27 class Profile; |
25 | 28 |
26 // This class keeps track of notifications for installed apps. | 29 // This class keeps track of notifications for installed apps. |
27 class AppNotificationManager | 30 class AppNotificationManager |
28 : public base::RefCountedThreadSafe<AppNotificationManager>, | 31 : public base::RefCountedThreadSafe<AppNotificationManager>, |
29 public content::NotificationObserver, | 32 public content::NotificationObserver, |
30 public SyncableService { | 33 public SyncableService { |
31 public: | 34 public: |
32 explicit AppNotificationManager(Profile* profile); | 35 explicit AppNotificationManager(Profile* profile); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 void Remove(const std::string& extension_id, const std::string& guid); | 126 void Remove(const std::string& extension_id, const std::string& guid); |
124 | 127 |
125 // Returns the notification for the given |extension_id| and |guid|, | 128 // Returns the notification for the given |extension_id| and |guid|, |
126 // NULL if no such notification exists. | 129 // NULL if no such notification exists. |
127 const AppNotification* GetNotification(const std::string& extension_id, | 130 const AppNotification* GetNotification(const std::string& extension_id, |
128 const std::string& guid); | 131 const std::string& guid); |
129 | 132 |
130 // Sends a change to syncer to add the given notification. | 133 // Sends a change to syncer to add the given notification. |
131 void SyncAddChange(const AppNotification& notif); | 134 void SyncAddChange(const AppNotification& notif); |
132 | 135 |
136 // Sends a change to syncer to remove the given notification. | |
137 void SyncRemoveChange(const AppNotification& notif, | |
138 bool shouldProcessSyncerChanges); | |
Munjal (Google)
2011/11/17 19:45:32
This method is an instance method and it can acces
elvin
2011/11/17 22:28:17
REmoved
On 2011/11/17 19:45:32, munjal wrote:
| |
139 | |
133 // Sends changes to syncer to remove all notifications in the given list. | 140 // Sends changes to syncer to remove all notifications in the given list. |
134 void SyncClearAllChange(const AppNotificationList& list); | 141 void SyncClearAllChange(const AppNotificationList& list); |
135 | 142 |
136 // Converters from AppNotification to SyncData and vice versa. | 143 // Converters from AppNotification to SyncData and vice versa. |
137 static SyncData CreateSyncDataFromNotification( | 144 static SyncData CreateSyncDataFromNotification( |
138 const AppNotification& notification); | 145 const AppNotification& notification); |
139 static AppNotification* CreateNotificationFromSyncData( | 146 static AppNotification* CreateNotificationFromSyncData( |
140 const SyncData& sync_data); | 147 const SyncData& sync_data); |
141 | 148 |
142 Profile* profile_; | 149 Profile* profile_; |
143 content::NotificationRegistrar registrar_; | 150 content::NotificationRegistrar registrar_; |
144 scoped_ptr<NotificationMap> notifications_; | 151 scoped_ptr<NotificationMap> notifications_; |
145 | 152 |
146 // This should only be used on the FILE thread. | 153 // This should only be used on the FILE thread. |
147 scoped_ptr<AppNotificationStorage> storage_; | 154 scoped_ptr<AppNotificationStorage> storage_; |
148 | 155 |
149 // Sync change processor we use to push all our changes. | 156 // Sync change processor we use to push all our changes. |
150 SyncChangeProcessor* sync_processor_; | 157 SyncChangeProcessor* sync_processor_; |
151 // Whether the sync model is associated with the local model. | 158 // Whether the sync model is associated with the local model. |
152 // In other words, whether we are ready to apply sync changes. | 159 // In other words, whether we are ready to apply sync changes. |
153 bool models_associated_; | 160 bool models_associated_; |
154 // Whether syncer changes are being processed right now. | 161 // Whether syncer changes are being processed right now. |
155 bool processing_syncer_changes_; | 162 bool processing_syncer_changes_; |
156 | 163 |
157 DISALLOW_COPY_AND_ASSIGN(AppNotificationManager); | 164 DISALLOW_COPY_AND_ASSIGN(AppNotificationManager); |
158 }; | 165 }; |
159 | 166 |
160 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_MANAGER_H_ | 167 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_MANAGER_H_ |
OLD | NEW |