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