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

Side by Side Diff: components/invalidation/p2p_invalidator.h

Issue 294123004: Move some sync/notifier to components/invalidation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 invalidator that uses p2p invalidations based on XMPP push 5 // An invalidator that uses p2p invalidations based on XMPP push
6 // notifications. Used only for sync integration tests. 6 // notifications. Used only for sync integration tests.
7 7
8 #ifndef SYNC_NOTIFIER_P2P_INVALIDATOR_H_ 8 #ifndef COMPONENTS_INVALIDATION_P2P_INVALIDATOR_H_
9 #define SYNC_NOTIFIER_P2P_INVALIDATOR_H_ 9 #define COMPONENTS_INVALIDATION_P2P_INVALIDATOR_H_
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h" 17 #include "base/observer_list.h"
18 #include "base/threading/thread_checker.h" 18 #include "base/threading/thread_checker.h"
19 #include "components/invalidation/invalidation_export.h"
20 #include "components/invalidation/invalidator_registrar.h"
19 #include "jingle/notifier/base/notifier_options.h" 21 #include "jingle/notifier/base/notifier_options.h"
20 #include "jingle/notifier/listener/push_client.h" 22 #include "jingle/notifier/listener/push_client.h"
21 #include "jingle/notifier/listener/push_client_observer.h" 23 #include "jingle/notifier/listener/push_client_observer.h"
22 #include "sync/base/sync_export.h" 24 #include "sync/internal_api/public/base/invalidator_state.h"
23 #include "sync/internal_api/public/base/model_type.h" 25 #include "sync/internal_api/public/base/model_type.h"
24 #include "sync/notifier/invalidator.h" 26 #include "sync/notifier/invalidator.h"
25 #include "sync/notifier/invalidator_registrar.h"
26 #include "sync/notifier/invalidator_state.h"
27 #include "sync/notifier/object_id_invalidation_map.h" 27 #include "sync/notifier/object_id_invalidation_map.h"
28 28
29 namespace notifier { 29 namespace notifier {
30 class PushClient; 30 class PushClient;
31 } // namespace notifier 31 } // namespace notifier
32 32
33 namespace syncer { 33 namespace syncer {
34 34
35 // The channel to use for sync notifications. 35 // The channel to use for sync notifications.
36 SYNC_EXPORT extern const char kSyncP2PNotificationChannel[]; 36 INVALIDATION_EXPORT extern const char kSyncP2PNotificationChannel[];
37 37
38 // The intended recipient(s) of a P2P notification. 38 // The intended recipient(s) of a P2P notification.
39 enum P2PNotificationTarget { 39 enum P2PNotificationTarget {
40 NOTIFY_SELF, 40 NOTIFY_SELF,
41 FIRST_NOTIFICATION_TARGET = NOTIFY_SELF, 41 FIRST_NOTIFICATION_TARGET = NOTIFY_SELF,
42 NOTIFY_OTHERS, 42 NOTIFY_OTHERS,
43 NOTIFY_ALL, 43 NOTIFY_ALL,
44 LAST_NOTIFICATION_TARGET = NOTIFY_ALL 44 LAST_NOTIFICATION_TARGET = NOTIFY_ALL
45 }; 45 };
46 46
47 SYNC_EXPORT_PRIVATE std::string P2PNotificationTargetToString( 47 INVALIDATION_EXPORT_PRIVATE std::string P2PNotificationTargetToString(
48 P2PNotificationTarget target); 48 P2PNotificationTarget target);
49 49
50 // If |target_str| can't be parsed, assumes NOTIFY_SELF. 50 // If |target_str| can't be parsed, assumes NOTIFY_SELF.
51 SYNC_EXPORT_PRIVATE P2PNotificationTarget P2PNotificationTargetFromString( 51 INVALIDATION_EXPORT_PRIVATE P2PNotificationTarget
52 const std::string& target_str); 52 P2PNotificationTargetFromString(const std::string& target_str);
53 53
54 // Helper notification data class that can be serialized to and 54 // Helper notification data class that can be serialized to and
55 // deserialized from a string. 55 // deserialized from a string.
56 class SYNC_EXPORT_PRIVATE P2PNotificationData { 56 class INVALIDATION_EXPORT_PRIVATE P2PNotificationData {
57 public: 57 public:
58 // Initializes with an empty sender ID, target set to NOTIFY_SELF, 58 // Initializes with an empty sender ID, target set to NOTIFY_SELF,
59 // and empty changed types. 59 // and empty changed types.
60 P2PNotificationData(); 60 P2PNotificationData();
61 P2PNotificationData(const std::string& sender_id, 61 P2PNotificationData(const std::string& sender_id,
62 P2PNotificationTarget target, 62 P2PNotificationTarget target,
63 const ObjectIdInvalidationMap& invalidation_map); 63 const ObjectIdInvalidationMap& invalidation_map);
64 64
65 ~P2PNotificationData(); 65 ~P2PNotificationData();
66 66
(...skipping 12 matching lines...) Expand all
79 79
80 private: 80 private:
81 // The unique ID of the client that sent the notification. 81 // The unique ID of the client that sent the notification.
82 std::string sender_id_; 82 std::string sender_id_;
83 // The intendent recipient(s) of the notification. 83 // The intendent recipient(s) of the notification.
84 P2PNotificationTarget target_; 84 P2PNotificationTarget target_;
85 // The invalidation map for the notification. 85 // The invalidation map for the notification.
86 ObjectIdInvalidationMap invalidation_map_; 86 ObjectIdInvalidationMap invalidation_map_;
87 }; 87 };
88 88
89 class SYNC_EXPORT_PRIVATE P2PInvalidator 89 class INVALIDATION_EXPORT_PRIVATE P2PInvalidator
90 : public Invalidator, 90 : public Invalidator,
91 public NON_EXPORTED_BASE(notifier::PushClientObserver) { 91 public NON_EXPORTED_BASE(notifier::PushClientObserver) {
92 public: 92 public:
93 // The |send_notification_target| parameter was added to allow us to send 93 // The |send_notification_target| parameter was added to allow us to send
94 // self-notifications in some cases, but not others. The value should be 94 // self-notifications in some cases, but not others. The value should be
95 // either NOTIFY_ALL to send notifications to all clients, or NOTIFY_OTHERS 95 // either NOTIFY_ALL to send notifications to all clients, or NOTIFY_OTHERS
96 // to send notifications to all clients except for the one that triggered the 96 // to send notifications to all clients except for the one that triggered the
97 // notification. See crbug.com/97780. 97 // notification. See crbug.com/97780.
98 P2PInvalidator(scoped_ptr<notifier::PushClient> push_client, 98 P2PInvalidator(scoped_ptr<notifier::PushClient> push_client,
99 const std::string& invalidator_client_id, 99 const std::string& invalidator_client_id,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 bool logged_in_; 140 bool logged_in_;
141 bool notifications_enabled_; 141 bool notifications_enabled_;
142 // Which set of clients should be sent notifications. 142 // Which set of clients should be sent notifications.
143 P2PNotificationTarget send_notification_target_; 143 P2PNotificationTarget send_notification_target_;
144 144
145 DISALLOW_COPY_AND_ASSIGN(P2PInvalidator); 145 DISALLOW_COPY_AND_ASSIGN(P2PInvalidator);
146 }; 146 };
147 147
148 } // namespace syncer 148 } // namespace syncer
149 149
150 #endif // SYNC_NOTIFIER_P2P_INVALIDATOR_H_ 150 #endif // COMPONENTS_INVALIDATION_P2P_INVALIDATOR_H_
OLDNEW
« no previous file with comments | « components/invalidation/p2p_invalidation_service.cc ('k') | components/invalidation/p2p_invalidator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698