Chromium Code Reviews| Index: sync/notifier/sync_notifier_helper.h |
| diff --git a/sync/notifier/sync_notifier_helper.h b/sync/notifier/sync_notifier_helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..659354f3f98ebb227a9d6fdc93c2330e47ae6e62 |
| --- /dev/null |
| +++ b/sync/notifier/sync_notifier_helper.h |
| @@ -0,0 +1,51 @@ |
| +// 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 SYNC_NOTIFIER_SYNC_NOTIFIER_HELPER_H_ |
| +#define SYNC_NOTIFIER_SYNC_NOTIFIER_HELPER_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/observer_list.h" |
| +#include "sync/notifier/invalidation_util.h" |
| +#include "sync/notifier/object_id_payload_map.h" |
| +#include "sync/notifier/sync_notifier_observer.h" |
| + |
| +namespace syncer { |
| + |
| +class SyncNotifierHelper { |
|
akalin
2012/07/19 00:42:07
class-level comment
dcheng
2012/07/19 18:31:05
Done.
|
| + public: |
| + SyncNotifierHelper(); |
| + virtual ~SyncNotifierHelper(); |
|
akalin
2012/07/19 00:42:07
doesn't need to be virtual
dcheng
2012/07/19 18:31:05
Leftover from an earlier patch. We don't need it a
|
| + |
| + // Updates the list of ObjectIds associated with a given |handler|. Passing an |
| + // empty ObjectIdSet will unregister |handler|; any other value is an implicit |
| + // registration. The return value is an ObjectIdSet containing all currently |
| + // registered values. |
|
akalin
2012/07/19 00:42:07
was momentarily confused -- maybe '...values.' ->
akalin
2012/07/19 00:42:07
Specify that at most one handler can handle a give
dcheng
2012/07/19 18:31:05
Done.
dcheng
2012/07/19 18:31:05
Done.
|
| + ObjectIdSet UpdateRegisteredIds(SyncNotifierObserver* handler, |
| + const ObjectIdSet& ids); |
| + |
| + // Helper that sorts incoming invalidations into a bucket for each handler |
| + // and then dispatches the batched invalidations to the corresponding handler. |
| + void DispatchInvalidationsToHandlers(const ObjectIdPayloadMap& id_payloads, |
| + IncomingNotificationSource source); |
| + |
| + // Note that this is non-const because FOR_EACH_OBSERVER() may mutate the |
|
akalin
2012/07/19 00:42:07
Would rather replace this accessor with functions
dcheng
2012/07/19 18:31:05
Done.
|
| + // original observer list. |
| + ObserverList<SyncNotifierObserver>* handlers() { return &handlers_; } |
| + |
| + private: |
| + typedef std::map<invalidation::ObjectId, |
| + SyncNotifierObserver*, |
| + ObjectIdLessThan> ObjectIdObserverMap; |
| + ObserverList<SyncNotifierObserver> handlers_; |
| + ObjectIdObserverMap id_to_handler_map_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SyncNotifierHelper); |
| +}; |
| + |
| +} // namespace syncer |
| + |
| +#endif // SYNC_NOTIFIER_SYNC_NOTIFIER_HELPER_H_ |