Index: chrome/browser/notifications/sync_notifier/synced_notification_app_info_service.h |
diff --git a/chrome/browser/notifications/sync_notifier/synced_notification_app_info_service.h b/chrome/browser/notifications/sync_notifier/synced_notification_app_info_service.h |
index 4a1b19b98fe121f1190fafa53b569e8a392e24f2..39662990136ac86f00f6d59a61b51efe8222d0b9 100644 |
--- a/chrome/browser/notifications/sync_notifier/synced_notification_app_info_service.h |
+++ b/chrome/browser/notifications/sync_notifier/synced_notification_app_info_service.h |
@@ -24,6 +24,8 @@ class SyncedNotificationAppInfo; |
namespace notifier { |
+class ChromeNotifierService; |
+ |
// The SyncedNotificationAppInfoService contains and syncs AppInfo protobufs |
// from the server with metadata about the services sending synced |
// notifications. |
@@ -65,26 +67,52 @@ class SyncedNotificationAppInfoService : public syncer::SyncableService, |
void ProcessRemovedAppInfoProtobuf( |
const sync_pb::SyncedNotificationAppInfo& app_info); |
+ // When the bitmaps are all ready, tell ChromeNotifierService about changes. |
+ virtual void OnBitmapFetchesDone(std::vector<std::string> added_app_ids, |
+ std::vector<std::string> removed_app_ids); |
+ |
// Convert the protobuf to our internal format. |
- static scoped_ptr<SyncedNotificationAppInfo> |
+ scoped_ptr<SyncedNotificationAppInfo> |
CreateSyncedNotificationAppInfoFromProtobuf( |
const sync_pb::SyncedNotificationAppInfo& app_info); |
+ // Get the app info that contains this sending service name. |
+ SyncedNotificationAppInfo* FindSyncedNotificationAppInfoByName( |
+ const std::string& name); |
+ |
+ // Get the app info that contains this app id. |
+ SyncedNotificationAppInfo* FindSyncedNotificationAppInfoByAppId( |
+ const std::string& app_id); |
+ |
+ // Lookup the sending service name for a given app id. |
+ std::string FindSendingServiceNameFromAppId(const std::string app_id); |
+ |
+ // Return a list of all sending service names. |
+ std::vector<std::string> GetAllSendingServiceNames(); |
+ |
+ void set_chrome_notifier_service(ChromeNotifierService* notifier) { |
+ chrome_notifier_service_ = notifier; |
+ } |
+ |
// Functions for test. |
void AddForTest( |
scoped_ptr<notifier::SyncedNotificationAppInfo> sending_service_info) { |
Add(sending_service_info.Pass()); |
} |
+ // If we allow the tests to do bitmap fetching, they will attempt to fetch |
+ // a URL from the web, which will fail. We can already test the majority |
+ // of what we want without also trying to fetch bitmaps. Other tests will |
+ // cover bitmap fetching. |
+ static void set_avoid_bitmap_fetching_for_test(bool avoid) { |
+ avoid_bitmap_fetching_for_test_ = avoid; |
+ } |
+ |
private: |
// Add an app_info object to our list. This takes ownership of the pointer. |
void Add( |
scoped_ptr<notifier::SyncedNotificationAppInfo> sending_service_info); |
- // Get the app info that contains this ID. |
- SyncedNotificationAppInfo* FindSyncedNotificationAppInfoByName( |
- const std::string& name); |
- |
// Remove this app info. |
void FreeSyncedNotificationAppInfoByName(const std::string& name); |
@@ -102,6 +130,14 @@ class SyncedNotificationAppInfoService : public syncer::SyncableService, |
// Cache of the sync info. |
syncer::SyncData sync_data_; |
+ // Don't let unit tests try to hit the network. |
+ static bool avoid_bitmap_fetching_for_test_; |
+ |
+ // Pointer to the ChromeNotifierService. Its lifetime is controlled by the |
+ // ChromeNotifierService itself, which will zero out the pointer when it is |
+ // destroyed. |
+ ChromeNotifierService* chrome_notifier_service_; |
+ |
friend class SyncedNotificationAppInfoServiceTest; |
FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoServiceTest, |
MergeDataAndStartSyncingTest); |
@@ -112,6 +148,8 @@ class SyncedNotificationAppInfoService : public syncer::SyncableService, |
FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoServiceTest, |
FindSyncedNotificationAppInfoByNameTest); |
FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoServiceTest, |
+ FindSyncedNotificationAppInfoByNameTestTest); |
+ FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoServiceTest, |
FreeSyncedNotificationAppInfoByNameTest); |
FRIEND_TEST_ALL_PREFIXES(SyncedNotificationAppInfoServiceTest, |
CreateSyncedNotificationAppInfoFromProtobufTest); |