| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/engine/sync_scheduler.h" | 5 #include "chrome/browser/sync/engine/sync_scheduler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 case NUDGE_SOURCE_CONTINUATION: | 97 case NUDGE_SOURCE_CONTINUATION: |
| 98 return GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION; | 98 return GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION; |
| 99 case NUDGE_SOURCE_UNKNOWN: | 99 case NUDGE_SOURCE_UNKNOWN: |
| 100 return GetUpdatesCallerInfo::UNKNOWN; | 100 return GetUpdatesCallerInfo::UNKNOWN; |
| 101 default: | 101 default: |
| 102 NOTREACHED(); | 102 NOTREACHED(); |
| 103 return GetUpdatesCallerInfo::UNKNOWN; | 103 return GetUpdatesCallerInfo::UNKNOWN; |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 GetUpdatesCallerInfo::GetUpdatesSource GetSourceFromReason( | |
| 108 sync_api::ConfigureReason reason) { | |
| 109 switch (reason) { | |
| 110 case sync_api::CONFIGURE_REASON_RECONFIGURATION: | |
| 111 return GetUpdatesCallerInfo::RECONFIGURATION; | |
| 112 case sync_api::CONFIGURE_REASON_MIGRATION: | |
| 113 return GetUpdatesCallerInfo::MIGRATION; | |
| 114 case sync_api::CONFIGURE_REASON_NEW_CLIENT: | |
| 115 return GetUpdatesCallerInfo::NEW_CLIENT; | |
| 116 case sync_api::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE: | |
| 117 return GetUpdatesCallerInfo::NEWLY_SUPPORTED_DATATYPE; | |
| 118 default: | |
| 119 NOTREACHED(); | |
| 120 } | |
| 121 | |
| 122 return GetUpdatesCallerInfo::UNKNOWN; | |
| 123 } | |
| 124 | |
| 125 SyncScheduler::WaitInterval::WaitInterval(Mode mode, TimeDelta length) | 107 SyncScheduler::WaitInterval::WaitInterval(Mode mode, TimeDelta length) |
| 126 : mode(mode), had_nudge(false), length(length) { } | 108 : mode(mode), had_nudge(false), length(length) { } |
| 127 | 109 |
| 128 // Helper macros to log with the syncer thread name; useful when there | 110 // Helper macros to log with the syncer thread name; useful when there |
| 129 // are multiple syncer threads involved. | 111 // are multiple syncer threads involved. |
| 130 | 112 |
| 131 #define SLOG(severity) LOG(severity) << name_ << ": " | 113 #define SLOG(severity) LOG(severity) << name_ << ": " |
| 132 | 114 |
| 133 #define SVLOG(verbose_level) VLOG(verbose_level) << name_ << ": " | 115 #define SVLOG(verbose_level) VLOG(verbose_level) << name_ << ": " |
| 134 | 116 |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 if (passive_group_added == false) { | 546 if (passive_group_added == false) { |
| 565 iter it = std::find_if(w_tmp.begin(), w_tmp.end(), | 547 iter it = std::find_if(w_tmp.begin(), w_tmp.end(), |
| 566 ModelSafeWorkerGroupIs(GROUP_PASSIVE)); | 548 ModelSafeWorkerGroupIs(GROUP_PASSIVE)); |
| 567 if (it != w_tmp.end()) | 549 if (it != w_tmp.end()) |
| 568 workers->push_back(*it); | 550 workers->push_back(*it); |
| 569 else | 551 else |
| 570 NOTREACHED(); | 552 NOTREACHED(); |
| 571 } | 553 } |
| 572 } | 554 } |
| 573 | 555 |
| 574 void SyncScheduler::ScheduleConfig(const ModelTypeBitSet& types, | 556 void SyncScheduler::ScheduleConfig( |
| 575 sync_api::ConfigureReason reason) { | 557 const ModelTypeBitSet& types, |
| 558 GetUpdatesCallerInfo::GetUpdatesSource source) { |
| 576 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 559 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 577 SVLOG(2) << "Scheduling a config"; | 560 SVLOG(2) << "Scheduling a config"; |
| 578 ModelSafeRoutingInfo routes; | 561 ModelSafeRoutingInfo routes; |
| 579 std::vector<ModelSafeWorker*> workers; | 562 std::vector<ModelSafeWorker*> workers; |
| 580 GetModelSafeParamsForTypes(types, session_context_->registrar(), | 563 GetModelSafeParamsForTypes(types, session_context_->registrar(), |
| 581 &routes, &workers); | 564 &routes, &workers); |
| 582 | 565 |
| 583 PostTask(FROM_HERE, "ScheduleConfigImpl", | 566 PostTask(FROM_HERE, "ScheduleConfigImpl", |
| 584 method_factory_.NewRunnableMethod( | 567 method_factory_.NewRunnableMethod( |
| 585 &SyncScheduler::ScheduleConfigImpl, routes, workers, | 568 &SyncScheduler::ScheduleConfigImpl, routes, workers, source)); |
| 586 GetSourceFromReason(reason))); | |
| 587 } | 569 } |
| 588 | 570 |
| 589 void SyncScheduler::ScheduleConfigImpl( | 571 void SyncScheduler::ScheduleConfigImpl( |
| 590 const ModelSafeRoutingInfo& routing_info, | 572 const ModelSafeRoutingInfo& routing_info, |
| 591 const std::vector<ModelSafeWorker*>& workers, | 573 const std::vector<ModelSafeWorker*>& workers, |
| 592 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) { | 574 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) { |
| 593 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 575 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 594 | 576 |
| 595 SVLOG(2) << "In ScheduleConfigImpl"; | 577 SVLOG(2) << "In ScheduleConfigImpl"; |
| 596 // TODO(tim): config-specific GetUpdatesCallerInfo value? | 578 // TODO(tim): config-specific GetUpdatesCallerInfo value? |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 | 1087 |
| 1106 #undef SVLOG_LOC | 1088 #undef SVLOG_LOC |
| 1107 | 1089 |
| 1108 #undef SVLOG | 1090 #undef SVLOG |
| 1109 | 1091 |
| 1110 #undef SLOG | 1092 #undef SLOG |
| 1111 | 1093 |
| 1112 #undef ENUM_CASE | 1094 #undef ENUM_CASE |
| 1113 | 1095 |
| 1114 } // browser_sync | 1096 } // browser_sync |
| OLD | NEW |