OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_API_SYNC_CHANGE_H_ |
| 6 #define CHROME_BROWSER_SYNC_API_SYNC_CHANGE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "chrome/browser/sync/api/sync_data.h" |
| 13 |
| 14 // A SyncChange object reflects a change to a piece of synced data. The change |
| 15 // can be either a delete, add, or an update. All data relevant to the change |
| 16 // is encapsulated within the SyncChange, which, once created, is immutable. |
| 17 // Note: it is safe and cheap to pass these by value or make copies, as they do |
| 18 // not create deep copies of their internal data. |
| 19 class SyncChange { |
| 20 public: |
| 21 enum SyncChangeType { |
| 22 ACTION_INVALID, |
| 23 ACTION_ADD, |
| 24 ACTION_UPDATE, |
| 25 ACTION_DELETE |
| 26 }; |
| 27 |
| 28 // Default constructor creates an invalid change. |
| 29 SyncChange(); |
| 30 // Create a new change with the specified sync data. |
| 31 SyncChange(SyncChangeType change_type, const SyncData& sync_data); |
| 32 ~SyncChange(); |
| 33 |
| 34 // Copy constructor and assignment operator welcome. |
| 35 |
| 36 // Whether this change is valid. This must be true before attempting to access |
| 37 // the data. |
| 38 // Deletes: Requires valid tag when going to the syncer. Requires valid |
| 39 // specifics when coming from the syncer. |
| 40 // Adds, Updates: Require valid tag and specifics when going to the syncer. |
| 41 // Require only valid specifics when coming from the syncer. |
| 42 bool IsValid() const; |
| 43 |
| 44 // Getters. |
| 45 SyncChangeType change_type() const; |
| 46 SyncData sync_data() const; |
| 47 |
| 48 private: |
| 49 SyncChangeType change_type_; |
| 50 |
| 51 // An immutable container for the data of this SyncChange. Whenever |
| 52 // SyncChanges are copied, they copy references to this data. |
| 53 SyncData sync_data_; |
| 54 }; |
| 55 |
| 56 #endif // CHROME_BROWSER_SYNC_API_SYNC_CHANGE_H_ |
OLD | NEW |