OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SESSION_SNAPSHOT_H_ | |
6 #define SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SESSION_SNAPSHOT_H_ | |
7 | |
8 #include <stddef.h> | |
9 | |
10 #include <string> | |
11 #include <vector> | |
12 | |
13 #include "base/time/time.h" | |
14 #include "sync/base/sync_export.h" | |
15 #include "sync/internal_api/public/base/model_type.h" | |
16 #include "sync/internal_api/public/base/progress_marker_map.h" | |
17 #include "sync/internal_api/public/sessions/model_neutral_state.h" | |
18 | |
19 namespace base { | |
20 class DictionaryValue; | |
21 } | |
22 | |
23 namespace syncer { | |
24 namespace sessions { | |
25 | |
26 // An immutable snapshot of state from a SyncSession. Convenient to use as | |
27 // part of notifications as it is inherently thread-safe. | |
28 // TODO(zea): if copying this all over the place starts getting expensive, | |
29 // consider passing around immutable references instead of values. | |
30 // Default copy and assign welcome. | |
31 class SYNC_EXPORT SyncSessionSnapshot { | |
32 public: | |
33 SyncSessionSnapshot(); | |
34 SyncSessionSnapshot( | |
35 const ModelNeutralState& model_neutral_state, | |
36 const ProgressMarkerMap& download_progress_markers, | |
37 bool is_silenced, | |
38 int num_encryption_conflicts, | |
39 int num_hierarchy_conflicts, | |
40 int num_server_conflicts, | |
41 bool notifications_enabled, | |
42 size_t num_entries, | |
43 base::Time sync_start_time, | |
44 base::Time poll_finish_time, | |
45 const std::vector<int>& num_entries_by_type, | |
46 const std::vector<int>& num_to_delete_entries_by_type, | |
47 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source); | |
48 SyncSessionSnapshot(const SyncSessionSnapshot& other); | |
49 ~SyncSessionSnapshot(); | |
50 | |
51 std::unique_ptr<base::DictionaryValue> ToValue() const; | |
52 | |
53 std::string ToString() const; | |
54 | |
55 ModelNeutralState model_neutral_state() const { | |
56 return model_neutral_state_; | |
57 } | |
58 const ProgressMarkerMap& download_progress_markers() const; | |
59 bool is_silenced() const; | |
60 int num_encryption_conflicts() const; | |
61 int num_hierarchy_conflicts() const; | |
62 int num_server_conflicts() const; | |
63 bool notifications_enabled() const; | |
64 size_t num_entries() const; | |
65 base::Time sync_start_time() const; | |
66 base::Time poll_finish_time() const; | |
67 const std::vector<int>& num_entries_by_type() const; | |
68 const std::vector<int>& num_to_delete_entries_by_type() const; | |
69 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source() const; | |
70 | |
71 // Set iff this snapshot was not built using the default constructor. | |
72 bool is_initialized() const; | |
73 | |
74 private: | |
75 ModelNeutralState model_neutral_state_; | |
76 ProgressMarkerMap download_progress_markers_; | |
77 bool is_silenced_; | |
78 int num_encryption_conflicts_; | |
79 int num_hierarchy_conflicts_; | |
80 int num_server_conflicts_; | |
81 bool notifications_enabled_; | |
82 size_t num_entries_; | |
83 base::Time sync_start_time_; | |
84 base::Time poll_finish_time_; | |
85 | |
86 std::vector<int> num_entries_by_type_; | |
87 std::vector<int> num_to_delete_entries_by_type_; | |
88 | |
89 // This enum value used to be an important part of the sync protocol, but is | |
90 // now deprecated. We continue to use it in the snapshot because there is | |
91 // still some value in displaying it on the about:sync page. | |
92 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source_; | |
93 | |
94 bool is_initialized_; | |
95 }; | |
96 | |
97 } // namespace sessions | |
98 } // namespace syncer | |
99 | |
100 #endif // SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SESSION_SNAPSHOT_H_ | |
OLD | NEW |