1 // Copyright 2013 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_ENGINE_CONTEXT_H_ 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_CONTEXT_H_ 7 8 #include "base/basictypes.h" 9 #include "base/memory/ref_counted.h" 10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/weak_ptr.h" 12 #include "base/sequence_checker.h" 13 14 namespace base { 15 class SequencedTaskRunner; 16 class SingleThreadTaskRunner; 17 } 18 19 namespace drive { 20 class DriveServiceInterface; 21 class DriveUploaderInterface; 22 } 23 24 namespace sync_file_system { 25 26 class RemoteChangeProcessor; 27 class TaskLogger; 28 29 namespace drive_backend { 30 31 class MetadataDatabase; 32 33 class SyncEngineContext { 34 public: 35 SyncEngineContext( 36 scoped_ptr<drive::DriveServiceInterface> drive_service, 37 scoped_ptr<drive::DriveUploaderInterface> drive_uploader, 38 TaskLogger* task_logger, 39 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, 40 const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner); 41 ~SyncEngineContext(); 42 43 void SetMetadataDatabase(scoped_ptr<MetadataDatabase> metadata_database); 44 void SetRemoteChangeProcessor( 45 RemoteChangeProcessor* remote_change_processor); 46 47 drive::DriveServiceInterface* GetDriveService(); 48 drive::DriveUploaderInterface* GetDriveUploader(); 49 base::WeakPtr<TaskLogger> GetTaskLogger(); 50 MetadataDatabase* GetMetadataDatabase(); 51 RemoteChangeProcessor* GetRemoteChangeProcessor(); 52 base::SingleThreadTaskRunner* GetUITaskRunner(); 53 base::SequencedTaskRunner* GetWorkerTaskRunner(); 54 55 scoped_ptr<MetadataDatabase> PassMetadataDatabase(); 56 57 void DetachFromSequence(); 58 59 private: 60 friend class DriveBackendSyncTest; 61 62 scoped_ptr<drive::DriveServiceInterface> drive_service_; 63 scoped_ptr<drive::DriveUploaderInterface> drive_uploader_; 64 base::WeakPtr<TaskLogger> task_logger_; 65 RemoteChangeProcessor* remote_change_processor_; // Not owned. 66 67 scoped_ptr<MetadataDatabase> metadata_database_; 68 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 69 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_; 70 71 base::SequenceChecker sequence_checker_; 72 73 DISALLOW_COPY_AND_ASSIGN(SyncEngineContext); 74 }; 75 76 } // namespace drive_backend 77 } // namespace sync_file_system 78 79 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_CONTEXT_H_ 80