OLD | NEW |
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 "jingle/notifier/base/notifier_options.h" | 23 #include "jingle/notifier/base/notifier_options.h" |
24 #include "jingle/notifier/communicator/login.h" | 24 #include "jingle/notifier/communicator/login.h" |
25 #include "sync/notifier/chrome_invalidation_client.h" | 25 #include "sync/notifier/chrome_invalidation_client.h" |
26 #include "sync/notifier/invalidation_version_tracker.h" | 26 #include "sync/notifier/invalidation_state_tracker.h" |
27 #include "sync/notifier/state_writer.h" | 27 #include "sync/notifier/state_writer.h" |
28 #include "sync/notifier/sync_notifier.h" | 28 #include "sync/notifier/sync_notifier.h" |
29 #include "sync/syncable/model_type.h" | 29 #include "sync/syncable/model_type.h" |
30 #include "sync/util/weak_handle.h" | 30 #include "sync/util/weak_handle.h" |
31 | 31 |
32 namespace sync_notifier { | 32 namespace sync_notifier { |
33 | 33 |
34 // This class must live on the IO thread. | 34 // This class must live on the IO thread. |
35 class InvalidationNotifier | 35 class InvalidationNotifier |
36 : public SyncNotifier, | 36 : public SyncNotifier, |
37 public notifier::LoginDelegate, | 37 public notifier::LoginDelegate, |
38 public ChromeInvalidationClient::Listener, | 38 public ChromeInvalidationClient::Listener, |
39 public StateWriter { | 39 public StateWriter { |
40 public: | 40 public: |
41 // |invalidation_version_tracker| must be initialized. | 41 // |invalidation_state_tracker| must be initialized. |
42 InvalidationNotifier( | 42 InvalidationNotifier( |
43 const notifier::NotifierOptions& notifier_options, | 43 const notifier::NotifierOptions& notifier_options, |
44 const InvalidationVersionMap& initial_max_invalidation_versions, | 44 const InvalidationVersionMap& initial_max_invalidation_versions, |
45 const browser_sync::WeakHandle<InvalidationVersionTracker>& | 45 const browser_sync::WeakHandle<InvalidationStateTracker>& |
46 invalidation_version_tracker, | 46 invalidation_state_tracker, |
47 const std::string& client_info); | 47 const std::string& client_info); |
48 | 48 |
49 virtual ~InvalidationNotifier(); | 49 virtual ~InvalidationNotifier(); |
50 | 50 |
51 // SyncNotifier implementation. | 51 // SyncNotifier implementation. |
52 virtual void AddObserver(SyncNotifierObserver* observer) OVERRIDE; | 52 virtual void AddObserver(SyncNotifierObserver* observer) OVERRIDE; |
53 virtual void RemoveObserver(SyncNotifierObserver* observer) OVERRIDE; | 53 virtual void RemoveObserver(SyncNotifierObserver* observer) OVERRIDE; |
54 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; | 54 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; |
55 virtual void SetState(const std::string& state) OVERRIDE; | 55 virtual void SetState(const std::string& state) OVERRIDE; |
56 virtual void UpdateCredentials( | 56 virtual void UpdateCredentials( |
(...skipping 30 matching lines...) Expand all Loading... |
87 }; | 87 }; |
88 State state_; | 88 State state_; |
89 | 89 |
90 // Used to build parameters for |login_|. | 90 // Used to build parameters for |login_|. |
91 const notifier::NotifierOptions notifier_options_; | 91 const notifier::NotifierOptions notifier_options_; |
92 | 92 |
93 // Passed to |invalidation_client_|. | 93 // Passed to |invalidation_client_|. |
94 const InvalidationVersionMap initial_max_invalidation_versions_; | 94 const InvalidationVersionMap initial_max_invalidation_versions_; |
95 | 95 |
96 // Passed to |invalidation_client_|. | 96 // Passed to |invalidation_client_|. |
97 const browser_sync::WeakHandle<InvalidationVersionTracker> | 97 const browser_sync::WeakHandle<InvalidationStateTracker> |
98 invalidation_version_tracker_; | 98 invalidation_state_tracker_; |
99 | 99 |
100 // Passed to |invalidation_client_|. | 100 // Passed to |invalidation_client_|. |
101 const std::string client_info_; | 101 const std::string client_info_; |
102 | 102 |
103 // Our observers (which must live on the same thread). | 103 // Our observers (which must live on the same thread). |
104 ObserverList<SyncNotifierObserver> observers_; | 104 ObserverList<SyncNotifierObserver> observers_; |
105 | 105 |
106 // The client ID to pass to |chrome_invalidation_client_|. | 106 // The client ID to pass to |chrome_invalidation_client_|. |
107 std::string invalidation_client_id_; | 107 std::string invalidation_client_id_; |
108 | 108 |
109 // The state to pass to |chrome_invalidation_client_|. | 109 // The state to pass to |chrome_invalidation_client_|. |
110 std::string invalidation_state_; | 110 std::string invalidation_state_; |
111 | 111 |
112 // The XMPP connection manager. | 112 // The XMPP connection manager. |
113 scoped_ptr<notifier::Login> login_; | 113 scoped_ptr<notifier::Login> login_; |
114 | 114 |
115 // The invalidation client. | 115 // The invalidation client. |
116 ChromeInvalidationClient invalidation_client_; | 116 ChromeInvalidationClient invalidation_client_; |
117 | 117 |
118 DISALLOW_COPY_AND_ASSIGN(InvalidationNotifier); | 118 DISALLOW_COPY_AND_ASSIGN(InvalidationNotifier); |
119 }; | 119 }; |
120 | 120 |
121 } // namespace sync_notifier | 121 } // namespace sync_notifier |
122 | 122 |
123 #endif // SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ | 123 #endif // SYNC_NOTIFIER_INVALIDATION_NOTIFIER_H_ |
OLD | NEW |