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_session_job.h" | 5 #include "sync/engine/sync_session_job.h" |
| 6 #include "sync/internal_api/public/sessions/model_neutral_state.h" | 6 #include "sync/internal_api/public/sessions/model_neutral_state.h" |
| 7 | 7 |
| 8 namespace syncer { | 8 namespace syncer { |
| 9 | 9 |
| 10 SyncSessionJob::~SyncSessionJob() { | 10 SyncSessionJob::~SyncSessionJob() { |
| 11 } | 11 } |
| 12 | 12 |
| 13 SyncSessionJob::SyncSessionJob( | 13 SyncSessionJob::SyncSessionJob( |
| 14 Purpose purpose, | 14 Purpose purpose, |
| 15 base::TimeTicks start, | 15 base::TimeTicks start, |
| 16 const sessions::SyncSourceInfo& source_info, | 16 const sessions::SyncSourceInfo& source_info, |
| 17 const ConfigurationParams& config_params) | 17 const ConfigurationParams& config_params) |
| 18 : purpose_(purpose), | 18 : purpose_(purpose), |
| 19 source_info_(source_info), | 19 source_info_(source_info), |
| 20 scheduled_start_(start), | 20 scheduled_start_(start), |
| 21 config_params_(config_params), | 21 config_params_(config_params) { |
| 22 finished_(NOT_FINISHED) { | |
| 23 } | 22 } |
| 24 | 23 |
| 25 #define ENUM_CASE(x) case x: return #x; break; | 24 #define ENUM_CASE(x) case x: return #x; break; |
| 26 const char* SyncSessionJob::GetPurposeString(SyncSessionJob::Purpose purpose) { | 25 const char* SyncSessionJob::GetPurposeString(SyncSessionJob::Purpose purpose) { |
| 27 switch (purpose) { | 26 switch (purpose) { |
| 28 ENUM_CASE(UNKNOWN); | 27 ENUM_CASE(UNKNOWN); |
| 29 ENUM_CASE(POLL); | 28 ENUM_CASE(POLL); |
| 30 ENUM_CASE(NUDGE); | 29 ENUM_CASE(NUDGE); |
| 31 ENUM_CASE(CONFIGURATION); | 30 ENUM_CASE(CONFIGURATION); |
| 32 } | 31 } |
| 33 NOTREACHED(); | 32 NOTREACHED(); |
| 34 return ""; | 33 return ""; |
| 35 } | 34 } |
| 36 #undef ENUM_CASE | 35 #undef ENUM_CASE |
| 37 | 36 |
| 38 bool SyncSessionJob::Finish(bool early_exit, sessions::SyncSession* session) { | 37 bool SyncSessionJob::Finish(bool early_exit, sessions::SyncSession* session) { |
| 39 DCHECK_EQ(finished_, NOT_FINISHED); | |
| 40 // Did we run through all SyncerSteps from start_step() to end_step() | |
|
tim (not reviewing)
2013/04/05 19:30:36
This comment still applies, I think, it was just i
| |
| 41 // until the SyncSession returned !HasMoreToSync()? | |
| 42 // Note: if not, it's possible the scheduler hasn't started with | |
| 43 // SyncShare yet, it's possible there is still more to sync in the session, | |
| 44 // and it's also possible the job quit part way through due to a premature | |
| 45 // exit condition (such as shutdown). | |
| 46 finished_ = early_exit ? EARLY_EXIT : FINISHED; | |
| 47 | |
| 48 if (early_exit) | 38 if (early_exit) |
| 49 return false; | 39 return false; |
| 50 | 40 |
| 51 // Did we hit any errors along the way? | 41 // Did we hit any errors along the way? |
| 52 if (sessions::HasSyncerError( | 42 if (sessions::HasSyncerError( |
| 53 session->status_controller().model_neutral_state())) { | 43 session->status_controller().model_neutral_state())) { |
| 54 return false; | 44 return false; |
| 55 } | 45 } |
| 56 | 46 |
| 57 const sessions::ModelNeutralState& state( | 47 const sessions::ModelNeutralState& state( |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 68 case UNKNOWN: | 58 case UNKNOWN: |
| 69 default: | 59 default: |
| 70 NOTREACHED(); | 60 NOTREACHED(); |
| 71 } | 61 } |
| 72 | 62 |
| 73 if (!config_params_.ready_task.is_null()) | 63 if (!config_params_.ready_task.is_null()) |
| 74 config_params_.ready_task.Run(); | 64 config_params_.ready_task.Run(); |
| 75 return true; | 65 return true; |
| 76 } | 66 } |
| 77 | 67 |
| 78 scoped_ptr<SyncSessionJob> SyncSessionJob::Clone() const { | |
| 79 return scoped_ptr<SyncSessionJob>(new SyncSessionJob( | |
| 80 purpose_, scheduled_start_, source_info_, | |
| 81 config_params_)); | |
| 82 } | |
| 83 | |
| 84 void SyncSessionJob::CoalesceSources(const sessions::SyncSourceInfo& source) { | 68 void SyncSessionJob::CoalesceSources(const sessions::SyncSourceInfo& source) { |
| 85 CoalesceStates(source.types, &source_info_.types); | 69 CoalesceStates(source.types, &source_info_.types); |
| 86 source_info_.updates_source = source.updates_source; | 70 source_info_.updates_source = source.updates_source; |
| 87 } | 71 } |
| 88 | 72 |
| 89 SyncSessionJob::Purpose SyncSessionJob::purpose() const { | 73 SyncSessionJob::Purpose SyncSessionJob::purpose() const { |
| 90 return purpose_; | 74 return purpose_; |
| 91 } | 75 } |
| 92 | 76 |
| 93 const sessions::SyncSourceInfo& SyncSessionJob::source_info() const { | 77 const sessions::SyncSourceInfo& SyncSessionJob::source_info() const { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 return; | 118 return; |
| 135 default: | 119 default: |
| 136 NOTREACHED(); | 120 NOTREACHED(); |
| 137 *start = SYNCER_END; | 121 *start = SYNCER_END; |
| 138 *end = SYNCER_END; | 122 *end = SYNCER_END; |
| 139 return; | 123 return; |
| 140 } | 124 } |
| 141 } | 125 } |
| 142 | 126 |
| 143 } // namespace syncer | 127 } // namespace syncer |
| OLD | NEW |