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/internal_api/sync_manager_impl.h" | 5 #include "sync/internal_api/sync_manager_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "sync/internal_api/public/read_transaction.h" | 31 #include "sync/internal_api/public/read_transaction.h" |
32 #include "sync/internal_api/public/sync_context.h" | 32 #include "sync/internal_api/public/sync_context.h" |
33 #include "sync/internal_api/public/sync_context_proxy.h" | 33 #include "sync/internal_api/public/sync_context_proxy.h" |
34 #include "sync/internal_api/public/user_share.h" | 34 #include "sync/internal_api/public/user_share.h" |
35 #include "sync/internal_api/public/util/experiments.h" | 35 #include "sync/internal_api/public/util/experiments.h" |
36 #include "sync/internal_api/public/write_node.h" | 36 #include "sync/internal_api/public/write_node.h" |
37 #include "sync/internal_api/public/write_transaction.h" | 37 #include "sync/internal_api/public/write_transaction.h" |
38 #include "sync/internal_api/sync_context_proxy_impl.h" | 38 #include "sync/internal_api/sync_context_proxy_impl.h" |
39 #include "sync/internal_api/syncapi_internal.h" | 39 #include "sync/internal_api/syncapi_internal.h" |
40 #include "sync/internal_api/syncapi_server_connection_manager.h" | 40 #include "sync/internal_api/syncapi_server_connection_manager.h" |
41 #include "sync/notifier/invalidation_util.h" | |
42 #include "sync/notifier/invalidator.h" | |
43 #include "sync/notifier/object_id_invalidation_map.h" | |
44 #include "sync/protocol/proto_value_conversions.h" | 41 #include "sync/protocol/proto_value_conversions.h" |
45 #include "sync/protocol/sync.pb.h" | 42 #include "sync/protocol/sync.pb.h" |
46 #include "sync/sessions/directory_type_debug_info_emitter.h" | 43 #include "sync/sessions/directory_type_debug_info_emitter.h" |
47 #include "sync/syncable/directory.h" | 44 #include "sync/syncable/directory.h" |
48 #include "sync/syncable/entry.h" | 45 #include "sync/syncable/entry.h" |
49 #include "sync/syncable/in_memory_directory_backing_store.h" | 46 #include "sync/syncable/in_memory_directory_backing_store.h" |
50 #include "sync/syncable/on_disk_directory_backing_store.h" | 47 #include "sync/syncable/on_disk_directory_backing_store.h" |
51 | 48 |
52 using base::TimeDelta; | 49 using base::TimeDelta; |
53 using sync_pb::GetUpdatesCallerInfo; | 50 using sync_pb::GetUpdatesCallerInfo; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 159 } |
163 return delay; | 160 return delay; |
164 } | 161 } |
165 }; | 162 }; |
166 | 163 |
167 SyncManagerImpl::SyncManagerImpl(const std::string& name) | 164 SyncManagerImpl::SyncManagerImpl(const std::string& name) |
168 : name_(name), | 165 : name_(name), |
169 change_delegate_(NULL), | 166 change_delegate_(NULL), |
170 initialized_(false), | 167 initialized_(false), |
171 observing_network_connectivity_changes_(false), | 168 observing_network_connectivity_changes_(false), |
172 invalidator_state_(DEFAULT_INVALIDATION_ERROR), | |
173 report_unrecoverable_error_function_(NULL), | 169 report_unrecoverable_error_function_(NULL), |
174 weak_ptr_factory_(this) { | 170 weak_ptr_factory_(this) { |
175 // Pre-fill |notification_info_map_|. | 171 // Pre-fill |notification_info_map_|. |
176 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { | 172 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { |
177 notification_info_map_.insert( | 173 notification_info_map_.insert( |
178 std::make_pair(ModelTypeFromInt(i), NotificationInfo())); | 174 std::make_pair(ModelTypeFromInt(i), NotificationInfo())); |
179 } | 175 } |
180 } | 176 } |
181 | 177 |
182 SyncManagerImpl::~SyncManagerImpl() { | 178 SyncManagerImpl::~SyncManagerImpl() { |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 // This can happen in some cases. The UI thread makes requests of us | 956 // This can happen in some cases. The UI thread makes requests of us |
961 // when it doesn't really know which types are enabled or disabled. | 957 // when it doesn't really know which types are enabled or disabled. |
962 DLOG(WARNING) << "Asked to return debug info for invalid type " | 958 DLOG(WARNING) << "Asked to return debug info for invalid type " |
963 << ModelTypeToString(type); | 959 << ModelTypeToString(type); |
964 return scoped_ptr<base::ListValue>(); | 960 return scoped_ptr<base::ListValue>(); |
965 } | 961 } |
966 | 962 |
967 return it->second->GetAllNodes(); | 963 return it->second->GetAllNodes(); |
968 } | 964 } |
969 | 965 |
970 void SyncManagerImpl::OnInvalidatorStateChange(InvalidatorState state) { | 966 void SyncManagerImpl::SetInvalidatorEnabled(bool invalidator_enabled) { |
971 DCHECK(thread_checker_.CalledOnValidThread()); | 967 DCHECK(thread_checker_.CalledOnValidThread()); |
972 | 968 |
973 const std::string& state_str = InvalidatorStateToString(state); | 969 DVLOG(1) << "Invalidator enabled state is now: " << invalidator_enabled; |
974 invalidator_state_ = state; | 970 allstatus_.SetNotificationsEnabled(invalidator_enabled); |
975 DVLOG(1) << "Invalidator state changed to: " << state_str; | 971 scheduler_->SetNotificationsEnabled(invalidator_enabled); |
976 const bool notifications_enabled = | |
977 (invalidator_state_ == INVALIDATIONS_ENABLED); | |
978 allstatus_.SetNotificationsEnabled(notifications_enabled); | |
979 scheduler_->SetNotificationsEnabled(notifications_enabled); | |
980 } | 972 } |
981 | 973 |
982 void SyncManagerImpl::OnIncomingInvalidation( | 974 void SyncManagerImpl::OnIncomingInvalidation( |
983 syncer::ModelType type, | 975 syncer::ModelType type, |
984 scoped_ptr<InvalidationInterface> invalidation) { | 976 scoped_ptr<InvalidationInterface> invalidation) { |
985 DCHECK(thread_checker_.CalledOnValidThread()); | 977 DCHECK(thread_checker_.CalledOnValidThread()); |
986 | 978 |
987 scheduler_->ScheduleInvalidationNudge( | 979 scheduler_->ScheduleInvalidationNudge( |
988 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), | 980 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), |
989 type, | 981 type, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1127 int SyncManagerImpl::GetDefaultNudgeDelay() { |
1136 return kDefaultNudgeDelayMilliseconds; | 1128 return kDefaultNudgeDelayMilliseconds; |
1137 } | 1129 } |
1138 | 1130 |
1139 // static. | 1131 // static. |
1140 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1132 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
1141 return kPreferencesNudgeDelayMilliseconds; | 1133 return kPreferencesNudgeDelayMilliseconds; |
1142 } | 1134 } |
1143 | 1135 |
1144 } // namespace syncer | 1136 } // namespace syncer |
OLD | NEW |