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

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

Issue 8567018: Limit number of notifications that can be received by the client. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
OLDNEW
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
(...skipping 11 matching lines...) Expand all
22 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
23 23
24 class Profile; 24 class Profile;
25 25
26 // This class keeps track of notifications for installed apps. 26 // This class keeps track of notifications for installed apps.
27 class AppNotificationManager 27 class AppNotificationManager
28 : public base::RefCountedThreadSafe<AppNotificationManager>, 28 : public base::RefCountedThreadSafe<AppNotificationManager>,
29 public content::NotificationObserver, 29 public content::NotificationObserver,
30 public SyncableService { 30 public SyncableService {
31 public: 31 public:
32 static const unsigned int kMaxNotificationPerApp;
32 explicit AppNotificationManager(Profile* profile); 33 explicit AppNotificationManager(Profile* profile);
33 virtual ~AppNotificationManager(); 34 virtual ~AppNotificationManager();
34 35
35 // Starts up the process of reading from persistent storage. 36 // Starts up the process of reading from persistent storage.
36 void Init(); 37 void Init();
37 38
38 // Returns whether add was succcessful. 39 // Returns whether add was succcessful.
39 // Takes ownership of |item| in all cases. 40 // Takes ownership of |item| in all cases.
40 bool Add(AppNotification* item); 41 bool Add(AppNotification* item);
41 42
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 void Remove(const std::string& extension_id, const std::string& guid); 124 void Remove(const std::string& extension_id, const std::string& guid);
124 125
125 // Returns the notification for the given |extension_id| and |guid|, 126 // Returns the notification for the given |extension_id| and |guid|,
126 // NULL if no such notification exists. 127 // NULL if no such notification exists.
127 const AppNotification* GetNotification(const std::string& extension_id, 128 const AppNotification* GetNotification(const std::string& extension_id,
128 const std::string& guid); 129 const std::string& guid);
129 130
130 // Sends a change to syncer to add the given notification. 131 // Sends a change to syncer to add the given notification.
131 void SyncAddChange(const AppNotification& notif); 132 void SyncAddChange(const AppNotification& notif);
132 133
134 // Sends a change to syncer to remove the given notification.
135 void SyncRemoveChange(const AppNotification& notif);
136
133 // Sends changes to syncer to remove all notifications in the given list. 137 // Sends changes to syncer to remove all notifications in the given list.
134 void SyncClearAllChange(const AppNotificationList& list); 138 void SyncClearAllChange(const AppNotificationList& list);
135 139
136 // Converters from AppNotification to SyncData and vice versa. 140 // Converters from AppNotification to SyncData and vice versa.
137 static SyncData CreateSyncDataFromNotification( 141 static SyncData CreateSyncDataFromNotification(
138 const AppNotification& notification); 142 const AppNotification& notification);
139 static AppNotification* CreateNotificationFromSyncData( 143 static AppNotification* CreateNotificationFromSyncData(
140 const SyncData& sync_data); 144 const SyncData& sync_data);
141 145
142 Profile* profile_; 146 Profile* profile_;
143 content::NotificationRegistrar registrar_; 147 content::NotificationRegistrar registrar_;
144 scoped_ptr<NotificationMap> notifications_; 148 scoped_ptr<NotificationMap> notifications_;
145 149
146 // This should only be used on the FILE thread. 150 // This should only be used on the FILE thread.
147 scoped_ptr<AppNotificationStorage> storage_; 151 scoped_ptr<AppNotificationStorage> storage_;
148 152
149 // Sync change processor we use to push all our changes. 153 // Sync change processor we use to push all our changes.
150 SyncChangeProcessor* sync_processor_; 154 SyncChangeProcessor* sync_processor_;
151 // Whether the sync model is associated with the local model. 155 // Whether the sync model is associated with the local model.
152 // In other words, whether we are ready to apply sync changes. 156 // In other words, whether we are ready to apply sync changes.
153 bool models_associated_; 157 bool models_associated_;
154 // Whether syncer changes are being processed right now. 158 // Whether syncer changes are being processed right now.
155 bool processing_syncer_changes_; 159 bool processing_syncer_changes_;
156 160
157 DISALLOW_COPY_AND_ASSIGN(AppNotificationManager); 161 DISALLOW_COPY_AND_ASSIGN(AppNotificationManager);
158 }; 162 };
159 163
160 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_MANAGER_H_ 164 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_notification.cc ('k') | chrome/browser/extensions/app_notification_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698