| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "sync/engine/syncer_command.h" | 10 #include "sync/engine/syncer_command.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // This should return the set of groups in |session| that need to be | 48 // This should return the set of groups in |session| that need to be |
| 49 // changed. The returned set should be a subset of | 49 // changed. The returned set should be a subset of |
| 50 // session.GetEnabledGroups(). Subclasses can guarantee this either | 50 // session.GetEnabledGroups(). Subclasses can guarantee this either |
| 51 // by calling one of the session.GetEnabledGroups*() functions and | 51 // by calling one of the session.GetEnabledGroups*() functions and |
| 52 // filtering that, or using GetGroupForModelType() (which handles | 52 // filtering that, or using GetGroupForModelType() (which handles |
| 53 // top-level/unspecified nodes) to project from model types to | 53 // top-level/unspecified nodes) to project from model types to |
| 54 // groups. | 54 // groups. |
| 55 virtual std::set<ModelSafeGroup> GetGroupsToChange( | 55 virtual std::set<ModelSafeGroup> GetGroupsToChange( |
| 56 const sessions::SyncSession& session) const = 0; | 56 const sessions::SyncSession& session) const = 0; |
| 57 | 57 |
| 58 // Sometimes, a command has work to do that needs to touch global state | |
| 59 // belonging to multiple ModelSafeGroups, but in a way that is known to be | |
| 60 // safe. This will be called once, prior to ModelChangingExecuteImpl, | |
| 61 // *without* a ModelSafeGroup restriction in place on the SyncSession. | |
| 62 // Returns true on success, false on failure. | |
| 63 // TODO(tim): Remove this (bug 36594). | |
| 64 virtual SyncerError ModelNeutralExecuteImpl(sessions::SyncSession* session); | |
| 65 | |
| 66 // Abstract method to be implemented by subclasses to handle logic that | 58 // Abstract method to be implemented by subclasses to handle logic that |
| 67 // operates on the model. This is invoked with a SyncSession ModelSafeGroup | 59 // operates on the model. This is invoked with a SyncSession ModelSafeGroup |
| 68 // restriction in place so that bits of state belonging to data types | 60 // restriction in place so that bits of state belonging to data types |
| 69 // running on an unsafe thread are siloed away. | 61 // running on an unsafe thread are siloed away. |
| 70 virtual SyncerError ModelChangingExecuteImpl( | 62 virtual SyncerError ModelChangingExecuteImpl( |
| 71 sessions::SyncSession* session) = 0; | 63 sessions::SyncSession* session) = 0; |
| 72 | 64 |
| 73 private: | 65 private: |
| 74 // ExecuteImpl is expected to be run by SyncerCommand to set work_session. | 66 // ExecuteImpl is expected to be run by SyncerCommand to set work_session. |
| 75 // StartChangingModel is called to start this command running. | 67 // StartChangingModel is called to start this command running. |
| 76 // Implementations will implement ModelChangingExecuteImpl and not | 68 // Implementations will implement ModelChangingExecuteImpl and not |
| 77 // worry about storing the session or setting it. They are given work_session. | 69 // worry about storing the session or setting it. They are given work_session. |
| 78 sessions::SyncSession* work_session_; | 70 sessions::SyncSession* work_session_; |
| 79 | 71 |
| 80 DISALLOW_COPY_AND_ASSIGN(ModelChangingSyncerCommand); | 72 DISALLOW_COPY_AND_ASSIGN(ModelChangingSyncerCommand); |
| 81 }; | 73 }; |
| 82 | 74 |
| 83 } // namespace browser_sync | 75 } // namespace browser_sync |
| 84 | 76 |
| 85 #endif // SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ | 77 #endif // SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_ |
| OLD | NEW |