Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: chrome/browser/sync_file_system/remote_file_sync_service.h

Issue 11299008: Remote service state handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 disabled due to unrecoverable errors, e.g.
34 // local database corruption, no available account on the remote
tzik 2012/11/16 05:21:51 maybe, "no available account" causes authenticatio
kinuko 2012/11/16 05:45:02 Per offline chat I added yet another AUTHENTICATIO
35 // service side etc.
36 // Any new requests will immediately fail when the service is in
37 // this state.
38 REMOTE_SERVICE_DISABLED,
39 };
40
19 // This class represents a backing service of the sync filesystem. 41 // This class represents a backing service of the sync filesystem.
20 // This also maintains conflict information, i.e. a list of conflicting files 42 // This also maintains conflict information, i.e. a list of conflicting files
21 // (at least in the current design). 43 // (at least in the current design).
22 // Owned by SyncFileSystemService. 44 // Owned by SyncFileSystemService.
23 class RemoteFileSyncService { 45 class RemoteFileSyncService {
24 public: 46 public:
25 class Observer { 47 class Observer {
26 public: 48 public:
27 Observer() {} 49 Observer() {}
28 virtual ~Observer() {} 50 virtual ~Observer() {}
29 51
30 // This is called when there're one or more remote changes available. 52 // This is called when there're one or more remote changes available.
31 // |pending_changes_hint| indicates the pending queue length to help sync 53 // |pending_changes_hint| indicates the pending queue length to help sync
32 // scheduling but the value may not be accurately reflect the real-time 54 // scheduling but the value may not be accurately reflect the real-time
33 // value. 55 // value.
34 virtual void OnRemoteChangeAvailable(int64 pending_changes_hint) = 0; 56 virtual void OnRemoteChangeAvailable(int64 pending_changes_hint) = 0;
35 57
36 // This is called when RemoteFileSyncService changes its status. 58 // This is called when RemoteFileSyncService updates its state.
37 virtual void OnRemoteSyncStatusChanged( 59 virtual void OnRemoteServiceStateUpdated(
38 fileapi::SyncStatusCode new_status) {} 60 RemoteServiceState state,
61 const std::string& description) {}
39 62
tzik 2012/11/16 05:21:51 Could you add getters for state and description?
kinuko 2012/11/16 05:45:02 Per offline chat I didn't add them for now. (Let's
40 private: 63 private:
41 DISALLOW_COPY_AND_ASSIGN(Observer); 64 DISALLOW_COPY_AND_ASSIGN(Observer);
42 }; 65 };
43 66
44 RemoteFileSyncService() {} 67 RemoteFileSyncService() {}
45 virtual ~RemoteFileSyncService() {} 68 virtual ~RemoteFileSyncService() {}
46 69
47 virtual void AddObserver(Observer* observer) = 0; 70 virtual void AddObserver(Observer* observer) = 0;
48 virtual void RemoveObserver(Observer* observer) = 0; 71 virtual void RemoveObserver(Observer* observer) = 0;
49 72
50 // Registers |origin| to track remote side changes for the |origin|. 73 // Registers |origin| to track remote side changes for the |origin|.
51 // Upon completion, invokes |callback|. 74 // Upon completion, invokes |callback|.
75 // The caller may call this method again when the remote service state
76 // migrates to REMOTE_SERVICE_OK state if the error code returned via
77 // |callback| was retriable ones.
52 virtual void RegisterOriginForTrackingChanges( 78 virtual void RegisterOriginForTrackingChanges(
53 const GURL& origin, 79 const GURL& origin,
54 const fileapi::SyncStatusCallback& callback) = 0; 80 const fileapi::SyncStatusCallback& callback) = 0;
55 81
56 // Unregisters |origin| to track remote side changes for the |origin|. 82 // Unregisters |origin| to track remote side changes for the |origin|.
57 // Upon completion, invokes |callback|. 83 // Upon completion, invokes |callback|.
84 // The caller may call this method again when the remote service state
85 // migrates to REMOTE_SERVICE_OK state if the error code returned via
86 // |callback| was retriable ones.
58 virtual void UnregisterOriginForTrackingChanges( 87 virtual void UnregisterOriginForTrackingChanges(
59 const GURL& origin, 88 const GURL& origin,
60 const fileapi::SyncStatusCallback& callback) = 0; 89 const fileapi::SyncStatusCallback& callback) = 0;
61 90
62 // Called by the sync engine to process one remote change. 91 // Called by the sync engine to process one remote change.
63 // After a change is processed |callback| will be called (to return 92 // After a change is processed |callback| will be called (to return
64 // the control to the sync engine). 93 // the control to the sync engine).
65 virtual void ProcessRemoteChange( 94 virtual void ProcessRemoteChange(
66 RemoteChangeProcessor* processor, 95 RemoteChangeProcessor* processor,
67 const fileapi::SyncFileCallback& callback) = 0; 96 const fileapi::SyncFileCallback& callback) = 0;
(...skipping 12 matching lines...) Expand all
80 const fileapi::FileSystemURL& url, 109 const fileapi::FileSystemURL& url,
81 const fileapi::SyncFileMetadataCallback& callback) = 0; 110 const fileapi::SyncFileMetadataCallback& callback) = 0;
82 111
83 private: 112 private:
84 DISALLOW_COPY_AND_ASSIGN(RemoteFileSyncService); 113 DISALLOW_COPY_AND_ASSIGN(RemoteFileSyncService);
85 }; 114 };
86 115
87 } // namespace sync_file_system 116 } // namespace sync_file_system
88 117
89 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_FILE_SYNC_SERVICE_H_ 118 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_FILE_SYNC_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698