Chromium Code Reviews| Index: chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h |
| diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h b/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3f2d5433f1ad70a3c6ab8f8b8a3bba63b41477f4 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h |
| @@ -0,0 +1,67 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_INVALIDATION_HANDLER_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_INVALIDATION_HANDLER_H_ |
| + |
| +#include <set> |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/compiler_specific.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_mapper.h" |
| +#include "sync/notifier/sync_notifier_observer.h" |
| + |
| +class InvalidationService; |
| + |
| +namespace extensions { |
| + |
| +class PushMessagingInvalidationHandlerObserver; |
| + |
| +// This class maps extension IDs to the corresponding object IDs, manages |
| +// invalidation registrations, and dispatches callbacks for any invalidations |
| +// received. |
| +class PushMessagingInvalidationHandler : public PushMessagingInvalidationMapper, |
| + public syncer::SyncNotifierObserver { |
| + public: |
| + // |service| and |observer| must remain valid for the lifetime of this object. |
| + // |extension_ids| is the set of extension IDs for which push messaging is |
| + // enabled. |
| + PushMessagingInvalidationHandler( |
| + InvalidationService* service, |
| + PushMessagingInvalidationHandlerObserver* observer, |
| + const std::set<std::string>& extension_ids); |
| + virtual ~PushMessagingInvalidationHandler(); |
| + |
| + // PushMessagingInvalidationMapper implementation. |
|
Munjal (Google)
2012/08/20 19:26:00
Make these methods private/protected to reduce the
akalin
2012/08/20 20:35:01
I think the current best practice is to not bother
dcheng
2012/08/20 20:58:21
Opted to leave it the same. Eliminates FRIEND_TEST
|
| + virtual void RegisterExtension(const std::string& extension_id) OVERRIDE; |
| + virtual void UnregisterExtension(const std::string& extension_id) OVERRIDE; |
| + |
| + // SyncNotifierObserver implementation. |
|
Munjal (Google)
2012/08/20 19:26:00
Make these methods private/protected to reduce the
akalin
2012/08/20 20:35:01
same as above.
dcheng
2012/08/20 20:58:21
Ditto.
|
| + virtual void OnNotificationsEnabled() OVERRIDE; |
| + virtual void OnNotificationsDisabled( |
| + syncer::NotificationsDisabledReason reason) OVERRIDE; |
| + virtual void OnIncomingNotification( |
| + const syncer::ObjectIdPayloadMap& id_payloads, |
| + syncer::IncomingNotificationSource source) OVERRIDE; |
| + |
| + const std::set<std::string>& GetRegisteredExtensionsForTest() const { |
| + return registered_extensions_; |
| + } |
| + |
| + private: |
| + void UpdateRegistrations(); |
| + |
| + base::ThreadChecker thread_checker_; |
| + InvalidationService* service_; |
|
akalin
2012/08/20 20:35:01
const pointer?
dcheng
2012/08/20 20:58:21
Done.
|
| + std::set<std::string> registered_extensions_; |
| + PushMessagingInvalidationHandlerObserver* observer_; |
|
akalin
2012/08/20 20:35:01
const pointer?
dcheng
2012/08/20 20:58:21
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(PushMessagingInvalidationHandler); |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_PUSH_MESSAGING_INVALIDATION_HANDLER_H_ |