| 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_SYNC_MANAGER_H_ | 5 #ifndef SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
| 6 #define SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 6 #define SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/task_runner.h" | 15 #include "base/task_runner.h" |
| 16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 17 #include "base/time.h" | 17 #include "base/time.h" |
| 18 #include "sync/internal_api/change_record.h" | 18 #include "sync/internal_api/change_record.h" |
| 19 #include "sync/internal_api/configure_reason.h" | 19 #include "sync/internal_api/configure_reason.h" |
| 20 #include "sync/internal_api/public/engine/model_safe_worker.h" | 20 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 21 #include "sync/internal_api/public/engine/sync_status.h" |
| 21 #include "sync/internal_api/public/syncable/model_type.h" | 22 #include "sync/internal_api/public/syncable/model_type.h" |
| 22 #include "sync/protocol/sync_protocol_error.h" | 23 #include "sync/protocol/sync_protocol_error.h" |
| 23 #include "sync/util/report_unrecoverable_error_function.h" | 24 #include "sync/util/report_unrecoverable_error_function.h" |
| 24 #include "sync/util/unrecoverable_error_handler.h" | 25 #include "sync/util/unrecoverable_error_handler.h" |
| 25 #include "sync/util/weak_handle.h" | 26 #include "sync/util/weak_handle.h" |
| 26 | 27 |
| 27 namespace browser_sync { | 28 namespace browser_sync { |
| 28 class Encryptor; | 29 class Encryptor; |
| 29 struct Experiments; | 30 struct Experiments; |
| 30 class ExtensionsActivityMonitor; | 31 class ExtensionsActivityMonitor; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // SyncManager for the lifetime of a user session. | 84 // SyncManager for the lifetime of a user session. |
| 84 // | 85 // |
| 85 // Unless stated otherwise, all methods of SyncManager should be called on the | 86 // Unless stated otherwise, all methods of SyncManager should be called on the |
| 86 // same thread. | 87 // same thread. |
| 87 class SyncManager { | 88 class SyncManager { |
| 88 public: | 89 public: |
| 89 // SyncInternal contains the implementation of SyncManager, while abstracting | 90 // SyncInternal contains the implementation of SyncManager, while abstracting |
| 90 // internal types from clients of the interface. | 91 // internal types from clients of the interface. |
| 91 class SyncInternal; | 92 class SyncInternal; |
| 92 | 93 |
| 93 // Status encapsulates detailed state about the internals of the SyncManager. | |
| 94 struct Status { | |
| 95 Status(); | |
| 96 ~Status(); | |
| 97 | |
| 98 bool notifications_enabled; // True only if subscribed for notifications. | |
| 99 | |
| 100 // Notifications counters updated by the actions in synapi. | |
| 101 int notifications_received; | |
| 102 | |
| 103 browser_sync::SyncProtocolError sync_protocol_error; | |
| 104 | |
| 105 // Number of encryption conflicts counted during most recent sync cycle. | |
| 106 int encryption_conflicts; | |
| 107 | |
| 108 // Number of hierarchy conflicts counted during most recent sync cycle. | |
| 109 int hierarchy_conflicts; | |
| 110 | |
| 111 // Number of simple conflicts counted during most recent sync cycle. | |
| 112 int simple_conflicts; | |
| 113 | |
| 114 // Number of items the server refused to commit due to conflict during most | |
| 115 // recent sync cycle. | |
| 116 int server_conflicts; | |
| 117 | |
| 118 // Number of items successfully committed during most recent sync cycle. | |
| 119 int committed_count; | |
| 120 | |
| 121 bool syncing; | |
| 122 // True after a client has done a first sync. | |
| 123 bool initial_sync_ended; | |
| 124 | |
| 125 // Total updates available. If zero, nothing left to download. | |
| 126 int64 updates_available; | |
| 127 // Total updates received by the syncer since browser start. | |
| 128 int updates_received; | |
| 129 // Total updates received that are echoes of our own changes. | |
| 130 int reflected_updates_received; | |
| 131 // Of updates_received, how many were tombstones. | |
| 132 int tombstone_updates_received; | |
| 133 | |
| 134 // Total successful commits. | |
| 135 int num_commits_total; | |
| 136 | |
| 137 // Total number of overwrites due to conflict resolver since browser start. | |
| 138 int num_local_overwrites_total; | |
| 139 int num_server_overwrites_total; | |
| 140 | |
| 141 // Count of empty and non empty getupdates; | |
| 142 int nonempty_get_updates; | |
| 143 int empty_get_updates; | |
| 144 | |
| 145 // Count of sync cycles that successfully committed items; | |
| 146 int sync_cycles_with_commits; | |
| 147 int sync_cycles_without_commits; | |
| 148 | |
| 149 // Count of useless and useful syncs we perform. | |
| 150 int useless_sync_cycles; | |
| 151 int useful_sync_cycles; | |
| 152 | |
| 153 // Encryption related. | |
| 154 syncable::ModelTypeSet encrypted_types; | |
| 155 bool cryptographer_ready; | |
| 156 bool crypto_has_pending_keys; | |
| 157 | |
| 158 // The unique identifer for this client. | |
| 159 std::string unique_id; | |
| 160 }; | |
| 161 | |
| 162 // An interface the embedding application implements to be notified | 94 // An interface the embedding application implements to be notified |
| 163 // on change events. Note that these methods may be called on *any* | 95 // on change events. Note that these methods may be called on *any* |
| 164 // thread. | 96 // thread. |
| 165 class ChangeDelegate { | 97 class ChangeDelegate { |
| 166 public: | 98 public: |
| 167 // Notify the delegate that changes have been applied to the sync model. | 99 // Notify the delegate that changes have been applied to the sync model. |
| 168 // | 100 // |
| 169 // This will be invoked on the same thread as on which ApplyChanges was | 101 // This will be invoked on the same thread as on which ApplyChanges was |
| 170 // called. |changes| is an array of size |change_count|, and contains the | 102 // called. |changes| is an array of size |change_count|, and contains the |
| 171 // ID of each individual item that was changed. |changes| exists only for | 103 // ID of each individual item that was changed. |changes| exists only for |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 // NOTE: It is OK (in fact, it's probably a good idea) to call this before | 453 // NOTE: It is OK (in fact, it's probably a good idea) to call this before |
| 522 // having received OnInitializationCompleted. | 454 // having received OnInitializationCompleted. |
| 523 void AddObserver(Observer* observer); | 455 void AddObserver(Observer* observer); |
| 524 | 456 |
| 525 // Remove the given observer. Make sure to call this if the | 457 // Remove the given observer. Make sure to call this if the |
| 526 // Observer is being destroyed so the SyncManager doesn't | 458 // Observer is being destroyed so the SyncManager doesn't |
| 527 // potentially dereference garbage. | 459 // potentially dereference garbage. |
| 528 void RemoveObserver(Observer* observer); | 460 void RemoveObserver(Observer* observer); |
| 529 | 461 |
| 530 // Status-related getter. May be called on any thread. | 462 // Status-related getter. May be called on any thread. |
| 531 Status GetDetailedStatus() const; | 463 SyncStatus GetDetailedStatus() const; |
| 532 | 464 |
| 533 // Whether or not the Nigori node is encrypted using an explicit passphrase. | 465 // Whether or not the Nigori node is encrypted using an explicit passphrase. |
| 534 // May be called on any thread. | 466 // May be called on any thread. |
| 535 bool IsUsingExplicitPassphrase(); | 467 bool IsUsingExplicitPassphrase(); |
| 536 | 468 |
| 537 // Call periodically from a database-safe thread to persist recent changes | 469 // Call periodically from a database-safe thread to persist recent changes |
| 538 // to the syncapi model. | 470 // to the syncapi model. |
| 539 void SaveChanges(); | 471 void SaveChanges(); |
| 540 | 472 |
| 541 // Initiates shutdown of various components in the sync engine. Must be | 473 // Initiates shutdown of various components in the sync engine. Must be |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 sync_api::UserShare* share); | 563 sync_api::UserShare* share); |
| 632 | 564 |
| 633 const char* ConnectionStatusToString(ConnectionStatus status); | 565 const char* ConnectionStatusToString(ConnectionStatus status); |
| 634 | 566 |
| 635 // Returns the string representation of a PassphraseRequiredReason value. | 567 // Returns the string representation of a PassphraseRequiredReason value. |
| 636 const char* PassphraseRequiredReasonToString(PassphraseRequiredReason reason); | 568 const char* PassphraseRequiredReasonToString(PassphraseRequiredReason reason); |
| 637 | 569 |
| 638 } // namespace sync_api | 570 } // namespace sync_api |
| 639 | 571 |
| 640 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 572 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
| OLD | NEW |