Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Side by Side Diff: chrome/browser/sync/invalidation_frontend.h

Issue 10916131: [Invalidations] Add GetInvalidatorState() to Invalidator{,Frontend} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix android Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SYNC_INVALIDATION_FRONTEND_H_ 5 #ifndef CHROME_BROWSER_SYNC_INVALIDATION_FRONTEND_H_
6 #define CHROME_BROWSER_SYNC_INVALIDATION_FRONTEND_H_ 6 #define CHROME_BROWSER_SYNC_INVALIDATION_FRONTEND_H_
7 7
8 #include "sync/notifier/invalidation_util.h" 8 #include "sync/notifier/invalidation_util.h"
9 9
10 namespace syncer { 10 namespace syncer {
11 class InvalidationHandler; 11 class InvalidationHandler;
12 } // namespace syncer 12 } // namespace syncer
13 13
14 // Interface for classes that handle invalidation registrations and send out 14 // Interface for classes that handle invalidation registrations and send out
15 // invalidations to register handlers. 15 // invalidations to register handlers.
16 //
17 // Invalidation clients should follow the pattern below:
18 //
19 // When starting the client:
20 //
21 // frontend->RegisterInvalidationHandler(client_handler);
22 //
23 // When the set of IDs to register changes for the client during its lifetime
24 // (i.e., between calls to RegisterInvalidationHandler(client_handler) and
25 // UnregisterInvalidationHandler(client_handler):
26 //
27 // frontend->UpdateRegisteredInvalidationIds(client_handler, client_ids);
28 //
29 // When shutting down the client for browser shutdown:
30 //
31 // frontend->UnregisterInvalidationHandler(client_handler);
32 //
33 // Note that there's no call to UpdateRegisteredIds() -- this is because the
34 // invalidation API persists registrations across browser restarts.
35 //
36 // When permanently shutting down the client, e.g. when disabling the related
37 // feature:
38 //
39 // frontend->UpdateRegisteredInvalidationIds(client_handler, ObjectIdSet());
40 // frontend->UnregisterInvalidationHandler(client_handler);
41 //
42 // If an invalidation handler cares about the invalidator state, it should also
43 // do the following when starting the client:
44 //
45 // invalidator_state = frontend->GetInvalidatorState();
46 //
47 // It can also do the above in OnInvalidatorStateChange(), or it can use the
48 // argument to OnInvalidatorStateChange().
49 //
50 // NOTE(akalin): Invalidations that come in during browser shutdown may get
51 // dropped. This won't matter once we have an Acknowledge API, though: see
52 // http://crbug.com/78462 and http://crbug.com/124149.
16 class InvalidationFrontend { 53 class InvalidationFrontend {
17 public: 54 public:
18 // Starts sending notifications to |handler|. |handler| must not be NULL, 55 // Starts sending notifications to |handler|. |handler| must not be NULL,
19 // and it must not already be registered. 56 // and it must not already be registered.
20 // 57 //
21 // Handler registrations are persisted across restarts of sync. 58 // Handler registrations are persisted across restarts of sync.
22 virtual void RegisterInvalidationHandler( 59 virtual void RegisterInvalidationHandler(
23 syncer::InvalidationHandler* handler) = 0; 60 syncer::InvalidationHandler* handler) = 0;
24 61
25 // Updates the set of ObjectIds associated with |handler|. |handler| must 62 // Updates the set of ObjectIds associated with |handler|. |handler| must
26 // not be NULL, and must already be registered. An ID must be registered for 63 // not be NULL, and must already be registered. An ID must be registered for
27 // at most one handler. 64 // at most one handler.
28 // 65 //
29 // Registered IDs are persisted across restarts of sync. 66 // Registered IDs are persisted across restarts of sync.
30 virtual void UpdateRegisteredInvalidationIds( 67 virtual void UpdateRegisteredInvalidationIds(
31 syncer::InvalidationHandler* handler, 68 syncer::InvalidationHandler* handler,
32 const syncer::ObjectIdSet& ids) = 0; 69 const syncer::ObjectIdSet& ids) = 0;
33 70
34 // Stops sending notifications to |handler|. |handler| must not be NULL, and 71 // Stops sending notifications to |handler|. |handler| must not be NULL, and
35 // it must already be registered. Note that this doesn't unregister the IDs 72 // it must already be registered. Note that this doesn't unregister the IDs
36 // associated with |handler|. 73 // associated with |handler|.
37 // 74 //
38 // Handler registrations are persisted across restarts of sync. 75 // Handler registrations are persisted across restarts of sync.
39 virtual void UnregisterInvalidationHandler( 76 virtual void UnregisterInvalidationHandler(
40 syncer::InvalidationHandler* handler) = 0; 77 syncer::InvalidationHandler* handler) = 0;
41 78
79 // Returns the current invalidator state. When called from within
80 // InvalidationHandler::OnInvalidatorStateChange(), this must return
81 // the updated state.
82 virtual syncer::InvalidatorState GetInvalidatorState() const = 0;
83
42 protected: 84 protected:
43 virtual ~InvalidationFrontend() { } 85 virtual ~InvalidationFrontend() { }
44 }; 86 };
45 87
46 #endif // CHROME_BROWSER_SYNC_INVALIDATION_FRONTEND_H_ 88 #endif // CHROME_BROWSER_SYNC_INVALIDATION_FRONTEND_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host_unittest.cc ('k') | chrome/browser/sync/profile_sync_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698