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