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 | |
51 // Abstract method to be implemented by subclasses to handle logic that | 43 // Abstract method to be implemented by subclasses to handle logic that |
52 // operates on the model. This is invoked with a SyncSession ModelSafeGroup | 44 // operates on the model. This is invoked with a SyncSession ModelSafeGroup |
53 // restriction in place so that bits of state belonging to data types | 45 // restriction in place so that bits of state belonging to data types |
54 // running on an unsafe thread are siloed away. | 46 // running on an unsafe thread are siloed away. |
55 virtual void ModelChangingExecuteImpl(sessions::SyncSession* session) = 0; | 47 virtual void ModelChangingExecuteImpl(sessions::SyncSession* session) = 0; |
56 | 48 |
57 private: | 49 private: |
58 // ExecuteImpl is expected to be run by SyncerCommand to set work_session. | 50 // ExecuteImpl is expected to be run by SyncerCommand to set work_session. |
59 // StartChangingModel is called to start this command running. | 51 // StartChangingModel is called to start this command running. |
60 // Implementations will implement ModelChangingExecuteImpl and not | 52 // Implementations will implement ModelChangingExecuteImpl and not |
61 // worry about storing the session or setting it. They are given work_session. | 53 // worry about storing the session or setting it. They are given work_session. |
62 sessions::SyncSession* work_session_; | 54 sessions::SyncSession* work_session_; |
63 | 55 |
64 DISALLOW_COPY_AND_ASSIGN(ModelChangingSyncerCommand); | 56 DISALLOW_COPY_AND_ASSIGN(ModelChangingSyncerCommand); |
65 }; | 57 }; |
66 | 58 |
67 } // namespace browser_sync | 59 } // namespace browser_sync |
68 | 60 |
69 #endif // CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ | 61 #endif // CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ |
OLD | NEW |