OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SESSION_SNAPSHOT_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SESSION_SNAPSHOT_H_ |
6 #define SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SESSION_SNAPSHOT_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SESSION_SNAPSHOT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "sync/base/sync_export.h" | 12 #include "sync/base/sync_export.h" |
13 #include "sync/internal_api/public/base/model_type.h" | 13 #include "sync/internal_api/public/base/model_type.h" |
14 #include "sync/internal_api/public/base/progress_marker_map.h" | 14 #include "sync/internal_api/public/base/progress_marker_map.h" |
15 #include "sync/internal_api/public/sessions/model_neutral_state.h" | 15 #include "sync/internal_api/public/sessions/model_neutral_state.h" |
16 #include "sync/internal_api/public/sessions/sync_source_info.h" | |
17 | 16 |
18 namespace base { | 17 namespace base { |
19 class DictionaryValue; | 18 class DictionaryValue; |
20 } | 19 } |
21 | 20 |
22 namespace syncer { | 21 namespace syncer { |
23 namespace sessions { | 22 namespace sessions { |
24 | 23 |
25 // An immutable snapshot of state from a SyncSession. Convenient to use as | 24 // An immutable snapshot of state from a SyncSession. Convenient to use as |
26 // part of notifications as it is inherently thread-safe. | 25 // part of notifications as it is inherently thread-safe. |
27 // TODO(zea): if copying this all over the place starts getting expensive, | 26 // TODO(zea): if copying this all over the place starts getting expensive, |
28 // consider passing around immutable references instead of values. | 27 // consider passing around immutable references instead of values. |
29 // Default copy and assign welcome. | 28 // Default copy and assign welcome. |
30 class SYNC_EXPORT SyncSessionSnapshot { | 29 class SYNC_EXPORT SyncSessionSnapshot { |
31 public: | 30 public: |
32 SyncSessionSnapshot(); | 31 SyncSessionSnapshot(); |
33 SyncSessionSnapshot( | 32 SyncSessionSnapshot( |
34 const ModelNeutralState& model_neutral_state, | 33 const ModelNeutralState& model_neutral_state, |
35 const ProgressMarkerMap& download_progress_markers, | 34 const ProgressMarkerMap& download_progress_markers, |
36 bool is_silenced, | 35 bool is_silenced, |
37 int num_encryption_conflicts, | 36 int num_encryption_conflicts, |
38 int num_hierarchy_conflicts, | 37 int num_hierarchy_conflicts, |
39 int num_server_conflicts, | 38 int num_server_conflicts, |
40 const SyncSourceInfo& source, | |
41 bool notifications_enabled, | 39 bool notifications_enabled, |
42 size_t num_entries, | 40 size_t num_entries, |
43 base::Time sync_start_time, | 41 base::Time sync_start_time, |
42 const std::vector<int>& num_entries_by_type, | |
43 const std::vector<int>& num_to_delete_entries_by_type, | |
44 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source); | |
45 SyncSessionSnapshot( | |
tim (not reviewing)
2013/08/01 17:16:38
Style guide forbids overloading functions (constru
rlarocque
2013/08/01 21:01:41
Apparently the second constructor is only used in
| |
46 const ModelNeutralState& model_neutral_state, | |
47 const ProgressMarkerMap& download_progress_markers, | |
48 bool is_silenced, | |
49 int num_encryption_conflicts, | |
50 int num_hierarchy_conflicts, | |
51 int num_server_conflicts, | |
52 bool notifications_enabled, | |
53 size_t num_entries, | |
54 base::Time sync_start_time, | |
44 const std::vector<int>& num_entries_by_type, | 55 const std::vector<int>& num_entries_by_type, |
45 const std::vector<int>& num_to_delete_entries_by_type); | 56 const std::vector<int>& num_to_delete_entries_by_type); |
46 ~SyncSessionSnapshot(); | 57 ~SyncSessionSnapshot(); |
47 | 58 |
48 // Caller takes ownership of the returned dictionary. | 59 // Caller takes ownership of the returned dictionary. |
49 base::DictionaryValue* ToValue() const; | 60 base::DictionaryValue* ToValue() const; |
50 | 61 |
51 std::string ToString() const; | 62 std::string ToString() const; |
52 | 63 |
53 ModelNeutralState model_neutral_state() const { | 64 ModelNeutralState model_neutral_state() const { |
54 return model_neutral_state_; | 65 return model_neutral_state_; |
55 } | 66 } |
56 int64 num_server_changes_remaining() const; | 67 int64 num_server_changes_remaining() const; |
57 const ProgressMarkerMap& download_progress_markers() const; | 68 const ProgressMarkerMap& download_progress_markers() const; |
58 bool is_silenced() const; | 69 bool is_silenced() const; |
59 int num_encryption_conflicts() const; | 70 int num_encryption_conflicts() const; |
60 int num_hierarchy_conflicts() const; | 71 int num_hierarchy_conflicts() const; |
61 int num_server_conflicts() const; | 72 int num_server_conflicts() const; |
62 SyncSourceInfo source() const; | |
63 bool notifications_enabled() const; | 73 bool notifications_enabled() const; |
64 size_t num_entries() const; | 74 size_t num_entries() const; |
65 base::Time sync_start_time() const; | 75 base::Time sync_start_time() const; |
66 const std::vector<int>& num_entries_by_type() const; | 76 const std::vector<int>& num_entries_by_type() const; |
67 const std::vector<int>& num_to_delete_entries_by_type() const; | 77 const std::vector<int>& num_to_delete_entries_by_type() const; |
78 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source() const; | |
tim (not reviewing)
2013/08/01 17:16:38
Comment what this is / why it is considered "legac
rlarocque
2013/08/01 21:01:41
Done.
| |
68 | 79 |
69 // Set iff this snapshot was not built using the default constructor. | 80 // Set iff this snapshot was not built using the default constructor. |
70 bool is_initialized() const; | 81 bool is_initialized() const; |
71 | 82 |
72 private: | 83 private: |
73 ModelNeutralState model_neutral_state_; | 84 ModelNeutralState model_neutral_state_; |
74 ProgressMarkerMap download_progress_markers_; | 85 ProgressMarkerMap download_progress_markers_; |
75 bool is_silenced_; | 86 bool is_silenced_; |
76 int num_encryption_conflicts_; | 87 int num_encryption_conflicts_; |
77 int num_hierarchy_conflicts_; | 88 int num_hierarchy_conflicts_; |
78 int num_server_conflicts_; | 89 int num_server_conflicts_; |
79 SyncSourceInfo source_; | |
80 bool notifications_enabled_; | 90 bool notifications_enabled_; |
81 size_t num_entries_; | 91 size_t num_entries_; |
82 base::Time sync_start_time_; | 92 base::Time sync_start_time_; |
83 | 93 |
84 std::vector<int> num_entries_by_type_; | 94 std::vector<int> num_entries_by_type_; |
85 std::vector<int> num_to_delete_entries_by_type_; | 95 std::vector<int> num_to_delete_entries_by_type_; |
86 | 96 |
97 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source_; | |
98 | |
87 bool is_initialized_; | 99 bool is_initialized_; |
88 }; | 100 }; |
89 | 101 |
90 } // namespace sessions | 102 } // namespace sessions |
91 } // namespace syncer | 103 } // namespace syncer |
92 | 104 |
93 #endif // SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SESSION_SNAPSHOT_H_ | 105 #endif // SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SESSION_SNAPSHOT_H_ |
OLD | NEW |