| 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/model_changing_syncer_command.h" | 5 #include "chrome/browser/sync/engine/model_changing_syncer_command.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" |
| 7 #include "base/callback_old.h" | 8 #include "base/callback_old.h" |
| 8 #include "chrome/browser/sync/engine/model_safe_worker.h" | 9 #include "chrome/browser/sync/engine/model_safe_worker.h" |
| 9 #include "chrome/browser/sync/sessions/status_controller.h" | 10 #include "chrome/browser/sync/sessions/status_controller.h" |
| 10 #include "chrome/browser/sync/sessions/sync_session.h" | 11 #include "chrome/browser/sync/sessions/sync_session.h" |
| 12 #include "chrome/browser/sync/util/unrecoverable_error_info.h" |
| 11 | 13 |
| 12 namespace browser_sync { | 14 namespace browser_sync { |
| 13 | 15 |
| 14 void ModelChangingSyncerCommand::ExecuteImpl(sessions::SyncSession* session) { | 16 void ModelChangingSyncerCommand::ExecuteImpl(sessions::SyncSession* session) { |
| 15 work_session_ = session; | 17 work_session_ = session; |
| 16 if (!ModelNeutralExecuteImpl(work_session_)) { | 18 if (!ModelNeutralExecuteImpl(work_session_)) { |
| 17 return; | 19 return; |
| 18 } | 20 } |
| 19 | 21 |
| 20 // Project the list of active types (i.e., types in the routing | 22 // Project the list of active types (i.e., types in the routing |
| (...skipping 17 matching lines...) Expand all Loading... |
| 38 ModelSafeGroup group = worker->GetModelSafeGroup(); | 40 ModelSafeGroup group = worker->GetModelSafeGroup(); |
| 39 // Skip workers whose group isn't active. | 41 // Skip workers whose group isn't active. |
| 40 if (active_groups.find(group) == active_groups.end()) { | 42 if (active_groups.find(group) == active_groups.end()) { |
| 41 VLOG(2) << "Skipping worker for group " | 43 VLOG(2) << "Skipping worker for group " |
| 42 << ModelSafeGroupToString(group); | 44 << ModelSafeGroupToString(group); |
| 43 continue; | 45 continue; |
| 44 } | 46 } |
| 45 | 47 |
| 46 sessions::StatusController* status = work_session_->status_controller(); | 48 sessions::StatusController* status = work_session_->status_controller(); |
| 47 sessions::ScopedModelSafeGroupRestriction r(status, group); | 49 sessions::ScopedModelSafeGroupRestriction r(status, group); |
| 48 scoped_ptr<Callback0::Type> c(NewCallback(this, | 50 WorkCallback c = base::Bind( |
| 49 &ModelChangingSyncerCommand::StartChangingModel)); | 51 &ModelChangingSyncerCommand::StartChangingModel, |
| 50 worker->DoWorkAndWaitUntilDone(c.get()); | 52 // We wait until the callback is executed. So it is safe to use |
| 53 // unretained. |
| 54 base::Unretained(this)); |
| 55 |
| 56 // TODO(lipalani): Check the return value for an unrecoverable error. |
| 57 ignore_result(worker->DoWorkAndWaitUntilDone(c)); |
| 58 |
| 51 } | 59 } |
| 52 } | 60 } |
| 53 | 61 |
| 54 bool ModelChangingSyncerCommand::ModelNeutralExecuteImpl( | 62 bool ModelChangingSyncerCommand::ModelNeutralExecuteImpl( |
| 55 sessions::SyncSession* session) { | 63 sessions::SyncSession* session) { |
| 56 return true; | 64 return true; |
| 57 } | 65 } |
| 58 | 66 |
| 59 } // namespace browser_sync | 67 } // namespace browser_sync |
| OLD | NEW |