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