Home | History | Annotate | Download | only in engine
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_SYNC_ENGINE_DOWNLOAD_UPDATES_COMMAND_H_
      6 #define CHROME_BROWSER_SYNC_ENGINE_DOWNLOAD_UPDATES_COMMAND_H_
      7 #pragma once
      8 
      9 #include "base/basictypes.h"
     10 #include "chrome/browser/sync/engine/model_safe_worker.h"
     11 #include "chrome/browser/sync/engine/syncer_command.h"
     12 #include "chrome/browser/sync/syncable/model_type.h"
     13 
     14 namespace sync_pb {
     15 class EntitySpecifics;
     16 }
     17 
     18 namespace browser_sync {
     19 
     20 // Determine the enabled datatypes, download a batch of updates for them
     21 // from the server, place the result in the SyncSession for further processing.
     22 //
     23 // The main inputs to this operation are the download_progress state
     24 // in the syncable::Directory, and the set of enabled types as indicated by
     25 // the SyncSession. DownloadUpdatesCommand will fetch updates for
     26 // all the enabled types, using download_progress to indicate the starting
     27 // point to the server. DownloadUpdatesCommand stores the server response
     28 // in the SyncSession. Only one server request is performed per Execute
     29 // operation. A loop that causes multiple Execute operations within a sync
     30 // session can be found in the Syncer logic. When looping, the
     31 // DownloadUpdatesCommand consumes the information stored by the
     32 // StoreTimestampsCommand.
     33 //
     34 // In practice, DownloadUpdatesCommand should loop until all updates are
     35 // downloaded for all enabled datatypes (i.e., until the server indicates
     36 // changes_remaining == 0 in the GetUpdates response), or until an error
     37 // is encountered.
     38 class DownloadUpdatesCommand : public SyncerCommand {
     39  public:
     40   DownloadUpdatesCommand();
     41   virtual ~DownloadUpdatesCommand();
     42 
     43   // SyncerCommand implementation.
     44   virtual void ExecuteImpl(sessions::SyncSession* session);
     45 
     46   void SetRequestedTypes(const syncable::ModelTypeBitSet& target_datatypes,
     47                          sync_pb::EntitySpecifics* filter_protobuf);
     48 
     49  private:
     50   DISALLOW_COPY_AND_ASSIGN(DownloadUpdatesCommand);
     51 };
     52 
     53 }  // namespace browser_sync
     54 
     55 #endif  // CHROME_BROWSER_SYNC_ENGINE_DOWNLOAD_UPDATES_COMMAND_H_
     56 
     57