OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_API_SYNC_CHANGE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_API_SYNC_CHANGE_H_ |
6 #define CHROME_BROWSER_SYNC_API_SYNC_CHANGE_H_ | 6 #define CHROME_BROWSER_SYNC_API_SYNC_CHANGE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <iosfwd> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "chrome/browser/sync/api/sync_data.h" | 13 #include "chrome/browser/sync/api/sync_data.h" |
13 | 14 |
14 // A SyncChange object reflects a change to a piece of synced data. The change | 15 // 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 // 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 // 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 // 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 // not create deep copies of their internal data. |
(...skipping 22 matching lines...) Expand all Loading... |
41 // Require only valid specifics when coming from the syncer. | 42 // Require only valid specifics when coming from the syncer. |
42 bool IsValid() const; | 43 bool IsValid() const; |
43 | 44 |
44 // Getters. | 45 // Getters. |
45 SyncChangeType change_type() const; | 46 SyncChangeType change_type() const; |
46 SyncData sync_data() const; | 47 SyncData sync_data() const; |
47 | 48 |
48 // Returns a string representation of |change_type|. | 49 // Returns a string representation of |change_type|. |
49 static std::string ChangeTypeToString(SyncChangeType change_type); | 50 static std::string ChangeTypeToString(SyncChangeType change_type); |
50 | 51 |
| 52 // Returns a string representation of the entire object. Used for gmock |
| 53 // printing method, PrintTo. |
| 54 std::string ToString() const; |
| 55 |
51 private: | 56 private: |
52 SyncChangeType change_type_; | 57 SyncChangeType change_type_; |
53 | 58 |
54 // An immutable container for the data of this SyncChange. Whenever | 59 // An immutable container for the data of this SyncChange. Whenever |
55 // SyncChanges are copied, they copy references to this data. | 60 // SyncChanges are copied, they copy references to this data. |
56 SyncData sync_data_; | 61 SyncData sync_data_; |
57 }; | 62 }; |
58 | 63 |
| 64 // gmock printer helper. |
| 65 void PrintTo(const SyncChange& sync_change, std::ostream* os); |
| 66 |
59 #endif // CHROME_BROWSER_SYNC_API_SYNC_CHANGE_H_ | 67 #endif // CHROME_BROWSER_SYNC_API_SYNC_CHANGE_H_ |
OLD | NEW |