| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_SYNCER_COMMAND_H_ | 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNCER_COMMAND_H_ |
| 6 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_COMMAND_H_ | 6 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_COMMAND_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 | 9 |
| 10 namespace browser_sync { | 10 namespace browser_sync { |
| 11 | 11 |
| 12 class SyncerSession; | 12 namespace sessions { |
| 13 class SyncSession; |
| 14 } |
| 13 | 15 |
| 14 // Implementation of a simple command pattern intended to be driven by the | 16 // Implementation of a simple command pattern intended to be driven by the |
| 15 // Syncer. SyncerCommand is abstract and all subclasses must implement | 17 // Syncer. SyncerCommand is abstract and all subclasses must implement |
| 16 // ExecuteImpl(). This is done so that chunks of syncer operation can be unit | 18 // ExecuteImpl(). This is done so that chunks of syncer operation can be unit |
| 17 // tested. | 19 // tested. |
| 18 // | 20 // |
| 19 // Example Usage: | 21 // Example Usage: |
| 20 // | 22 // |
| 21 // SyncerSession session = ...; | 23 // SyncSession session = ...; |
| 22 // SyncerCommand *cmd = SomeCommandFactory.createCommand(...); | 24 // SyncerCommand *cmd = SomeCommandFactory.createCommand(...); |
| 23 // cmd->Execute(session); | 25 // cmd->Execute(session); |
| 24 // delete cmd; | 26 // delete cmd; |
| 25 | 27 |
| 26 class SyncerCommand { | 28 class SyncerCommand { |
| 27 public: | 29 public: |
| 28 SyncerCommand(); | 30 SyncerCommand(); |
| 29 virtual ~SyncerCommand(); | 31 virtual ~SyncerCommand(); |
| 30 | 32 |
| 31 // Execute dispatches to a derived class's ExecuteImpl. | 33 // Execute dispatches to a derived class's ExecuteImpl. |
| 32 void Execute(SyncerSession* session); | 34 void Execute(sessions::SyncSession* session); |
| 33 | 35 |
| 34 // ExecuteImpl is where derived classes actually do work. | 36 // ExecuteImpl is where derived classes actually do work. |
| 35 virtual void ExecuteImpl(SyncerSession* session) = 0; | 37 virtual void ExecuteImpl(sessions::SyncSession* session) = 0; |
| 36 private: | 38 private: |
| 37 void SendNotifications(SyncerSession* session); | 39 void SendNotifications(sessions::SyncSession* session); |
| 38 DISALLOW_COPY_AND_ASSIGN(SyncerCommand); | 40 DISALLOW_COPY_AND_ASSIGN(SyncerCommand); |
| 39 }; | 41 }; |
| 40 | 42 |
| 41 } // namespace browser_sync | 43 } // namespace browser_sync |
| 42 | 44 |
| 43 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_COMMAND_H_ | 45 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_COMMAND_H_ |
| OLD | NEW |