sync_worker_interface.h revision 03b57e008b61dfcb1fbad3aea950ae0e001748b0
1// Copyright 2014 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_DRIVE_BACKEND_SYNC_WORKER_INTERFACE_H_ 6#define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_WORKER_INTERFACE_H_ 7 8#include <string> 9 10#include "base/memory/scoped_ptr.h" 11#include "chrome/browser/sync_file_system/remote_file_sync_service.h" 12#include "chrome/browser/sync_file_system/sync_action.h" 13#include "chrome/browser/sync_file_system/sync_callbacks.h" 14#include "chrome/browser/sync_file_system/sync_direction.h" 15#include "net/base/network_change_notifier.h" 16 17class GURL; 18 19namespace base { 20class FilePath; 21class ListValue; 22} 23 24namespace drive { 25class DriveServiceInterface; 26class DriveUploaderInterface; 27} 28 29namespace storage { 30class FileSystemURL; 31} 32 33namespace sync_file_system { 34 35class FileChange; 36class SyncFileMetadata; 37 38namespace drive_backend { 39 40class MetadataDatabase; 41class RemoteChangeProcessorOnWorker; 42class SyncEngineContext; 43class SyncTaskManager; 44 45class SyncWorkerInterface { 46 public: 47 class Observer { 48 public: 49 virtual void OnPendingFileListUpdated(int item_count) = 0; 50 virtual void OnFileStatusChanged(const storage::FileSystemURL& url, 51 SyncFileStatus file_status, 52 SyncAction sync_action, 53 SyncDirection direction) = 0; 54 virtual void UpdateServiceState(RemoteServiceState state, 55 const std::string& description) = 0; 56 57 protected: 58 virtual ~Observer() {} 59 }; 60 61 SyncWorkerInterface() {} 62 virtual ~SyncWorkerInterface() {} 63 64 // Initializes SyncWorkerInterface after constructions of some member classes. 65 virtual void Initialize( 66 scoped_ptr<SyncEngineContext> sync_engine_context) = 0; 67 68 // See RemoteFileSyncService for the details. 69 virtual void RegisterOrigin(const GURL& origin, 70 const SyncStatusCallback& callback) = 0; 71 virtual void EnableOrigin(const GURL& origin, 72 const SyncStatusCallback& callback) = 0; 73 virtual void DisableOrigin(const GURL& origin, 74 const SyncStatusCallback& callback) = 0; 75 virtual void UninstallOrigin( 76 const GURL& origin, 77 RemoteFileSyncService::UninstallFlag flag, 78 const SyncStatusCallback& callback) = 0; 79 virtual void ProcessRemoteChange(const SyncFileCallback& callback) = 0; 80 virtual void SetRemoteChangeProcessor( 81 RemoteChangeProcessorOnWorker* remote_change_processor_on_worker) = 0; 82 virtual RemoteServiceState GetCurrentState() const = 0; 83 virtual void GetOriginStatusMap( 84 const RemoteFileSyncService::StatusMapCallback& callback) = 0; 85 virtual scoped_ptr<base::ListValue> DumpFiles(const GURL& origin) = 0; 86 virtual scoped_ptr<base::ListValue> DumpDatabase() = 0; 87 virtual void SetSyncEnabled(bool enabled) = 0; 88 virtual void PromoteDemotedChanges(const base::Closure& callback) = 0; 89 90 // See LocalChangeProcessor for the details. 91 virtual void ApplyLocalChange(const FileChange& local_change, 92 const base::FilePath& local_path, 93 const SyncFileMetadata& local_metadata, 94 const storage::FileSystemURL& url, 95 const SyncStatusCallback& callback) = 0; 96 97 virtual void ActivateService(RemoteServiceState service_state, 98 const std::string& description) = 0; 99 virtual void DeactivateService(const std::string& description) = 0; 100 101 virtual void DetachFromSequence() = 0; 102 103 virtual void AddObserver(Observer* observer) = 0; 104 105 private: 106 friend class SyncEngineTest; 107 108 DISALLOW_COPY_AND_ASSIGN(SyncWorkerInterface); 109}; 110 111} // namespace drive_backend 112} // namespace sync_file_system 113 114#endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_WORKER_INTERFACE_H_ 115