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

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

Issue 11187021: Add RemoteFileSyncService interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 2 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_FILE_PROVIDER_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_FILE_PROVIDER_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/callback_forward.h"
11 #include "webkit/fileapi/syncable/sync_status_code.h"
12
13 class FilePath;
14 class GURL;
15
16 namespace fileapi {
17 class FileSystemURL;
18 }
19
20 namespace sync_file_system {
21
22 class RemoteChangeProcessor {
23 public:
24 RemoteChangeProcessor();
25 virtual ~RemoteChangeProcessor();
26
27 // Called when RemoteFileProvider has pending remote change.
28 virtual void OnRemoteChangeAvailable() = 0;
29
30 private:
31 DISALLOW_COPY_AND_ASSIGN(RemoteChangeProcessor);
32 };
33
34 // This class represents the changelist of the remote files.
kinuko 2012/10/18 13:54:32 This class provides access to the remote side chan
35 class RemoteChangeProvider {
36 public:
37 // |processor| needs alive until RemoteChangeProvider destroyed.
38 explicit RemoteChangeProvider(RemoteChangeProcessor* processor);
39 virtual ~RemoteChangeProvider();
40
41 // Registers |origin| as a tracking origin.
42 // After this method is called, the representing changelist includes
43 // remote file changes for |origin|.
kinuko 2012/10/18 13:54:32 Registers |origin| to track remote side changes fo
tzik 2012/10/23 04:19:32 Done.
44 virtual void RegisterOrigin(const GURL& origin) = 0;
kinuko 2012/10/18 13:54:32 On the second thought I may prefer having this on
45
46 // Unregisters |origin| as a tracking origin.
47 // After this method is called, the representing changelist no longer includes
48 // remote file changes for |origin|.
kinuko 2012/10/18 13:54:32 Unregisters |origin| so that this provider no long
tzik 2012/10/23 04:19:32 Done.
49 virtual void UnregisterOrigin(const GURL& origin) = 0;
50
51 // Returns true if it has a pending remote change.
52 virtual bool HasRemoteChange() = 0;
kinuko 2012/10/18 13:54:32 nit: Change -> Changes ?
53
54 // Returns URL where the current remote change was happend at.
55 // This requires HasRemoteChange() == true.
56 virtual const fileapi::FileSystemURL& GetURLForCurrentChange() = 0;
57
58 // Return true if the current remote change deleted the file.
59 // This requires HasRemoteChange() == true.
60 virtual bool IsDeletionChange() = 0;
kinuko 2012/10/18 13:54:32 How do we know if a change is for a file or a dire
tzik 2012/10/19 04:32:07 Change data from Drive server seems not containing
61
62 // Tells we have processed the current remote change.
63 // This requires HasRemoteChange() == true.
64 virtual void DidProcessRemoteChange() = 0;
65
66 protected:
67 void NotifyChangeAvailable();
68
69 private:
70 RemoteChangeProcessor* const processor_;
71
72 DISALLOW_COPY_AND_ASSIGN(RemoteChangeProvider);
73 };
74
75 class RemoteFileProvider {
kinuko 2012/10/18 13:54:32 For consistency & since this interface is still sp
tzik 2012/10/23 04:19:32 Done.
76 public:
77 typedef base::Callback<void(fileapi::SyncStatusCode status,
78 const FilePath& temp_file)> DownloadCallback;
79 typedef base::Callback<void(fileapi::SyncStatusCode status)> StatusCallback;
80
81 explicit RemoteFileProvider(
82 scoped_ptr<RemoteChangeProvider> remote_change_provider);
83 virtual ~RemoteFileProvider();
84
85 // Downloads the remote file for |url|. Upon completion, |callback| is
86 // invoked with status and temporary file.
87 // Its caller need to delete the temporary file after it processed locally.
88 virtual void DownloadFile(const fileapi::FileSystemURL& url,
89 const DownloadCallback& callback) = 0;
90
91 // Deletes the remote file for |url|. Upon completion, |callback| is
92 // invoked with status.
93 virtual void DeleteFile(const fileapi::FileSystemURL& url,
94 const StatusCallback& callback) = 0;
95
96 // Upload the file at |file_path| and update the remote file for |url|.
97 // Upon completion, |callback| is invoked with status.
98 // The caller must guarantee the file does not modified until its completion.
99 virtual void UploadFile(const fileapi::FileSystemURL& url,
100 const FilePath& file_path,
101 const StatusCallback& callback) = 0;
102
103 RemoteChangeProvider* change_provider() {
104 return remote_change_provider_.get();
105 }
106
107 private:
108 scoped_ptr<RemoteChangeProvider> remote_change_provider_;
109
110 DISALLOW_COPY_AND_ASSIGN(RemoteFileProvider);
111 };
112
113 } // namespace sync_file_system
114
115 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_FILE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698