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 #ifndef CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ | 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ |
6 #define CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ | 6 #define CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include "base/compiler_specific.h" |
9 #include "chrome/browser/sync/engine/syncer_command.h" | 10 #include "chrome/browser/sync/engine/syncer_command.h" |
10 #include "chrome/browser/sync/util/unrecoverable_error_info.h" | 11 #include "chrome/browser/sync/util/unrecoverable_error_info.h" |
11 | 12 |
12 namespace browser_sync { | 13 namespace browser_sync { |
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 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 void ExecuteImpl(sessions::SyncSession* session); | 34 virtual void 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 UnrecoverableErrorInfo StartChangingModel() { | 37 UnrecoverableErrorInfo StartChangingModel() { |
37 // TODO(lipalani): |ModelChangingExecuteImpl| should return an | 38 // TODO(lipalani): |ModelChangingExecuteImpl| should return an |
38 // UnrecoverableErrorInfo struct. | 39 // UnrecoverableErrorInfo struct. |
39 ModelChangingExecuteImpl(work_session_); | 40 ModelChangingExecuteImpl(work_session_); |
40 return UnrecoverableErrorInfo(); | 41 return UnrecoverableErrorInfo(); |
41 } | 42 } |
42 | 43 |
43 // Sometimes, a command has work to do that needs to touch global state | 44 // Sometimes, a command has work to do that needs to touch global state |
(...skipping 16 matching lines...) Expand all Loading... |
60 // Implementations will implement ModelChangingExecuteImpl and not | 61 // Implementations will implement ModelChangingExecuteImpl and not |
61 // worry about storing the session or setting it. They are given work_session. | 62 // worry about storing the session or setting it. They are given work_session. |
62 sessions::SyncSession* work_session_; | 63 sessions::SyncSession* work_session_; |
63 | 64 |
64 DISALLOW_COPY_AND_ASSIGN(ModelChangingSyncerCommand); | 65 DISALLOW_COPY_AND_ASSIGN(ModelChangingSyncerCommand); |
65 }; | 66 }; |
66 | 67 |
67 } // namespace browser_sync | 68 } // namespace browser_sync |
68 | 69 |
69 #endif // CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ | 70 #endif // CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ |
OLD | NEW |