| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.h" | 11 #include "base/time.h" |
| 12 #include "sync/internal_api/public/base/model_type.h" | 12 #include "sync/internal_api/public/base/model_type.h" |
| 13 #include "sync/internal_api/public/base/model_type_payload_map.h" | 13 #include "sync/internal_api/public/base/model_type_state_map.h" |
| 14 #include "sync/internal_api/public/sessions/model_neutral_state.h" | 14 #include "sync/internal_api/public/sessions/model_neutral_state.h" |
| 15 #include "sync/internal_api/public/sessions/sync_source_info.h" | 15 #include "sync/internal_api/public/sessions/sync_source_info.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class DictionaryValue; | 18 class DictionaryValue; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace syncer { | 21 namespace syncer { |
| 22 namespace sessions { | 22 namespace sessions { |
| 23 | 23 |
| 24 // 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 |
| 25 // part of notifications as it is inherently thread-safe. | 25 // part of notifications as it is inherently thread-safe. |
| 26 // 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, |
| 27 // consider passing around immutable references instead of values. | 27 // consider passing around immutable references instead of values. |
| 28 // Default copy and assign welcome. | 28 // Default copy and assign welcome. |
| 29 class SyncSessionSnapshot { | 29 class SyncSessionSnapshot { |
| 30 public: | 30 public: |
| 31 SyncSessionSnapshot(); | 31 SyncSessionSnapshot(); |
| 32 SyncSessionSnapshot( | 32 SyncSessionSnapshot( |
| 33 const ModelNeutralState& model_neutral_state, | 33 const ModelNeutralState& model_neutral_state, |
| 34 bool is_share_usable, | 34 bool is_share_usable, |
| 35 ModelTypeSet initial_sync_ended, | 35 ModelTypeSet initial_sync_ended, |
| 36 const ModelTypePayloadMap& download_progress_markers, | 36 const ModelTypeStateMap& download_progress_markers, |
| 37 bool more_to_sync, | 37 bool more_to_sync, |
| 38 bool is_silenced, | 38 bool is_silenced, |
| 39 int num_encryption_conflicts, | 39 int num_encryption_conflicts, |
| 40 int num_hierarchy_conflicts, | 40 int num_hierarchy_conflicts, |
| 41 int num_simple_conflicts, | 41 int num_simple_conflicts, |
| 42 int num_server_conflicts, | 42 int num_server_conflicts, |
| 43 const SyncSourceInfo& source, | 43 const SyncSourceInfo& source, |
| 44 bool notifications_enabled, | 44 bool notifications_enabled, |
| 45 size_t num_entries, | 45 size_t num_entries, |
| 46 base::Time sync_start_time, | 46 base::Time sync_start_time, |
| 47 bool retry_scheduled); | 47 bool retry_scheduled); |
| 48 ~SyncSessionSnapshot(); | 48 ~SyncSessionSnapshot(); |
| 49 | 49 |
| 50 // Caller takes ownership of the returned dictionary. | 50 // Caller takes ownership of the returned dictionary. |
| 51 base::DictionaryValue* ToValue() const; | 51 base::DictionaryValue* ToValue() const; |
| 52 | 52 |
| 53 std::string ToString() const; | 53 std::string ToString() const; |
| 54 | 54 |
| 55 ModelNeutralState model_neutral_state() const { | 55 ModelNeutralState model_neutral_state() const { |
| 56 return model_neutral_state_; | 56 return model_neutral_state_; |
| 57 } | 57 } |
| 58 int64 num_server_changes_remaining() const; | 58 int64 num_server_changes_remaining() const; |
| 59 bool is_share_usable() const; | 59 bool is_share_usable() const; |
| 60 ModelTypeSet initial_sync_ended() const; | 60 ModelTypeSet initial_sync_ended() const; |
| 61 ModelTypePayloadMap download_progress_markers() const; | 61 ModelTypeStateMap download_progress_markers() const; |
| 62 bool has_more_to_sync() const; | 62 bool has_more_to_sync() const; |
| 63 bool is_silenced() const; | 63 bool is_silenced() const; |
| 64 int num_encryption_conflicts() const; | 64 int num_encryption_conflicts() const; |
| 65 int num_hierarchy_conflicts() const; | 65 int num_hierarchy_conflicts() const; |
| 66 int num_simple_conflicts() const; | 66 int num_simple_conflicts() const; |
| 67 int num_server_conflicts() const; | 67 int num_server_conflicts() const; |
| 68 SyncSourceInfo source() const; | 68 SyncSourceInfo source() const; |
| 69 bool notifications_enabled() const; | 69 bool notifications_enabled() const; |
| 70 size_t num_entries() const; | 70 size_t num_entries() const; |
| 71 base::Time sync_start_time() const; | 71 base::Time sync_start_time() const; |
| 72 bool retry_scheduled() const; | 72 bool retry_scheduled() const; |
| 73 | 73 |
| 74 // Set iff this snapshot was not built using the default constructor. | 74 // Set iff this snapshot was not built using the default constructor. |
| 75 bool is_initialized() const; | 75 bool is_initialized() const; |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 ModelNeutralState model_neutral_state_; | 78 ModelNeutralState model_neutral_state_; |
| 79 bool is_share_usable_; | 79 bool is_share_usable_; |
| 80 ModelTypeSet initial_sync_ended_; | 80 ModelTypeSet initial_sync_ended_; |
| 81 ModelTypePayloadMap download_progress_markers_; | 81 ModelTypeStateMap download_progress_markers_; |
| 82 bool has_more_to_sync_; | 82 bool has_more_to_sync_; |
| 83 bool is_silenced_; | 83 bool is_silenced_; |
| 84 int num_encryption_conflicts_; | 84 int num_encryption_conflicts_; |
| 85 int num_hierarchy_conflicts_; | 85 int num_hierarchy_conflicts_; |
| 86 int num_simple_conflicts_; | 86 int num_simple_conflicts_; |
| 87 int num_server_conflicts_; | 87 int num_server_conflicts_; |
| 88 SyncSourceInfo source_; | 88 SyncSourceInfo source_; |
| 89 bool notifications_enabled_; | 89 bool notifications_enabled_; |
| 90 size_t num_entries_; | 90 size_t num_entries_; |
| 91 base::Time sync_start_time_; | 91 base::Time sync_start_time_; |
| 92 bool retry_scheduled_; | 92 bool retry_scheduled_; |
| 93 | 93 |
| 94 bool is_initialized_; | 94 bool is_initialized_; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace sessions | 97 } // namespace sessions |
| 98 } // namespace syncer | 98 } // namespace syncer |
| 99 | 99 |
| 100 #endif // SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SESSION_SNAPSHOT_H_ | 100 #endif // SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SESSION_SNAPSHOT_H_ |
| OLD | NEW |