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 #include "sync/notifier/sync_notifier_factory.h" | 5 #include "sync/notifier/sync_notifier_factory.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "jingle/notifier/listener/mediator_thread_impl.h" | 10 #include "jingle/notifier/listener/mediator_thread_impl.h" |
11 #include "jingle/notifier/listener/talk_mediator_impl.h" | 11 #include "jingle/notifier/listener/talk_mediator_impl.h" |
12 #include "sync/notifier/non_blocking_invalidation_notifier.h" | 12 #include "sync/notifier/non_blocking_invalidation_notifier.h" |
13 #include "sync/notifier/p2p_notifier.h" | 13 #include "sync/notifier/p2p_notifier.h" |
14 #include "sync/notifier/sync_notifier.h" | 14 #include "sync/notifier/sync_notifier.h" |
15 | 15 |
16 namespace sync_notifier { | 16 namespace sync_notifier { |
17 namespace { | 17 namespace { |
18 | 18 |
19 SyncNotifier* CreateDefaultSyncNotifier( | 19 SyncNotifier* CreateDefaultSyncNotifier( |
20 const notifier::NotifierOptions& notifier_options, | 20 const notifier::NotifierOptions& notifier_options, |
21 const InvalidationVersionMap& initial_max_invalidation_versions, | 21 const InvalidationVersionMap& initial_max_invalidation_versions, |
22 const browser_sync::WeakHandle<InvalidationVersionTracker>& | 22 const browser_sync::WeakHandle<InvalidationStateTracker>& |
23 invalidation_version_tracker, | 23 invalidation_state_tracker, |
24 const std::string& client_info) { | 24 const std::string& client_info) { |
25 if (notifier_options.notification_method == notifier::NOTIFICATION_P2P) { | 25 if (notifier_options.notification_method == notifier::NOTIFICATION_P2P) { |
26 notifier::TalkMediator* const talk_mediator = | 26 notifier::TalkMediator* const talk_mediator = |
27 new notifier::TalkMediatorImpl( | 27 new notifier::TalkMediatorImpl( |
28 new notifier::MediatorThreadImpl(notifier_options), | 28 new notifier::MediatorThreadImpl(notifier_options), |
29 notifier_options); | 29 notifier_options); |
30 // TODO(rlarocque): Ideally, the notification target would be | 30 // TODO(rlarocque): Ideally, the notification target would be |
31 // NOTIFY_OTHERS. There's no good reason to notify ourselves of our own | 31 // NOTIFY_OTHERS. There's no good reason to notify ourselves of our own |
32 // commits. We self-notify for now only because the integration tests rely | 32 // commits. We self-notify for now only because the integration tests rely |
33 // on this behaviour. See crbug.com/97780. | 33 // on this behaviour. See crbug.com/97780. |
34 // | 34 // |
35 // Takes ownership of |talk_mediator|. | 35 // Takes ownership of |talk_mediator|. |
36 return new P2PNotifier(talk_mediator, NOTIFY_ALL); | 36 return new P2PNotifier(talk_mediator, NOTIFY_ALL); |
37 } | 37 } |
38 | 38 |
39 return new NonBlockingInvalidationNotifier( | 39 return new NonBlockingInvalidationNotifier( |
40 notifier_options, initial_max_invalidation_versions, | 40 notifier_options, initial_max_invalidation_versions, |
41 invalidation_version_tracker, client_info); | 41 invalidation_state_tracker, client_info); |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 // TODO(akalin): Remove the dependency on jingle if OS_ANDROID is defined. | 46 // TODO(akalin): Remove the dependency on jingle if OS_ANDROID is defined. |
47 SyncNotifierFactory::SyncNotifierFactory( | 47 SyncNotifierFactory::SyncNotifierFactory( |
48 const notifier::NotifierOptions& notifier_options, | 48 const notifier::NotifierOptions& notifier_options, |
49 const std::string& client_info, | 49 const std::string& client_info, |
50 const base::WeakPtr<InvalidationVersionTracker>& | 50 const base::WeakPtr<InvalidationStateTracker>& |
51 invalidation_version_tracker) | 51 invalidation_state_tracker) |
52 : notifier_options_(notifier_options), | 52 : notifier_options_(notifier_options), |
53 client_info_(client_info), | 53 client_info_(client_info), |
54 initial_max_invalidation_versions_( | 54 initial_max_invalidation_versions_( |
55 invalidation_version_tracker.get() ? | 55 invalidation_state_tracker.get() ? |
56 invalidation_version_tracker->GetAllMaxVersions() : | 56 invalidation_state_tracker->GetAllMaxVersions() : |
57 InvalidationVersionMap()), | 57 InvalidationVersionMap()), |
58 invalidation_version_tracker_(invalidation_version_tracker) { | 58 invalidation_state_tracker_(invalidation_state_tracker) { |
59 } | 59 } |
60 | 60 |
61 SyncNotifierFactory::~SyncNotifierFactory() { | 61 SyncNotifierFactory::~SyncNotifierFactory() { |
62 } | 62 } |
63 | 63 |
64 SyncNotifier* SyncNotifierFactory::CreateSyncNotifier() { | 64 SyncNotifier* SyncNotifierFactory::CreateSyncNotifier() { |
65 #if defined(OS_ANDROID) | 65 #if defined(OS_ANDROID) |
66 // Android uses ChromeSyncNotificationBridge exclusively. | 66 // Android uses ChromeSyncNotificationBridge exclusively. |
67 return NULL; | 67 return NULL; |
68 #else | 68 #else |
69 return CreateDefaultSyncNotifier(notifier_options_, | 69 return CreateDefaultSyncNotifier(notifier_options_, |
70 initial_max_invalidation_versions_, | 70 initial_max_invalidation_versions_, |
71 invalidation_version_tracker_, | 71 invalidation_state_tracker_, |
72 client_info_); | 72 client_info_); |
73 #endif | 73 #endif |
74 } | 74 } |
75 } // namespace sync_notifier | 75 } // namespace sync_notifier |
OLD | NEW |