Chromium Code Reviews| 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..4eaf3d333a2e3dd7928a209f33f56aa3d5086c83 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); |
|
dewittj
2014/03/17 21:43:43
This method signature is really confusing to me.
Pete Williamson
2014/03/21 01:22:31
Nothing, other than we need to wait until the bitm
|
| + |
| // 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 SetChromeNotifierService(ChromeNotifierService* notifier) { |
|
dewittj
2014/03/17 21:43:43
nit: set_chrome_notifier_service
Pete Williamson
2014/03/21 01:22:31
Done.
|
| + 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_; |
|
dewittj
2014/03/17 21:43:43
possibly a weak pointer is appropriate here?
Pete Williamson
2014/03/21 01:22:31
We could do that, but I'm not sure the extra compl
|
| + |
| 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); |