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 "chrome/browser/sync/engine/syncer_command.h" | 9 #include "chrome/browser/sync/engine/syncer_command.h" |
10 #include "chrome/browser/sync/util/unrecoverable_error_info.h" | 10 #include "chrome/browser/sync/util/unrecoverable_error_info.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 virtual void ExecuteImpl(sessions::SyncSession* session); | 33 virtual void ExecuteImpl(sessions::SyncSession* session); |
34 | 34 |
35 // wrapper so implementations don't worry about storing work_session | 35 // wrapper so implementations don't worry about storing work_session |
36 UnrecoverableErrorInfo StartChangingModel() { | 36 UnrecoverableErrorInfo StartChangingModel() { |
37 // TODO(lipalani): |ModelChangingExecuteImpl| should return an | 37 // TODO(lipalani): |ModelChangingExecuteImpl| should return an |
38 // UnrecoverableErrorInfo struct. | 38 // UnrecoverableErrorInfo struct. |
39 ModelChangingExecuteImpl(work_session_); | 39 ModelChangingExecuteImpl(work_session_); |
40 return UnrecoverableErrorInfo(); | 40 return UnrecoverableErrorInfo(); |
41 } | 41 } |
42 | 42 |
| 43 // Sometimes, a command has work to do that needs to touch global state |
| 44 // belonging to multiple ModelSafeGroups, but in a way that is known to be |
| 45 // safe. This will be called once, prior to ModelChangingExecuteImpl, |
| 46 // *without* a ModelSafeGroup restriction in place on the SyncSession. |
| 47 // Returns true on success, false on failure. |
| 48 // TODO(tim): Remove this (bug 36594). |
| 49 virtual bool ModelNeutralExecuteImpl(sessions::SyncSession* session); |
| 50 |
43 // Abstract method to be implemented by subclasses to handle logic that | 51 // Abstract method to be implemented by subclasses to handle logic that |
44 // operates on the model. This is invoked with a SyncSession ModelSafeGroup | 52 // operates on the model. This is invoked with a SyncSession ModelSafeGroup |
45 // restriction in place so that bits of state belonging to data types | 53 // restriction in place so that bits of state belonging to data types |
46 // running on an unsafe thread are siloed away. | 54 // running on an unsafe thread are siloed away. |
47 virtual void ModelChangingExecuteImpl(sessions::SyncSession* session) = 0; | 55 virtual void ModelChangingExecuteImpl(sessions::SyncSession* session) = 0; |
48 | 56 |
49 private: | 57 private: |
50 // ExecuteImpl is expected to be run by SyncerCommand to set work_session. | 58 // ExecuteImpl is expected to be run by SyncerCommand to set work_session. |
51 // StartChangingModel is called to start this command running. | 59 // StartChangingModel is called to start this command running. |
52 // Implementations will implement ModelChangingExecuteImpl and not | 60 // Implementations will implement ModelChangingExecuteImpl and not |
53 // worry about storing the session or setting it. They are given work_session. | 61 // worry about storing the session or setting it. They are given work_session. |
54 sessions::SyncSession* work_session_; | 62 sessions::SyncSession* work_session_; |
55 | 63 |
56 DISALLOW_COPY_AND_ASSIGN(ModelChangingSyncerCommand); | 64 DISALLOW_COPY_AND_ASSIGN(ModelChangingSyncerCommand); |
57 }; | 65 }; |
58 | 66 |
59 } // namespace browser_sync | 67 } // namespace browser_sync |
60 | 68 |
61 #endif // CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ | 69 #endif // CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ |
OLD | NEW |