OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ |
| 6 #define CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ |
| 7 |
| 8 #include "chrome/browser/sync/engine/syncer_command.h" |
| 9 |
| 10 namespace browser_sync { |
| 11 |
| 12 // An abstract SyncerCommand which dispatches its Execute step to the |
| 13 // model-safe worker thread. Classes derived from ModelChangingSyncerCommand |
| 14 // instead of SyncerCommand must implement ModelChangingExecuteImpl instead of |
| 15 // ExecuteImpl, but otherwise, the contract is the same. |
| 16 // |
| 17 // A command should derive from ModelChangingSyncerCommand instead of |
| 18 // SyncerCommand whenever the operation might change any client-visible |
| 19 // fields on any syncable::Entry. If the operation involves creating a |
| 20 // WriteTransaction, this is a sign that ModelChangingSyncerCommand is likely |
| 21 // necessary. |
| 22 class ModelChangingSyncerCommand : public SyncerCommand { |
| 23 public: |
| 24 ModelChangingSyncerCommand() : work_session_(NULL) { } |
| 25 virtual ~ModelChangingSyncerCommand() { } |
| 26 |
| 27 // SyncerCommand implementation. Sets work_session to session. |
| 28 virtual void ExecuteImpl(SyncerSession* session); |
| 29 |
| 30 // wrapper so implementations don't worry about storing work_session |
| 31 void StartChangingModel() { |
| 32 ModelChangingExecuteImpl(work_session_); |
| 33 } |
| 34 |
| 35 // Abstract method to be implemented by subclasses. |
| 36 virtual void ModelChangingExecuteImpl(SyncerSession* session) = 0; |
| 37 |
| 38 private: |
| 39 // ExecuteImpl is expected to be run by SyncerCommand to set work_session. |
| 40 // StartChangingModel is called to start this command running. |
| 41 // Implementations will implement ModelChangingExecuteImpl and not |
| 42 // worry about storing the session or setting it. They are given work_session. |
| 43 SyncerSession* work_session_; |
| 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(ModelChangingSyncerCommand); |
| 46 }; |
| 47 |
| 48 } // namespace browser_sync |
| 49 |
| 50 #endif // CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ |
OLD | NEW |