| 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.h" | 5 #include "sync/internal_api/sync_manager.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 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 | 840 |
| 841 bool SyncManager::IsUsingExplicitPassphrase() { | 841 bool SyncManager::IsUsingExplicitPassphrase() { |
| 842 return data_ && data_->IsUsingExplicitPassphrase(); | 842 return data_ && data_->IsUsingExplicitPassphrase(); |
| 843 } | 843 } |
| 844 | 844 |
| 845 void SyncManager::RequestCleanupDisabledTypes( | 845 void SyncManager::RequestCleanupDisabledTypes( |
| 846 const browser_sync::ModelSafeRoutingInfo& routing_info) { | 846 const browser_sync::ModelSafeRoutingInfo& routing_info) { |
| 847 DCHECK(thread_checker_.CalledOnValidThread()); | 847 DCHECK(thread_checker_.CalledOnValidThread()); |
| 848 if (data_->scheduler()) { | 848 if (data_->scheduler()) { |
| 849 data_->session_context()->set_routing_info(routing_info); | 849 data_->session_context()->set_routing_info(routing_info); |
| 850 data_->scheduler()->ScheduleCleanupDisabledTypes(); | 850 data_->scheduler()->CleanupDisabledTypes(); |
| 851 } | 851 } |
| 852 } | 852 } |
| 853 | 853 |
| 854 void SyncManager::RequestClearServerData() { | 854 void SyncManager::RequestClearServerData() { |
| 855 DCHECK(thread_checker_.CalledOnValidThread()); | 855 DCHECK(thread_checker_.CalledOnValidThread()); |
| 856 if (data_->scheduler()) | 856 if (data_->scheduler()) |
| 857 data_->scheduler()->ScheduleClearUserData(); | 857 data_->scheduler()->ClearUserData(); |
| 858 } | 858 } |
| 859 | 859 |
| 860 void SyncManager::RequestConfig( | 860 void SyncManager::RequestConfig( |
| 861 const browser_sync::ModelSafeRoutingInfo& routing_info, | 861 const browser_sync::ModelSafeRoutingInfo& routing_info, |
| 862 const ModelTypeSet& types, ConfigureReason reason) { | 862 const ModelTypeSet& types, ConfigureReason reason) { |
| 863 DCHECK(thread_checker_.CalledOnValidThread()); | 863 DCHECK(thread_checker_.CalledOnValidThread()); |
| 864 if (!data_->scheduler()) { | 864 if (!data_->scheduler()) { |
| 865 LOG(INFO) | 865 LOG(INFO) |
| 866 << "SyncManager::RequestConfig: bailing out because scheduler is " | 866 << "SyncManager::RequestConfig: bailing out because scheduler is " |
| 867 << "null"; | 867 << "null"; |
| 868 return; | 868 return; |
| 869 } | 869 } |
| 870 StartConfigurationMode(base::Closure()); | 870 StartConfigurationMode(base::Closure()); |
| 871 data_->session_context()->set_routing_info(routing_info); | 871 data_->session_context()->set_routing_info(routing_info); |
| 872 data_->scheduler()->ScheduleConfig(types, GetSourceFromReason(reason)); | 872 data_->scheduler()->ScheduleConfigure(types, GetSourceFromReason(reason)); |
| 873 } | 873 } |
| 874 | 874 |
| 875 void SyncManager::StartConfigurationMode(const base::Closure& callback) { | 875 void SyncManager::StartConfigurationMode(const base::Closure& callback) { |
| 876 DCHECK(thread_checker_.CalledOnValidThread()); | 876 DCHECK(thread_checker_.CalledOnValidThread()); |
| 877 if (!data_->scheduler()) { | 877 if (!data_->scheduler()) { |
| 878 LOG(INFO) | 878 LOG(INFO) |
| 879 << "SyncManager::StartConfigurationMode: could not start " | 879 << "SyncManager::StartConfigurationMode: could not start " |
| 880 << "configuration mode because because scheduler is null"; | 880 << "configuration mode because because scheduler is null"; |
| 881 return; | 881 return; |
| 882 } | 882 } |
| (...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 } | 1959 } |
| 1960 } | 1960 } |
| 1961 | 1961 |
| 1962 SyncManager::Status SyncManager::SyncInternal::GetStatus() { | 1962 SyncManager::Status SyncManager::SyncInternal::GetStatus() { |
| 1963 return allstatus_.status(); | 1963 return allstatus_.status(); |
| 1964 } | 1964 } |
| 1965 | 1965 |
| 1966 void SyncManager::SyncInternal::RequestNudge( | 1966 void SyncManager::SyncInternal::RequestNudge( |
| 1967 const tracked_objects::Location& location) { | 1967 const tracked_objects::Location& location) { |
| 1968 if (scheduler()) { | 1968 if (scheduler()) { |
| 1969 scheduler()->ScheduleNudge( | 1969 scheduler()->ScheduleNudgeAsync( |
| 1970 TimeDelta::FromMilliseconds(0), browser_sync::NUDGE_SOURCE_LOCAL, | 1970 TimeDelta::FromMilliseconds(0), browser_sync::NUDGE_SOURCE_LOCAL, |
| 1971 ModelTypeSet(), location); | 1971 ModelTypeSet(), location); |
| 1972 } | 1972 } |
| 1973 } | 1973 } |
| 1974 | 1974 |
| 1975 TimeDelta SyncManager::SyncInternal::GetNudgeDelayTimeDelta( | 1975 TimeDelta SyncManager::SyncInternal::GetNudgeDelayTimeDelta( |
| 1976 const ModelType& model_type) { | 1976 const ModelType& model_type) { |
| 1977 return NudgeStrategy::GetNudgeDelayTimeDelta(model_type, this); | 1977 return NudgeStrategy::GetNudgeDelayTimeDelta(model_type, this); |
| 1978 } | 1978 } |
| 1979 | 1979 |
| 1980 void SyncManager::SyncInternal::RequestNudgeForDataTypes( | 1980 void SyncManager::SyncInternal::RequestNudgeForDataTypes( |
| 1981 const tracked_objects::Location& nudge_location, | 1981 const tracked_objects::Location& nudge_location, |
| 1982 ModelTypeSet types) { | 1982 ModelTypeSet types) { |
| 1983 if (!scheduler()) { | 1983 if (!scheduler()) { |
| 1984 NOTREACHED(); | 1984 NOTREACHED(); |
| 1985 return; | 1985 return; |
| 1986 } | 1986 } |
| 1987 | 1987 |
| 1988 debug_info_event_listener_.OnNudgeFromDatatype(types.First().Get()); | 1988 debug_info_event_listener_.OnNudgeFromDatatype(types.First().Get()); |
| 1989 | 1989 |
| 1990 // TODO(lipalani) : Calculate the nudge delay based on all types. | 1990 // TODO(lipalani) : Calculate the nudge delay based on all types. |
| 1991 base::TimeDelta nudge_delay = NudgeStrategy::GetNudgeDelayTimeDelta( | 1991 base::TimeDelta nudge_delay = NudgeStrategy::GetNudgeDelayTimeDelta( |
| 1992 types.First().Get(), | 1992 types.First().Get(), |
| 1993 this); | 1993 this); |
| 1994 scheduler()->ScheduleNudge(nudge_delay, | 1994 scheduler()->ScheduleNudgeAsync(nudge_delay, |
| 1995 browser_sync::NUDGE_SOURCE_LOCAL, | 1995 browser_sync::NUDGE_SOURCE_LOCAL, |
| 1996 types, | 1996 types, |
| 1997 nudge_location); | 1997 nudge_location); |
| 1998 } | 1998 } |
| 1999 | 1999 |
| 2000 void SyncManager::SyncInternal::OnSyncEngineEvent( | 2000 void SyncManager::SyncInternal::OnSyncEngineEvent( |
| 2001 const SyncEngineEvent& event) { | 2001 const SyncEngineEvent& event) { |
| 2002 DCHECK(thread_checker_.CalledOnValidThread()); | 2002 DCHECK(thread_checker_.CalledOnValidThread()); |
| 2003 // Only send an event if this is due to a cycle ending and this cycle | 2003 // Only send an event if this is due to a cycle ending and this cycle |
| 2004 // concludes a canonical "sync" process; that is, based on what is known | 2004 // concludes a canonical "sync" process; that is, based on what is known |
| 2005 // locally we are "all happy" and up-to-date. There may be new changes on | 2005 // locally we are "all happy" and up-to-date. There may be new changes on |
| 2006 // the server, but we'll get them on a subsequent sync. | 2006 // the server, but we'll get them on a subsequent sync. |
| 2007 // | 2007 // |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2322 info->payload = it->second; | 2322 info->payload = it->second; |
| 2323 } | 2323 } |
| 2324 } | 2324 } |
| 2325 | 2325 |
| 2326 void SyncManager::SyncInternal::OnIncomingNotification( | 2326 void SyncManager::SyncInternal::OnIncomingNotification( |
| 2327 const syncable::ModelTypePayloadMap& type_payloads, | 2327 const syncable::ModelTypePayloadMap& type_payloads, |
| 2328 sync_notifier::IncomingNotificationSource source) { | 2328 sync_notifier::IncomingNotificationSource source) { |
| 2329 DCHECK(thread_checker_.CalledOnValidThread()); | 2329 DCHECK(thread_checker_.CalledOnValidThread()); |
| 2330 if (source == sync_notifier::LOCAL_NOTIFICATION) { | 2330 if (source == sync_notifier::LOCAL_NOTIFICATION) { |
| 2331 if (scheduler()) { | 2331 if (scheduler()) { |
| 2332 scheduler()->ScheduleNudgeWithPayloads( | 2332 scheduler()->ScheduleNudgeWithPayloadsAsync( |
| 2333 TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec), | 2333 TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec), |
| 2334 browser_sync::NUDGE_SOURCE_LOCAL_REFRESH, | 2334 browser_sync::NUDGE_SOURCE_LOCAL_REFRESH, |
| 2335 type_payloads, FROM_HERE); | 2335 type_payloads, FROM_HERE); |
| 2336 } | 2336 } |
| 2337 } else if (!type_payloads.empty()) { | 2337 } else if (!type_payloads.empty()) { |
| 2338 if (scheduler()) { | 2338 if (scheduler()) { |
| 2339 scheduler()->ScheduleNudgeWithPayloads( | 2339 scheduler()->ScheduleNudgeWithPayloadsAsync( |
| 2340 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), | 2340 TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), |
| 2341 browser_sync::NUDGE_SOURCE_NOTIFICATION, | 2341 browser_sync::NUDGE_SOURCE_NOTIFICATION, |
| 2342 type_payloads, FROM_HERE); | 2342 type_payloads, FROM_HERE); |
| 2343 } | 2343 } |
| 2344 allstatus_.IncrementNotificationsReceived(); | 2344 allstatus_.IncrementNotificationsReceived(); |
| 2345 UpdateNotificationInfo(type_payloads); | 2345 UpdateNotificationInfo(type_payloads); |
| 2346 debug_info_event_listener_.OnIncomingNotification(type_payloads); | 2346 debug_info_event_listener_.OnIncomingNotification(type_payloads); |
| 2347 } else { | 2347 } else { |
| 2348 LOG(WARNING) << "Sync received notification without any type information."; | 2348 LOG(WARNING) << "Sync received notification without any type information."; |
| 2349 } | 2349 } |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2502 share->directory->GetDownloadProgress(i.Get(), &marker); | 2502 share->directory->GetDownloadProgress(i.Get(), &marker); |
| 2503 | 2503 |
| 2504 if (marker.token().empty()) | 2504 if (marker.token().empty()) |
| 2505 result.Put(i.Get()); | 2505 result.Put(i.Get()); |
| 2506 | 2506 |
| 2507 } | 2507 } |
| 2508 return result; | 2508 return result; |
| 2509 } | 2509 } |
| 2510 | 2510 |
| 2511 } // namespace sync_api | 2511 } // namespace sync_api |
| OLD | NEW |