Chromium Code Reviews| 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/engine/sync_scheduler_impl.h" | 5 #include "sync/engine/sync_scheduler_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/thread_task_runner_handle.h" |
|
gab
2016/05/12 15:50:57
FYI, that header moved to base/threading/thread_ta
| |
| 17 #include "sync/engine/backoff_delay_provider.h" | 17 #include "sync/engine/backoff_delay_provider.h" |
| 18 #include "sync/engine/syncer.h" | 18 #include "sync/engine/syncer.h" |
| 19 #include "sync/protocol/proto_enum_conversions.h" | 19 #include "sync/protocol/proto_enum_conversions.h" |
| 20 #include "sync/protocol/sync.pb.h" | 20 #include "sync/protocol/sync.pb.h" |
| 21 #include "sync/util/data_type_histogram.h" | 21 #include "sync/util/data_type_histogram.h" |
| 22 #include "sync/util/logging.h" | 22 #include "sync/util/logging.h" |
| 23 | 23 |
| 24 using base::TimeDelta; | 24 using base::TimeDelta; |
| 25 using base::TimeTicks; | 25 using base::TimeTicks; |
| 26 | 26 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 // | 219 // |
| 220 // In all cases except (2), we want to retry contacting the server. We | 220 // In all cases except (2), we want to retry contacting the server. We |
| 221 // call TryCanaryJob to achieve this, and note that nothing -- not even a | 221 // call TryCanaryJob to achieve this, and note that nothing -- not even a |
| 222 // canary job -- can bypass a THROTTLED WaitInterval. The only thing that | 222 // canary job -- can bypass a THROTTLED WaitInterval. The only thing that |
| 223 // has the authority to do that is the Unthrottle timer. | 223 // has the authority to do that is the Unthrottle timer. |
| 224 TryCanaryJob(); | 224 TryCanaryJob(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void SyncSchedulerImpl::Start(Mode mode, base::Time last_poll_time) { | 227 void SyncSchedulerImpl::Start(Mode mode, base::Time last_poll_time) { |
| 228 DCHECK(CalledOnValidThread()); | 228 DCHECK(CalledOnValidThread()); |
| 229 std::string thread_name = base::MessageLoop::current()->thread_name(); | 229 std::string thread_name = |
| 230 base::ThreadTaskRunnerHandle::Get()->GetThreadName(); | |
| 230 if (thread_name.empty()) | 231 if (thread_name.empty()) |
| 231 thread_name = "<Main thread>"; | 232 thread_name = "<Main thread>"; |
| 232 SDVLOG(2) << "Start called from thread " | 233 SDVLOG(2) << "Start called from thread " |
| 233 << thread_name << " with mode " << GetModeString(mode); | 234 << thread_name << " with mode " << GetModeString(mode); |
| 234 if (!started_) { | 235 if (!started_) { |
| 235 started_ = true; | 236 started_ = true; |
| 236 SendInitialSnapshot(); | 237 SendInitialSnapshot(); |
| 237 } | 238 } |
| 238 | 239 |
| 239 DCHECK(syncer_.get()); | 240 DCHECK(syncer_.get()); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 739 // privileges. Everyone else should use NORMAL_PRIORITY. | 740 // privileges. Everyone else should use NORMAL_PRIORITY. |
| 740 void SyncSchedulerImpl::TryCanaryJob() { | 741 void SyncSchedulerImpl::TryCanaryJob() { |
| 741 next_sync_session_job_priority_ = CANARY_PRIORITY; | 742 next_sync_session_job_priority_ = CANARY_PRIORITY; |
| 742 SDVLOG(2) << "Attempting canary job"; | 743 SDVLOG(2) << "Attempting canary job"; |
| 743 TrySyncSessionJob(); | 744 TrySyncSessionJob(); |
| 744 } | 745 } |
| 745 | 746 |
| 746 void SyncSchedulerImpl::TrySyncSessionJob() { | 747 void SyncSchedulerImpl::TrySyncSessionJob() { |
| 747 // Post call to TrySyncSessionJobImpl on current thread. Later request for | 748 // Post call to TrySyncSessionJobImpl on current thread. Later request for |
| 748 // access token will be here. | 749 // access token will be here. |
| 749 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 750 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 750 &SyncSchedulerImpl::TrySyncSessionJobImpl, | 751 FROM_HERE, base::Bind(&SyncSchedulerImpl::TrySyncSessionJobImpl, |
| 751 weak_ptr_factory_.GetWeakPtr())); | 752 weak_ptr_factory_.GetWeakPtr())); |
| 752 } | 753 } |
| 753 | 754 |
| 754 void SyncSchedulerImpl::TrySyncSessionJobImpl() { | 755 void SyncSchedulerImpl::TrySyncSessionJobImpl() { |
| 755 JobPriority priority = next_sync_session_job_priority_; | 756 JobPriority priority = next_sync_session_job_priority_; |
| 756 next_sync_session_job_priority_ = NORMAL_PRIORITY; | 757 next_sync_session_job_priority_ = NORMAL_PRIORITY; |
| 757 | 758 |
| 758 nudge_tracker_.SetSyncCycleStartTime(base::TimeTicks::Now()); | 759 nudge_tracker_.SetSyncCycleStartTime(base::TimeTicks::Now()); |
| 759 | 760 |
| 760 DCHECK(CalledOnValidThread()); | 761 DCHECK(CalledOnValidThread()); |
| 761 if (mode_ == CONFIGURATION_MODE) { | 762 if (mode_ == CONFIGURATION_MODE) { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 988 | 989 |
| 989 #undef SDVLOG_LOC | 990 #undef SDVLOG_LOC |
| 990 | 991 |
| 991 #undef SDVLOG | 992 #undef SDVLOG |
| 992 | 993 |
| 993 #undef SLOG | 994 #undef SLOG |
| 994 | 995 |
| 995 #undef ENUM_CASE | 996 #undef ENUM_CASE |
| 996 | 997 |
| 997 } // namespace syncer | 998 } // namespace syncer |
| OLD | NEW |