| OLD | NEW |
| 1 // Copyright (c) 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_SYNC_MANAGER_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_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 "sync/base/sync_export.h" |
| 17 #include "sync/internal_api/public/base/model_type.h" | 18 #include "sync/internal_api/public/base/model_type.h" |
| 18 #include "sync/internal_api/public/change_record.h" | 19 #include "sync/internal_api/public/change_record.h" |
| 19 #include "sync/internal_api/public/configure_reason.h" | 20 #include "sync/internal_api/public/configure_reason.h" |
| 20 #include "sync/internal_api/public/engine/model_safe_worker.h" | 21 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 21 #include "sync/internal_api/public/engine/sync_status.h" | 22 #include "sync/internal_api/public/engine/sync_status.h" |
| 22 #include "sync/internal_api/public/sync_encryption_handler.h" | 23 #include "sync/internal_api/public/sync_encryption_handler.h" |
| 23 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" | 24 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" |
| 24 #include "sync/internal_api/public/util/weak_handle.h" | 25 #include "sync/internal_api/public/util/weak_handle.h" |
| 25 #include "sync/notifier/invalidation_util.h" | 26 #include "sync/notifier/invalidation_util.h" |
| 26 #include "sync/protocol/sync_protocol_error.h" | 27 #include "sync/protocol/sync_protocol_error.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // single SyncManager instance. The caller should typically create one | 71 // single SyncManager instance. The caller should typically create one |
| 71 // SyncManager for the lifetime of a user session. | 72 // SyncManager for the lifetime of a user session. |
| 72 // | 73 // |
| 73 // Unless stated otherwise, all methods of SyncManager should be called on the | 74 // Unless stated otherwise, all methods of SyncManager should be called on the |
| 74 // same thread. | 75 // same thread. |
| 75 class SyncManager { | 76 class SyncManager { |
| 76 public: | 77 public: |
| 77 // An interface the embedding application implements to be notified | 78 // An interface the embedding application implements to be notified |
| 78 // on change events. Note that these methods may be called on *any* | 79 // on change events. Note that these methods may be called on *any* |
| 79 // thread. | 80 // thread. |
| 80 class ChangeDelegate { | 81 class SYNC_EXPORT ChangeDelegate { |
| 81 public: | 82 public: |
| 82 // Notify the delegate that changes have been applied to the sync model. | 83 // Notify the delegate that changes have been applied to the sync model. |
| 83 // | 84 // |
| 84 // This will be invoked on the same thread as on which ApplyChanges was | 85 // This will be invoked on the same thread as on which ApplyChanges was |
| 85 // called. |changes| is an array of size |change_count|, and contains the | 86 // called. |changes| is an array of size |change_count|, and contains the |
| 86 // ID of each individual item that was changed. |changes| exists only for | 87 // ID of each individual item that was changed. |changes| exists only for |
| 87 // the duration of the call. If items of multiple data types change at | 88 // the duration of the call. If items of multiple data types change at |
| 88 // the same time, this method is invoked once per data type and |changes| | 89 // the same time, this method is invoked once per data type and |changes| |
| 89 // is restricted to items of the ModelType indicated by |model_type|. | 90 // is restricted to items of the ModelType indicated by |model_type|. |
| 90 // Because the observer is passed a |trans|, the observer can assume a | 91 // Because the observer is passed a |trans|, the observer can assume a |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 virtual void OnChangesComplete(ModelType model_type) = 0; | 157 virtual void OnChangesComplete(ModelType model_type) = 0; |
| 157 | 158 |
| 158 protected: | 159 protected: |
| 159 virtual ~ChangeObserver(); | 160 virtual ~ChangeObserver(); |
| 160 }; | 161 }; |
| 161 | 162 |
| 162 // An interface the embedding application implements to receive | 163 // An interface the embedding application implements to receive |
| 163 // notifications from the SyncManager. Register an observer via | 164 // notifications from the SyncManager. Register an observer via |
| 164 // SyncManager::AddObserver. All methods are called only on the | 165 // SyncManager::AddObserver. All methods are called only on the |
| 165 // sync thread. | 166 // sync thread. |
| 166 class Observer { | 167 class SYNC_EXPORT Observer { |
| 167 public: | 168 public: |
| 168 // A round-trip sync-cycle took place and the syncer has resolved any | 169 // A round-trip sync-cycle took place and the syncer has resolved any |
| 169 // conflicts that may have arisen. | 170 // conflicts that may have arisen. |
| 170 virtual void OnSyncCycleCompleted( | 171 virtual void OnSyncCycleCompleted( |
| 171 const sessions::SyncSessionSnapshot& snapshot) = 0; | 172 const sessions::SyncSessionSnapshot& snapshot) = 0; |
| 172 | 173 |
| 173 // Called when the status of the connection to the sync server has | 174 // Called when the status of the connection to the sync server has |
| 174 // changed. | 175 // changed. |
| 175 virtual void OnConnectionStatusChange(ConnectionStatus status) = 0; | 176 virtual void OnConnectionStatusChange(ConnectionStatus status) = 0; |
| 176 | 177 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 // any remaining unsynced items. May be called on any thread. | 420 // any remaining unsynced items. May be called on any thread. |
| 420 virtual bool HasUnsyncedItems() = 0; | 421 virtual bool HasUnsyncedItems() = 0; |
| 421 | 422 |
| 422 // Returns the SyncManager's encryption handler. | 423 // Returns the SyncManager's encryption handler. |
| 423 virtual SyncEncryptionHandler* GetEncryptionHandler() = 0; | 424 virtual SyncEncryptionHandler* GetEncryptionHandler() = 0; |
| 424 }; | 425 }; |
| 425 | 426 |
| 426 } // namespace syncer | 427 } // namespace syncer |
| 427 | 428 |
| 428 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 429 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
| OLD | NEW |