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

Side by Side Diff: sync/notifier/invalidation_notifier.h

Issue 10451060: sync: migrate invalidation state from syncable::Directory to InvalidationStorage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: include order Created 8 years, 6 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 // An implementation of SyncNotifier that wraps an invalidation 5 // An implementation of SyncNotifier that wraps an invalidation
6 // client. Handles the details of connecting to XMPP and hooking it 6 // client. Handles the details of connecting to XMPP and hooking it
7 // up to the invalidation client. 7 // up to the invalidation client.
8 // 8 //
9 // You probably don't want to use this directly; use 9 // You probably don't want to use this directly; use
10 // NonBlockingInvalidationNotifier. 10 // NonBlockingInvalidationNotifier.
11 11
12 #ifndef SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ 12 #ifndef SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_
13 #define SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ 13 #define SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_
14 #pragma once 14 #pragma once
15 15
16 #include <string> 16 #include <string>
17 17
18 #include "base/basictypes.h" 18 #include "base/basictypes.h"
19 #include "base/compiler_specific.h" 19 #include "base/compiler_specific.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/observer_list.h" 21 #include "base/observer_list.h"
22 #include "base/threading/non_thread_safe.h" 22 #include "base/threading/non_thread_safe.h"
23 #include "sync/notifier/chrome_invalidation_client.h" 23 #include "sync/notifier/chrome_invalidation_client.h"
24 #include "sync/notifier/invalidation_state_tracker.h" 24 #include "sync/notifier/invalidation_state_tracker.h"
25 #include "sync/notifier/state_writer.h"
26 #include "sync/notifier/sync_notifier.h" 25 #include "sync/notifier/sync_notifier.h"
27 #include "sync/syncable/model_type.h" 26 #include "sync/syncable/model_type.h"
28 #include "sync/util/weak_handle.h" 27 #include "sync/util/weak_handle.h"
29 28
30 namespace notifier { 29 namespace notifier {
31 class PushClient; 30 class PushClient;
32 } // namespace notifier 31 } // namespace notifier
33 32
34 namespace sync_notifier { 33 namespace sync_notifier {
35 34
36 // This class must live on the IO thread. 35 // This class must live on the IO thread.
37 class InvalidationNotifier 36 class InvalidationNotifier
38 : public SyncNotifier, 37 : public SyncNotifier,
39 public ChromeInvalidationClient::Listener, 38 public ChromeInvalidationClient::Listener {
40 public StateWriter {
41 public: 39 public:
42 // |invalidation_state_tracker| must be initialized. 40 // |invalidation_state_tracker| must be initialized.
43 InvalidationNotifier( 41 InvalidationNotifier(
44 scoped_ptr<notifier::PushClient> push_client, 42 scoped_ptr<notifier::PushClient> push_client,
45 const InvalidationVersionMap& initial_max_invalidation_versions, 43 const InvalidationVersionMap& initial_max_invalidation_versions,
44 const std::string& initial_invalidation_state,
46 const browser_sync::WeakHandle<InvalidationStateTracker>& 45 const browser_sync::WeakHandle<InvalidationStateTracker>&
47 invalidation_state_tracker, 46 invalidation_state_tracker,
48 const std::string& client_info); 47 const std::string& client_info);
49 48
50 virtual ~InvalidationNotifier(); 49 virtual ~InvalidationNotifier();
51 50
52 // SyncNotifier implementation. 51 // SyncNotifier implementation.
53 virtual void AddObserver(SyncNotifierObserver* observer) OVERRIDE; 52 virtual void AddObserver(SyncNotifierObserver* observer) OVERRIDE;
54 virtual void RemoveObserver(SyncNotifierObserver* observer) OVERRIDE; 53 virtual void RemoveObserver(SyncNotifierObserver* observer) OVERRIDE;
55 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; 54 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE;
56 virtual void SetState(const std::string& state) OVERRIDE; 55 virtual void SetStateDeprecated(const std::string& state) OVERRIDE;
57 virtual void UpdateCredentials( 56 virtual void UpdateCredentials(
58 const std::string& email, const std::string& token) OVERRIDE; 57 const std::string& email, const std::string& token) OVERRIDE;
59 virtual void UpdateEnabledTypes( 58 virtual void UpdateEnabledTypes(
60 syncable::ModelTypeSet enabled_types) OVERRIDE; 59 syncable::ModelTypeSet enabled_types) OVERRIDE;
61 virtual void SendNotification( 60 virtual void SendNotification(
62 syncable::ModelTypeSet changed_types) OVERRIDE; 61 syncable::ModelTypeSet changed_types) OVERRIDE;
63 62
64 // ChromeInvalidationClient::Listener implementation. 63 // ChromeInvalidationClient::Listener implementation.
65 virtual void OnInvalidate( 64 virtual void OnInvalidate(
66 const syncable::ModelTypePayloadMap& type_payloads) OVERRIDE; 65 const syncable::ModelTypePayloadMap& type_payloads) OVERRIDE;
67 virtual void OnSessionStatusChanged(bool has_session) OVERRIDE; 66 virtual void OnSessionStatusChanged(bool has_session) OVERRIDE;
68 67
69 // StateWriter implementation.
70 virtual void WriteState(const std::string& state) OVERRIDE;
71
72 private: 68 private:
73 base::NonThreadSafe non_thread_safe_; 69 base::NonThreadSafe non_thread_safe_;
74 70
75 // We start off in the STOPPED state. When we get our initial 71 // We start off in the STOPPED state. When we get our initial
76 // credentials, we connect and move to the CONNECTING state. When 72 // credentials, we connect and move to the CONNECTING state. When
77 // we're connected we start the invalidation client and move to the 73 // we're connected we start the invalidation client and move to the
78 // STARTED state. We never go back to a previous state. 74 // STARTED state. We never go back to a previous state.
79 enum State { 75 enum State {
80 STOPPED, 76 STOPPED,
81 CONNECTING, 77 CONNECTING,
(...skipping 11 matching lines...) Expand all
93 // Passed to |invalidation_client_|. 89 // Passed to |invalidation_client_|.
94 const std::string client_info_; 90 const std::string client_info_;
95 91
96 // Our observers (which must live on the same thread). 92 // Our observers (which must live on the same thread).
97 ObserverList<SyncNotifierObserver> observers_; 93 ObserverList<SyncNotifierObserver> observers_;
98 94
99 // The client ID to pass to |chrome_invalidation_client_|. 95 // The client ID to pass to |chrome_invalidation_client_|.
100 std::string invalidation_client_id_; 96 std::string invalidation_client_id_;
101 97
102 // The state to pass to |chrome_invalidation_client_|. 98 // The state to pass to |chrome_invalidation_client_|.
99 // TODO(tim): This should be made const once migration is completed for bug
100 // 124140.
103 std::string invalidation_state_; 101 std::string invalidation_state_;
104 102
105 // The invalidation client. 103 // The invalidation client.
106 ChromeInvalidationClient invalidation_client_; 104 ChromeInvalidationClient invalidation_client_;
107 105
108 DISALLOW_COPY_AND_ASSIGN(InvalidationNotifier); 106 DISALLOW_COPY_AND_ASSIGN(InvalidationNotifier);
109 }; 107 };
110 108
111 } // namespace sync_notifier 109 } // namespace sync_notifier
112 110
113 #endif // SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ 111 #endif // SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_
OLDNEW
« no previous file with comments | « sync/notifier/chrome_invalidation_client_unittest.cc ('k') | sync/notifier/invalidation_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698