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