| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 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 | 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_DOWNLOAD_UPDATES_COMMAND_H_ | 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_DOWNLOAD_UPDATES_COMMAND_H_ |
| 6 #define CHROME_BROWSER_SYNC_ENGINE_DOWNLOAD_UPDATES_COMMAND_H_ | 6 #define CHROME_BROWSER_SYNC_ENGINE_DOWNLOAD_UPDATES_COMMAND_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "chrome/browser/sync/engine/model_safe_worker.h" | 10 #include "chrome/browser/sync/engine/model_safe_worker.h" |
| 11 #include "chrome/browser/sync/engine/syncer_command.h" | 11 #include "chrome/browser/sync/engine/syncer_command.h" |
| 12 #include "chrome/browser/sync/syncable/model_type.h" | 12 #include "chrome/browser/sync/syncable/model_type.h" |
| 13 | 13 |
| 14 namespace sync_pb { | 14 namespace sync_pb { |
| 15 class EntitySpecifics; | 15 class EntitySpecifics; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace browser_sync { | 18 namespace browser_sync { |
| 19 | 19 |
| 20 // Pick a subset of the enabled datatypes, download updates for them from | 20 // Determine the enabled datatypes, download a batch of updates for them |
| 21 // the server, place the result in the SyncSession for further processing. | 21 // from the server, place the result in the SyncSession for further processing. |
| 22 // | 22 // |
| 23 // The main inputs to this operation are the last_download_timestamp state | 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 | 24 // in the syncable::Directory, and the set of enabled types as indicated by |
| 25 // the SyncSession. DownloadUpdatesCommand will fetch the enabled type | 25 // the SyncSession. DownloadUpdatesCommand will fetch updates for |
| 26 // or types having the smallest (oldest) value for last_download_timestamp. | 26 // all the enabled types, using download_progress to indicate the starting |
| 27 // DownloadUpdatesCommand will request a download of those types and will | 27 // point to the server. DownloadUpdatesCommand store the server response |
| 28 // store the server response in the SyncSession. Only one server request | 28 // in the SyncSession. Only one server request is performed per Execute |
| 29 // is performed per Execute operation. A loop that causes multiple Execute | 29 // operation. A loop that causes multiple Execute operations within a sync |
| 30 // operations within a sync session can be found in the Syncer logic. | 30 // session can be found in the Syncer logic. When looping, the |
| 31 // When looping, the DownloadUpdatesCommand consumes the information stored | 31 // DownloadUpdatesCommand consumes the information stored by the |
| 32 // by the StoreTimestampsCommand. | 32 // StoreTimestampsCommand. |
| 33 // | 33 // |
| 34 // In practice, DownloadUpdatesCommand should exhibit one of two behaviors. | 34 // In practice, DownloadUpdatesCommand should loop until all updates are |
| 35 // (a) If one or more datatypes has just been enabled, then they will have the | 35 // downloaded for all enabled datatypes (i.e., until the server indicates |
| 36 // oldest last_download_timestamp value (0). DownloadUpdatesCommand will | 36 // changes_remaining == 0 in the GetUpdates response), or until an error |
| 37 // choose to download updates for those types, and likely this will happen | 37 // is encountered. |
| 38 // for several invocations of DownloadUpdatesCommand. Once the newly | |
| 39 // enabled types have caught up to the timestamp value of any previously | |
| 40 // enabled timestamps, DownloadUpdatesCommand will do a fetch for those | |
| 41 // datatypes. If nothing has changed on the server in the meantime, | |
| 42 // then the timestamp value for the new and old datatypes will now match. | |
| 43 // When that happens (and it eventually should), we have entered case (b). | |
| 44 // (b) The common case is for all enabled datatypes to have the same | |
| 45 // last_download_timestamp value. This means that one server request | |
| 46 // tells us whether there are updates available to any datatype. When | |
| 47 // the last_download_timestamp values for two datatypes is identical, | |
| 48 // those datatypes will never be separately requested, and the values | |
| 49 // will stay in lockstep indefinitely. | |
| 50 class DownloadUpdatesCommand : public SyncerCommand { | 38 class DownloadUpdatesCommand : public SyncerCommand { |
| 51 public: | 39 public: |
| 52 DownloadUpdatesCommand(); | 40 DownloadUpdatesCommand(); |
| 53 virtual ~DownloadUpdatesCommand(); | 41 virtual ~DownloadUpdatesCommand(); |
| 54 | 42 |
| 55 // SyncerCommand implementation. | 43 // SyncerCommand implementation. |
| 56 virtual void ExecuteImpl(sessions::SyncSession* session); | 44 virtual void ExecuteImpl(sessions::SyncSession* session); |
| 57 | 45 |
| 58 void SetRequestedTypes(const syncable::ModelTypeBitSet& target_datatypes, | 46 void SetRequestedTypes(const syncable::ModelTypeBitSet& target_datatypes, |
| 59 sync_pb::EntitySpecifics* filter_protobuf); | 47 sync_pb::EntitySpecifics* filter_protobuf); |
| 60 | 48 |
| 61 private: | 49 private: |
| 62 DISALLOW_COPY_AND_ASSIGN(DownloadUpdatesCommand); | 50 DISALLOW_COPY_AND_ASSIGN(DownloadUpdatesCommand); |
| 63 }; | 51 }; |
| 64 | 52 |
| 65 } // namespace browser_sync | 53 } // namespace browser_sync |
| 66 | 54 |
| 67 #endif // CHROME_BROWSER_SYNC_ENGINE_DOWNLOAD_UPDATES_COMMAND_H_ | 55 #endif // CHROME_BROWSER_SYNC_ENGINE_DOWNLOAD_UPDATES_COMMAND_H_ |
| 68 | 56 |
| OLD | NEW |