| 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.h" | 5 #include "sync/engine/sync_scheduler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
| 16 #include "sync/engine/syncer.h" | 16 #include "sync/engine/syncer.h" |
| 17 #include "sync/engine/throttled_data_type_tracker.h" | 17 #include "sync/engine/throttled_data_type_tracker.h" |
| 18 #include "sync/protocol/proto_enum_conversions.h" | 18 #include "sync/protocol/proto_enum_conversions.h" |
| 19 #include "sync/protocol/sync.pb.h" | 19 #include "sync/protocol/sync.pb.h" |
| 20 #include "sync/util/data_type_histogram.h" | 20 #include "sync/util/data_type_histogram.h" |
| 21 #include "sync/util/logging.h" | 21 #include "sync/util/logging.h" |
| 22 | 22 |
| 23 using base::TimeDelta; | 23 using base::TimeDelta; |
| 24 using base::TimeTicks; | 24 using base::TimeTicks; |
| 25 | 25 |
| 26 namespace csync { | 26 namespace syncer { |
| 27 | 27 |
| 28 using sessions::SyncSession; | 28 using sessions::SyncSession; |
| 29 using sessions::SyncSessionSnapshot; | 29 using sessions::SyncSessionSnapshot; |
| 30 using sessions::SyncSourceInfo; | 30 using sessions::SyncSourceInfo; |
| 31 using syncable::ModelTypeSet; | 31 using syncable::ModelTypeSet; |
| 32 using syncable::ModelTypeSetToString; | 32 using syncable::ModelTypeSetToString; |
| 33 using syncable::ModelTypePayloadMap; | 33 using syncable::ModelTypePayloadMap; |
| 34 using sync_pb::GetUpdatesCallerInfo; | 34 using sync_pb::GetUpdatesCallerInfo; |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 bool ShouldRequestEarlyExit( | 37 bool ShouldRequestEarlyExit( |
| 38 const csync::SyncProtocolError& error) { | 38 const syncer::SyncProtocolError& error) { |
| 39 switch (error.error_type) { | 39 switch (error.error_type) { |
| 40 case csync::SYNC_SUCCESS: | 40 case syncer::SYNC_SUCCESS: |
| 41 case csync::MIGRATION_DONE: | 41 case syncer::MIGRATION_DONE: |
| 42 case csync::THROTTLED: | 42 case syncer::THROTTLED: |
| 43 case csync::TRANSIENT_ERROR: | 43 case syncer::TRANSIENT_ERROR: |
| 44 return false; | 44 return false; |
| 45 case csync::NOT_MY_BIRTHDAY: | 45 case syncer::NOT_MY_BIRTHDAY: |
| 46 case csync::CLEAR_PENDING: | 46 case syncer::CLEAR_PENDING: |
| 47 // If we send terminate sync early then |sync_cycle_ended| notification | 47 // If we send terminate sync early then |sync_cycle_ended| notification |
| 48 // would not be sent. If there were no actions then |ACTIONABLE_ERROR| | 48 // would not be sent. If there were no actions then |ACTIONABLE_ERROR| |
| 49 // notification wouldnt be sent either. Then the UI layer would be left | 49 // notification wouldnt be sent either. Then the UI layer would be left |
| 50 // waiting forever. So assert we would send something. | 50 // waiting forever. So assert we would send something. |
| 51 DCHECK(error.action != csync::UNKNOWN_ACTION); | 51 DCHECK(error.action != syncer::UNKNOWN_ACTION); |
| 52 return true; | 52 return true; |
| 53 case csync::INVALID_CREDENTIAL: | 53 case syncer::INVALID_CREDENTIAL: |
| 54 // The notification for this is handled by PostAndProcessHeaders|. | 54 // The notification for this is handled by PostAndProcessHeaders|. |
| 55 // Server does no have to send any action for this. | 55 // Server does no have to send any action for this. |
| 56 return true; | 56 return true; |
| 57 // Make the default a NOTREACHED. So if a new error is introduced we | 57 // Make the default a NOTREACHED. So if a new error is introduced we |
| 58 // think about its expected functionality. | 58 // think about its expected functionality. |
| 59 default: | 59 default: |
| 60 NOTREACHED(); | 60 NOTREACHED(); |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool IsActionableError( | 65 bool IsActionableError( |
| 66 const csync::SyncProtocolError& error) { | 66 const syncer::SyncProtocolError& error) { |
| 67 return (error.action != csync::UNKNOWN_ACTION); | 67 return (error.action != syncer::UNKNOWN_ACTION); |
| 68 } | 68 } |
| 69 } // namespace | 69 } // namespace |
| 70 | 70 |
| 71 SyncScheduler::DelayProvider::DelayProvider() {} | 71 SyncScheduler::DelayProvider::DelayProvider() {} |
| 72 SyncScheduler::DelayProvider::~DelayProvider() {} | 72 SyncScheduler::DelayProvider::~DelayProvider() {} |
| 73 | 73 |
| 74 SyncScheduler::WaitInterval::WaitInterval() | 74 SyncScheduler::WaitInterval::WaitInterval() |
| 75 : mode(UNKNOWN), | 75 : mode(UNKNOWN), |
| 76 had_nudge(false) { | 76 had_nudge(false) { |
| 77 } | 77 } |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 } | 1134 } |
| 1135 | 1135 |
| 1136 #undef SDVLOG_LOC | 1136 #undef SDVLOG_LOC |
| 1137 | 1137 |
| 1138 #undef SDVLOG | 1138 #undef SDVLOG |
| 1139 | 1139 |
| 1140 #undef SLOG | 1140 #undef SLOG |
| 1141 | 1141 |
| 1142 #undef ENUM_CASE | 1142 #undef ENUM_CASE |
| 1143 | 1143 |
| 1144 } // csync | 1144 } // namespace syncer |
| OLD | NEW |