| 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 // StatusController handles all counter and status related number crunching and | 5 // StatusController handles all counter and status related number crunching and |
| 6 // state tracking on behalf of a SyncSession. | 6 // state tracking on behalf of a SyncCycle. |
| 7 // | 7 // |
| 8 // This object may be accessed from many different threads. It will be accessed | 8 // This object may be accessed from many different threads. It will be accessed |
| 9 // most often from the syncer thread. However, when update application is in | 9 // most often from the syncer thread. However, when update application is in |
| 10 // progress it may also be accessed from the worker threads. This is safe | 10 // progress it may also be accessed from the worker threads. This is safe |
| 11 // because only one of them will run at a time, and the syncer thread will be | 11 // because only one of them will run at a time, and the syncer thread will be |
| 12 // blocked until update application completes. | 12 // blocked until update application completes. |
| 13 // | 13 // |
| 14 // This object contains only global state. None of its members are per model | 14 // This object contains only global state. None of its members are per model |
| 15 // type counters. | 15 // type counters. |
| 16 | 16 |
| 17 #ifndef COMPONENTS_SYNC_SESSIONS_IMPL_STATUS_CONTROLLER_H_ | 17 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_CYCLE_STATUS_CONTROLLER_H_ |
| 18 #define COMPONENTS_SYNC_SESSIONS_IMPL_STATUS_CONTROLLER_H_ | 18 #define COMPONENTS_SYNC_ENGINE_IMPL_CYCLE_STATUS_CONTROLLER_H_ |
| 19 | 19 |
| 20 #include <map> | 20 #include <map> |
| 21 #include <vector> | 21 #include <vector> |
| 22 | 22 |
| 23 #include "base/logging.h" | 23 #include "base/logging.h" |
| 24 #include "base/macros.h" | 24 #include "base/macros.h" |
| 25 #include "base/stl_util.h" | 25 #include "base/stl_util.h" |
| 26 #include "base/time/time.h" | 26 #include "base/time/time.h" |
| 27 #include "components/sync/engine/cycle/model_neutral_state.h" |
| 27 #include "components/sync/engine/model_safe_worker.h" | 28 #include "components/sync/engine/model_safe_worker.h" |
| 28 #include "components/sync/sessions/model_neutral_state.h" | |
| 29 | 29 |
| 30 namespace syncer { | 30 namespace syncer { |
| 31 namespace sessions { | |
| 32 | 31 |
| 33 class StatusController { | 32 class StatusController { |
| 34 public: | 33 public: |
| 35 StatusController(); | 34 StatusController(); |
| 36 ~StatusController(); | 35 ~StatusController(); |
| 37 | 36 |
| 38 // The types included in the get updates and commit client to server requests. | 37 // The types included in the get updates and commit client to server requests. |
| 39 const ModelTypeSet get_updates_request_types() const; | 38 const ModelTypeSet get_updates_request_types() const; |
| 40 void set_get_updates_request_types(ModelTypeSet value); | 39 void set_get_updates_request_types(ModelTypeSet value); |
| 41 const ModelTypeSet commit_request_types() const; | 40 const ModelTypeSet commit_request_types() const; |
| 42 void set_commit_request_types(ModelTypeSet value); | 41 void set_commit_request_types(ModelTypeSet value); |
| 43 | 42 |
| 44 // Various conflict counters. | 43 // Various conflict counters. |
| 45 int num_encryption_conflicts() const; | 44 int num_encryption_conflicts() const; |
| 46 int num_hierarchy_conflicts() const; | 45 int num_hierarchy_conflicts() const; |
| 47 int num_server_conflicts() const; | 46 int num_server_conflicts() const; |
| 48 | 47 |
| 49 // Aggregate sum of all conflicting items over all conflict types. | 48 // Aggregate sum of all conflicting items over all conflict types. |
| 50 int TotalNumConflictingItems() const; | 49 int TotalNumConflictingItems() const; |
| 51 | 50 |
| 52 // Number of successfully applied updates. | 51 // Number of successfully applied updates. |
| 53 int num_updates_applied() const; | 52 int num_updates_applied() const; |
| 54 | 53 |
| 55 int num_server_overwrites() const; | 54 int num_server_overwrites() const; |
| 56 int num_local_overwrites() const; | 55 int num_local_overwrites() const; |
| 57 | 56 |
| 58 // The time at which we started the first sync cycle in this session. | 57 // The time at which we started the most recent sync cycle. |
| 59 base::Time sync_start_time() const { return sync_start_time_; } | 58 base::Time sync_start_time() const { return sync_start_time_; } |
| 60 | 59 |
| 61 // If a poll was performed in this session, the time at which it finished. | 60 // If a poll was performed in this cycle, the time at which it finished. |
| 62 // Not set if no poll was performed. | 61 // Not set if no poll was performed. |
| 63 base::Time poll_finish_time() const { return poll_finish_time_; } | 62 base::Time poll_finish_time() const { return poll_finish_time_; } |
| 64 | 63 |
| 65 const ModelNeutralState& model_neutral_state() const { | 64 const ModelNeutralState& model_neutral_state() const { |
| 66 return model_neutral_; | 65 return model_neutral_; |
| 67 } | 66 } |
| 68 | 67 |
| 69 SyncerError last_get_key_result() const; | 68 SyncerError last_get_key_result() const; |
| 70 | 69 |
| 71 // Download counters. | 70 // Download counters. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 100 // Time the last sync cycle began. | 99 // Time the last sync cycle began. |
| 101 base::Time sync_start_time_; | 100 base::Time sync_start_time_; |
| 102 | 101 |
| 103 // If a poll was performed, the time it finished. Not set if not poll was | 102 // If a poll was performed, the time it finished. Not set if not poll was |
| 104 // performed. | 103 // performed. |
| 105 base::Time poll_finish_time_; | 104 base::Time poll_finish_time_; |
| 106 | 105 |
| 107 DISALLOW_COPY_AND_ASSIGN(StatusController); | 106 DISALLOW_COPY_AND_ASSIGN(StatusController); |
| 108 }; | 107 }; |
| 109 | 108 |
| 110 } // namespace sessions | |
| 111 } // namespace syncer | 109 } // namespace syncer |
| 112 | 110 |
| 113 #endif // COMPONENTS_SYNC_SESSIONS_IMPL_STATUS_CONTROLLER_H_ | 111 #endif // COMPONENTS_SYNC_ENGINE_IMPL_CYCLE_STATUS_CONTROLLER_H_ |
| OLD | NEW |