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