| 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 CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_FILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_FILE_SYNC_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_FILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_FILE_SYNC_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "webkit/fileapi/file_system_url.h" | 9 #include "webkit/fileapi/file_system_url.h" |
| 10 #include "webkit/fileapi/syncable/sync_callbacks.h" | 10 #include "webkit/fileapi/syncable/sync_callbacks.h" |
| 11 | 11 |
| 12 class GURL; | 12 class GURL; |
| 13 | 13 |
| 14 namespace sync_file_system { | 14 namespace sync_file_system { |
| 15 | 15 |
| 16 class RemoteChangeProcessor; | 16 class RemoteChangeProcessor; |
| 17 class LocalChangeProcessor; | 17 class LocalChangeProcessor; |
| 18 | 18 |
| 19 enum RemoteServiceState { |
| 20 // Remote service is up and running, or has not seen any errors yet. |
| 21 // The consumer of this service can make new requests while the |
| 22 // service is in this state. |
| 23 REMOTE_SERVICE_OK, |
| 24 |
| 25 // Remote service is temporarily unavailable due to network, |
| 26 // authentication or some other temporary failure. |
| 27 // This state may be automatically resolved when the underlying |
| 28 // network condition or service condition changes. |
| 29 // The consumer of this service can still make new requests but |
| 30 // they may fail (with recoverable error code). |
| 31 REMOTE_SERVICE_TEMPORARY_UNAVAILABLE, |
| 32 |
| 33 // Remote service is temporarily unavailable due to authentication failure. |
| 34 // This state may be automatically resolved when the authentication token |
| 35 // has been refreshed internally (e.g. when the user signed in etc). |
| 36 // The consumer of this service can still make new requests but |
| 37 // they may fail (with recoverable error code). |
| 38 REMOTE_SERVICE_AUTHENTICATION_REQUIRED, |
| 39 |
| 40 // Remote service is disabled due to unrecoverable errors, e.g. |
| 41 // local database corruption. |
| 42 // Any new requests will immediately fail when the service is in |
| 43 // this state. |
| 44 REMOTE_SERVICE_DISABLED, |
| 45 }; |
| 46 |
| 19 // This class represents a backing service of the sync filesystem. | 47 // This class represents a backing service of the sync filesystem. |
| 20 // This also maintains conflict information, i.e. a list of conflicting files | 48 // This also maintains conflict information, i.e. a list of conflicting files |
| 21 // (at least in the current design). | 49 // (at least in the current design). |
| 22 // Owned by SyncFileSystemService. | 50 // Owned by SyncFileSystemService. |
| 23 class RemoteFileSyncService { | 51 class RemoteFileSyncService { |
| 24 public: | 52 public: |
| 25 class Observer { | 53 class Observer { |
| 26 public: | 54 public: |
| 27 Observer() {} | 55 Observer() {} |
| 28 virtual ~Observer() {} | 56 virtual ~Observer() {} |
| 29 | 57 |
| 30 // This is called when there're one or more remote changes available. | 58 // This is called when there're one or more remote changes available. |
| 31 // |pending_changes_hint| indicates the pending queue length to help sync | 59 // |pending_changes_hint| indicates the pending queue length to help sync |
| 32 // scheduling but the value may not be accurately reflect the real-time | 60 // scheduling but the value may not be accurately reflect the real-time |
| 33 // value. | 61 // value. |
| 34 virtual void OnRemoteChangeAvailable(int64 pending_changes_hint) = 0; | 62 virtual void OnRemoteChangeAvailable(int64 pending_changes_hint) = 0; |
| 35 | 63 |
| 36 // This is called when RemoteFileSyncService changes its status. | 64 // This is called when RemoteFileSyncService updates its state. |
| 37 virtual void OnRemoteSyncStatusChanged( | 65 virtual void OnRemoteServiceStateUpdated( |
| 38 fileapi::SyncStatusCode new_status) {} | 66 RemoteServiceState state, |
| 67 const std::string& description) {} |
| 39 | 68 |
| 40 private: | 69 private: |
| 41 DISALLOW_COPY_AND_ASSIGN(Observer); | 70 DISALLOW_COPY_AND_ASSIGN(Observer); |
| 42 }; | 71 }; |
| 43 | 72 |
| 44 RemoteFileSyncService() {} | 73 RemoteFileSyncService() {} |
| 45 virtual ~RemoteFileSyncService() {} | 74 virtual ~RemoteFileSyncService() {} |
| 46 | 75 |
| 47 virtual void AddObserver(Observer* observer) = 0; | 76 virtual void AddObserver(Observer* observer) = 0; |
| 48 virtual void RemoveObserver(Observer* observer) = 0; | 77 virtual void RemoveObserver(Observer* observer) = 0; |
| 49 | 78 |
| 50 // Registers |origin| to track remote side changes for the |origin|. | 79 // Registers |origin| to track remote side changes for the |origin|. |
| 51 // Upon completion, invokes |callback|. | 80 // Upon completion, invokes |callback|. |
| 81 // The caller may call this method again when the remote service state |
| 82 // migrates to REMOTE_SERVICE_OK state if the error code returned via |
| 83 // |callback| was retriable ones. |
| 52 virtual void RegisterOriginForTrackingChanges( | 84 virtual void RegisterOriginForTrackingChanges( |
| 53 const GURL& origin, | 85 const GURL& origin, |
| 54 const fileapi::SyncStatusCallback& callback) = 0; | 86 const fileapi::SyncStatusCallback& callback) = 0; |
| 55 | 87 |
| 56 // Unregisters |origin| to track remote side changes for the |origin|. | 88 // Unregisters |origin| to track remote side changes for the |origin|. |
| 57 // Upon completion, invokes |callback|. | 89 // Upon completion, invokes |callback|. |
| 90 // The caller may call this method again when the remote service state |
| 91 // migrates to REMOTE_SERVICE_OK state if the error code returned via |
| 92 // |callback| was retriable ones. |
| 58 virtual void UnregisterOriginForTrackingChanges( | 93 virtual void UnregisterOriginForTrackingChanges( |
| 59 const GURL& origin, | 94 const GURL& origin, |
| 60 const fileapi::SyncStatusCallback& callback) = 0; | 95 const fileapi::SyncStatusCallback& callback) = 0; |
| 61 | 96 |
| 62 // Called by the sync engine to process one remote change. | 97 // Called by the sync engine to process one remote change. |
| 63 // After a change is processed |callback| will be called (to return | 98 // After a change is processed |callback| will be called (to return |
| 64 // the control to the sync engine). | 99 // the control to the sync engine). |
| 65 virtual void ProcessRemoteChange( | 100 virtual void ProcessRemoteChange( |
| 66 RemoteChangeProcessor* processor, | 101 RemoteChangeProcessor* processor, |
| 67 const fileapi::SyncFileCallback& callback) = 0; | 102 const fileapi::SyncFileCallback& callback) = 0; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 80 const fileapi::FileSystemURL& url, | 115 const fileapi::FileSystemURL& url, |
| 81 const fileapi::SyncFileMetadataCallback& callback) = 0; | 116 const fileapi::SyncFileMetadataCallback& callback) = 0; |
| 82 | 117 |
| 83 private: | 118 private: |
| 84 DISALLOW_COPY_AND_ASSIGN(RemoteFileSyncService); | 119 DISALLOW_COPY_AND_ASSIGN(RemoteFileSyncService); |
| 85 }; | 120 }; |
| 86 | 121 |
| 87 } // namespace sync_file_system | 122 } // namespace sync_file_system |
| 88 | 123 |
| 89 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_FILE_SYNC_SERVICE_H_ | 124 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_FILE_SYNC_SERVICE_H_ |
| OLD | NEW |