OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/sync/notifier/p2p_notifier.h" | 5 #include "chrome/browser/sync/notifier/p2p_notifier.h" |
6 | 6 |
7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
8 #include "chrome/browser/sync/notifier/sync_notifier_observer.h" | 8 #include "chrome/browser/sync/notifier/sync_notifier_observer.h" |
9 #include "chrome/browser/sync/protocol/service_constants.h" | 9 #include "chrome/browser/sync/protocol/service_constants.h" |
10 #include "chrome/browser/sync/syncable/model_type_payload_map.h" | 10 #include "chrome/browser/sync/syncable/model_type_payload_map.h" |
11 #include "jingle/notifier/listener/mediator_thread_impl.h" | 11 #include "jingle/notifier/listener/mediator_thread_impl.h" |
12 #include "jingle/notifier/listener/talk_mediator_impl.h" | 12 #include "jingle/notifier/listener/talk_mediator_impl.h" |
13 | 13 |
14 namespace sync_notifier { | 14 namespace sync_notifier { |
15 | 15 |
16 namespace { | 16 namespace { |
17 const char kSyncNotificationChannel[] = "http://www.google.com/chrome/sync"; | 17 const char kSyncNotificationChannel[] = "http://www.google.com/chrome/sync"; |
18 const char kSyncNotificationData[] = "sync-ping-p2p"; | 18 const char kSyncNotificationData[] = "sync-ping-p2p"; |
19 } // namespace | 19 } // namespace |
20 | 20 |
21 P2PNotifier::P2PNotifier( | 21 P2PNotifier::P2PNotifier( |
22 const notifier::NotifierOptions& notifier_options) | 22 const notifier::NotifierOptions& notifier_options) |
23 : talk_mediator_( | 23 : talk_mediator_( |
24 new notifier::TalkMediatorImpl( | 24 new notifier::TalkMediatorImpl( |
25 new notifier::MediatorThreadImpl(notifier_options), | 25 new notifier::MediatorThreadImpl(notifier_options), |
26 notifier_options)), | 26 notifier_options)), |
27 logged_in_(false), | 27 logged_in_(false), |
28 notifications_enabled_(false), | 28 notifications_enabled_(false), |
29 parent_message_loop_proxy_( | 29 parent_message_loop_proxy_( |
30 base::MessageLoopProxy::CreateForCurrentThread()) { | 30 base::MessageLoopProxy::current()) { |
31 talk_mediator_->SetDelegate(this); | 31 talk_mediator_->SetDelegate(this); |
32 } | 32 } |
33 | 33 |
34 P2PNotifier::~P2PNotifier() { | 34 P2PNotifier::~P2PNotifier() { |
35 DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); | 35 DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); |
36 } | 36 } |
37 | 37 |
38 void P2PNotifier::AddObserver(SyncNotifierObserver* observer) { | 38 void P2PNotifier::AddObserver(SyncNotifierObserver* observer) { |
39 DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); | 39 DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); |
40 observer_list_.AddObserver(observer); | 40 observer_list_.AddObserver(observer); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 return; | 136 return; |
137 } | 137 } |
138 syncable::ModelTypePayloadMap type_payloads = | 138 syncable::ModelTypePayloadMap type_payloads = |
139 syncable::ModelTypePayloadMapFromBitSet( | 139 syncable::ModelTypePayloadMapFromBitSet( |
140 syncable::ModelTypeBitSetFromSet(enabled_types_), std::string()); | 140 syncable::ModelTypeBitSetFromSet(enabled_types_), std::string()); |
141 FOR_EACH_OBSERVER(SyncNotifierObserver, observer_list_, | 141 FOR_EACH_OBSERVER(SyncNotifierObserver, observer_list_, |
142 OnIncomingNotification(type_payloads)); | 142 OnIncomingNotification(type_payloads)); |
143 } | 143 } |
144 | 144 |
145 } // namespace sync_notifier | 145 } // namespace sync_notifier |
OLD | NEW |