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