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