| 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 #ifndef SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ | 5 #ifndef SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ |
| 6 #define SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ | 6 #define SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "sync/engine/syncer_command.h" | 10 #include "sync/engine/syncer_command.h" |
| 11 #include "sync/internal_api/public/engine/model_safe_worker.h" | 11 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 12 | 12 |
| 13 namespace csync { | 13 namespace syncer { |
| 14 namespace sessions { | 14 namespace sessions { |
| 15 class SyncSession; | 15 class SyncSession; |
| 16 } | 16 } |
| 17 | 17 |
| 18 // An abstract SyncerCommand which dispatches its Execute step to the | 18 // An abstract SyncerCommand which dispatches its Execute step to the |
| 19 // model-safe worker thread. Classes derived from ModelChangingSyncerCommand | 19 // model-safe worker thread. Classes derived from ModelChangingSyncerCommand |
| 20 // instead of SyncerCommand must implement ModelChangingExecuteImpl instead of | 20 // instead of SyncerCommand must implement ModelChangingExecuteImpl instead of |
| 21 // ExecuteImpl, but otherwise, the contract is the same. | 21 // ExecuteImpl, but otherwise, the contract is the same. |
| 22 // | 22 // |
| 23 // A command should derive from ModelChangingSyncerCommand instead of | 23 // A command should derive from ModelChangingSyncerCommand instead of |
| 24 // SyncerCommand whenever the operation might change any client-visible | 24 // SyncerCommand whenever the operation might change any client-visible |
| 25 // fields on any syncable::Entry. If the operation involves creating a | 25 // fields on any syncable::Entry. If the operation involves creating a |
| 26 // WriteTransaction, this is a sign that ModelChangingSyncerCommand is likely | 26 // WriteTransaction, this is a sign that ModelChangingSyncerCommand is likely |
| 27 // necessary. | 27 // necessary. |
| 28 class ModelChangingSyncerCommand : public SyncerCommand { | 28 class ModelChangingSyncerCommand : public SyncerCommand { |
| 29 public: | 29 public: |
| 30 ModelChangingSyncerCommand() : work_session_(NULL) { } | 30 ModelChangingSyncerCommand() : work_session_(NULL) { } |
| 31 virtual ~ModelChangingSyncerCommand() { } | 31 virtual ~ModelChangingSyncerCommand() { } |
| 32 | 32 |
| 33 // SyncerCommand implementation. Sets work_session to session. | 33 // SyncerCommand implementation. Sets work_session to session. |
| 34 virtual csync::SyncerError ExecuteImpl( | 34 virtual syncer::SyncerError ExecuteImpl( |
| 35 sessions::SyncSession* session) OVERRIDE; | 35 sessions::SyncSession* session) OVERRIDE; |
| 36 | 36 |
| 37 // Wrapper so implementations don't worry about storing work_session. | 37 // Wrapper so implementations don't worry about storing work_session. |
| 38 SyncerError StartChangingModel() { | 38 SyncerError StartChangingModel() { |
| 39 return ModelChangingExecuteImpl(work_session_); | 39 return ModelChangingExecuteImpl(work_session_); |
| 40 } | 40 } |
| 41 | 41 |
| 42 std::set<ModelSafeGroup> GetGroupsToChangeForTest( | 42 std::set<ModelSafeGroup> GetGroupsToChangeForTest( |
| 43 const sessions::SyncSession& session) const { | 43 const sessions::SyncSession& session) const { |
| 44 return GetGroupsToChange(session); | 44 return GetGroupsToChange(session); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 65 private: | 65 private: |
| 66 // ExecuteImpl is expected to be run by SyncerCommand to set work_session. | 66 // ExecuteImpl is expected to be run by SyncerCommand to set work_session. |
| 67 // StartChangingModel is called to start this command running. | 67 // StartChangingModel is called to start this command running. |
| 68 // Implementations will implement ModelChangingExecuteImpl and not | 68 // Implementations will implement ModelChangingExecuteImpl and not |
| 69 // worry about storing the session or setting it. They are given work_session. | 69 // worry about storing the session or setting it. They are given work_session. |
| 70 sessions::SyncSession* work_session_; | 70 sessions::SyncSession* work_session_; |
| 71 | 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(ModelChangingSyncerCommand); | 72 DISALLOW_COPY_AND_ASSIGN(ModelChangingSyncerCommand); |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 } // namespace csync | 75 } // namespace syncer |
| 76 | 76 |
| 77 #endif // SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ | 77 #endif // SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ |
| OLD | NEW |