diff options
author | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 21:44:44 +0000 |
---|---|---|
committer | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 21:44:44 +0000 |
commit | 5a1ad5c1ba4c5b9e86805e1c6fb7364492d6ac80 (patch) | |
tree | 471ff33ec7c19913601fc03dfaf63de606c21022 /chrome/browser/extensions/app_notification_manager.h | |
parent | 0b5781a63246fb4abf31f871b445a6d85970b19f (diff) | |
download | chromium_src-5a1ad5c1ba4c5b9e86805e1c6fb7364492d6ac80.zip chromium_src-5a1ad5c1ba4c5b9e86805e1c6fb7364492d6ac80.tar.gz chromium_src-5a1ad5c1ba4c5b9e86805e1c6fb7364492d6ac80.tar.bz2 |
Revert 106110 - Implement SyncableService in AppNotificationsManager:
- Implement all methods of SyncableService
- Modify existing methods that change the model (Add and ClearAll) to push changes to sync.
- Add some extra properties to AppNotification: guid and extension id
- Disallow operations on model until storage is loaded.
- Ton of unit tests for sync methods
There is anotehr part for the full notifications sync to work that will be done in a separate CL.
Review URL: http://codereview.chromium.org/8263002
TBR=munjal@chromium.org
Review URL: http://codereview.chromium.org/8345022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106136 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/app_notification_manager.h')
-rw-r--r-- | chrome/browser/extensions/app_notification_manager.h | 97 |
1 files changed, 8 insertions, 89 deletions
diff --git a/chrome/browser/extensions/app_notification_manager.h b/chrome/browser/extensions/app_notification_manager.h index 7c37cc7..8148a08 100644 --- a/chrome/browser/extensions/app_notification_manager.h +++ b/chrome/browser/extensions/app_notification_manager.h @@ -9,15 +9,10 @@ #include <map> #include "base/compiler_specific.h" -#include "base/gtest_prod_util.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/synchronization/waitable_event.h" #include "chrome/browser/extensions/app_notification.h" #include "chrome/browser/extensions/app_notification_storage.h" -#include "chrome/browser/sync/api/sync_change.h" -#include "chrome/browser/sync/api/syncable_service.h" -#include "content/common/notification_details.h" #include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" @@ -26,20 +21,17 @@ class Profile; // This class keeps track of notifications for installed apps. class AppNotificationManager : public base::RefCountedThreadSafe<AppNotificationManager>, - public NotificationObserver, - public SyncableService { + public NotificationObserver { public: explicit AppNotificationManager(Profile* profile); - virtual ~AppNotificationManager(); // Starts up the process of reading from persistent storage. void Init(); - // Returns whether add was succcessful. - // Takes ownership of |item| in all cases. - bool Add(AppNotification* item); + // Takes ownership of |notification|. + void Add(const std::string& extension_id, AppNotification* item); - const AppNotificationList* GetAll(const std::string& extension_id) const; + const AppNotificationList* GetAll(const std::string& extension_id); // Returns the most recently added notification for |extension_id| if there // are any, or NULL otherwise. @@ -53,105 +45,32 @@ class AppNotificationManager const NotificationSource& source, const NotificationDetails& details) OVERRIDE; - bool loaded() const { return notifications_.get() != NULL; } - - // SyncableService implementation. - - // Returns all syncable notifications from this model as SyncData. - virtual SyncDataList GetAllSyncData(syncable::ModelType type) const OVERRIDE; - // Process notifications related changes from Sync, merging them into - // our model. - virtual SyncError ProcessSyncChanges( - const tracked_objects::Location& from_here, - const SyncChangeList& change_list) OVERRIDE; - // Associate and merge sync data model with our data model. - virtual SyncError MergeDataAndStartSyncing( - syncable::ModelType type, - const SyncDataList& initial_sync_data, - SyncChangeProcessor* sync_processor) OVERRIDE; - virtual void StopSyncing(syncable::ModelType type) OVERRIDE; - private: - friend class AppNotificationManagerSyncTest; - FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, - NotificationToSyncDataToNotification); - FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, - GetAllSyncDataNoLocal); - FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, - GetAllSyncDataSomeLocal); - FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, - ModelAssocModelEmpty); - FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, - ModelAssocBothNonEmptyNoOverlap); - FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, - ModelAssocBothNonEmptySomeOverlap); - FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, - ModelAssocBothNonEmptyTitleMismatch); - FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, - ModelAssocBothNonEmptyMatchesLocal); - FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, - ProcessSyncChangesErrorModelAssocNotDone); - FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, - ProcessSyncChangesEmptyModel); - FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, - StopSyncing); - FRIEND_TEST_ALL_PREFIXES(AppNotificationManagerSyncTest, - ClearAllGetsSynced); - friend class base::RefCountedThreadSafe<AppNotificationManager>; // Maps extension id to a list of notifications for that extension. typedef std::map<std::string, AppNotificationList> NotificationMap; + virtual ~AppNotificationManager(); + // Starts loading storage_ using |storage_path|. void LoadOnFileThread(const FilePath& storage_path); // Called on the UI thread to handle the loaded results from storage_. - void HandleLoadResults(NotificationMap* map); + void HandleLoadResults(const NotificationMap& map); void SaveOnFileThread(const std::string& extension_id, const AppNotificationList& list); void DeleteOnFileThread(const std::string& extension_id); - // Gets notficiations for a given extension id. - AppNotificationList& GetAllInternal(const std::string& extension_id); - - // Removes the notification with given extension id and given guid. - void Remove(const std::string& extension_id, const std::string& guid); - - // Returns the notification for the given |extension_id| and |guid|, - // NULL if no such notification exists. - const AppNotification* GetNotification(const std::string& extension_id, - const std::string& guid); - - // Sends a change to syncer to add the given notification. - void SyncAddChange(const AppNotification& notif); - - // Sends changes to syncer to remove all notifications in the given list. - void SyncClearAllChange(const AppNotificationList& list); - - // Converters from AppNotification to SyncData and vice versa. - static SyncData CreateSyncDataFromNotification( - const AppNotification& notification); - static AppNotification* CreateNotificationFromSyncData( - const SyncData& sync_data); - Profile* profile_; NotificationRegistrar registrar_; - scoped_ptr<NotificationMap> notifications_; + NotificationMap notifications_; // This should only be used on the FILE thread. scoped_ptr<AppNotificationStorage> storage_; - // Sync change processor we use to push all our changes. - SyncChangeProcessor* sync_processor_; - // Whether the sync model is associated with the local model. - // In other words, whether we are ready to apply sync changes. - bool models_associated_; - // Whether syncer changes are being processed right now. - bool processing_syncer_changes_; - DISALLOW_COPY_AND_ASSIGN(AppNotificationManager); }; |