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