Chromium Code Reviews| 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_EVENT_H_ | |
| 6 #define CHROME_BROWSER_SYNC_API_SYNC_EVENT_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "chrome/browser/sync/api/sync_data.h" | |
| 13 | |
| 14 // A SyncEvent 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 SyncEvent, 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 SyncEvent { | |
|
akalin
2011/05/19 00:58:45
As we discussed, SyncEvent -> SyncChange, etc.
Nicolas Zea
2011/05/19 21:17:45
Done.
| |
| 20 public: | |
| 21 enum SyncEventType { | |
| 22 ACTION_INVALID, | |
| 23 ACTION_ADD, | |
| 24 ACTION_UPDATE, | |
| 25 ACTION_DELETE | |
| 26 }; | |
| 27 | |
| 28 // Default constructor creates an invalid event. | |
| 29 SyncEvent(); | |
| 30 // Create a new event with the specified sync data. | |
| 31 SyncEvent(SyncEventType event_type, const SyncData& sync_data); | |
| 32 ~SyncEvent(); | |
| 33 | |
| 34 // Copy constructor and assignment operator welcome. | |
| 35 | |
| 36 // Whether this event 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 SyncEventType event_type() const; | |
| 46 SyncData sync_data() const; | |
| 47 | |
| 48 private: | |
| 49 SyncEventType event_type_; | |
| 50 | |
| 51 // An immutable container for the data of this SyncEvent. Whenever | |
| 52 // SyncEvents are copied, they copy references to this data. | |
| 53 SyncData sync_data_; | |
| 54 }; | |
| 55 | |
| 56 // Ordered list of SyncEvent's. | |
| 57 typedef std::vector<SyncEvent> SyncEventList; | |
|
akalin
2011/05/19 00:58:45
Remove this (already in sync_event_processor.h)
Nicolas Zea
2011/05/19 21:17:45
Done.
| |
| 58 | |
| 59 #endif // CHROME_BROWSER_SYNC_API_SYNC_EVENT_H_ | |
| OLD | NEW |