remote_file_sync_service.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
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_SYNC_SERVICE_H_
6#define CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_FILE_SYNC_SERVICE_H_
7
8#include "base/basictypes.h"
9#include "webkit/fileapi/file_system_url.h"
10#include "webkit/fileapi/syncable/sync_callbacks.h"
11
12class GURL;
13
14namespace sync_file_system {
15
16class RemoteChangeProcessor;
17class LocalChangeProcessor;
18
19// This class represents a backing service of the sync filesystem.
20// This also maintains conflict information, i.e. a list of conflicting files
21// (at least in the current design).
22// Owned by SyncFileSystemService.
23class RemoteFileSyncService {
24 public:
25  class Observer {
26   public:
27    Observer() {}
28    virtual ~Observer() {}
29
30    // This is called when there're one or more remote changes available.
31    // |pending_changes_hint| indicates the pending queue length to help sync
32    // scheduling but the value may not be accurately reflect the real-time
33    // value.
34    virtual void OnRemoteChangeAvailable(int64 pending_changes_hint) = 0;
35
36    // This is called when RemoteFileSyncService changes its status.
37    virtual void OnRemoteSyncStatusChanged(
38        fileapi::SyncStatusCode new_status) {}
39
40   private:
41    DISALLOW_COPY_AND_ASSIGN(Observer);
42  };
43
44  RemoteFileSyncService() {}
45  virtual ~RemoteFileSyncService() {}
46
47  virtual void AddObserver(Observer* observer) = 0;
48  virtual void RemoveObserver(Observer* observer) = 0;
49
50  // Registers |origin| to track remote side changes for the |origin|.
51  // Upon completion, invokes |callback| if it's non-empty.
52  virtual void RegisterOriginForTrackingChanges(
53      const GURL& origin,
54      const fileapi::SyncStatusCallback& callback) = 0;
55
56  // Unregisters |origin| to track remote side changes for the |origin|.
57  // Upon completion, invokes |callback| if it's non-empty.
58  virtual void UnregisterOriginForTrackingChanges(
59      const GURL& origin,
60      const fileapi::SyncStatusCallback& callback) = 0;
61
62  // Called by the sync engine to process one remote change.
63  // After a change is processed |callback| will be called (to return
64  // the control to the sync engine).
65  virtual void ProcessRemoteChange(
66      RemoteChangeProcessor* processor,
67      const fileapi::SyncFileCallback& callback) = 0;
68
69  // Returns a LocalChangeProcessor that applies a local change to the remote
70  // storage backed by this service.
71  virtual LocalChangeProcessor* GetLocalChangeProcessor() = 0;
72
73  // Returns a list of conflicting files for the given origin.
74  virtual void GetConflictFiles(
75      const GURL& origin,
76      const fileapi::SyncFileSetCallback& callback) = 0;
77
78  // Returns the metadata of a remote file pointed by |url|.
79  virtual void GetRemoteFileMetadata(
80      const fileapi::FileSystemURL& url,
81      const fileapi::SyncFileMetadataCallback& callback) = 0;
82
83 private:
84  DISALLOW_COPY_AND_ASSIGN(RemoteFileSyncService);
85};
86
87}  // namespace sync_file_system
88
89#endif  // CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_FILE_SYNC_SERVICE_H_
90