| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 SERVICES_FILE_FILE_SERVICE_H_ | 5 #ifndef SERVICES_FILE_FILE_SERVICE_H_ |
| 6 #define SERVICES_FILE_FILE_SERVICE_H_ | 6 #define SERVICES_FILE_FILE_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "components/filesystem/lock_table.h" | 10 #include "components/filesystem/lock_table.h" |
| 11 #include "components/leveldb/public/interfaces/leveldb.mojom.h" | 11 #include "components/leveldb/public/interfaces/leveldb.mojom.h" |
| 12 #include "mojo/public/cpp/bindings/binding_set.h" | 12 #include "mojo/public/cpp/bindings/binding_set.h" |
| 13 #include "services/file/public/interfaces/file_system.mojom.h" | 13 #include "services/file/public/interfaces/file_system.mojom.h" |
| 14 #include "services/service_manager/public/cpp/interface_factory.h" | 14 #include "services/service_manager/public/cpp/interface_factory.h" |
| 15 #include "services/service_manager/public/cpp/service.h" | 15 #include "services/service_manager/public/cpp/service.h" |
| 16 | 16 |
| 17 namespace file { | 17 namespace file { |
| 18 | 18 |
| 19 std::unique_ptr<shell::Service> CreateFileService( | 19 std::unique_ptr<service_manager::Service> CreateFileService( |
| 20 scoped_refptr<base::SingleThreadTaskRunner> file_service_runner, | 20 scoped_refptr<base::SingleThreadTaskRunner> file_service_runner, |
| 21 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner, | 21 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner, |
| 22 const base::Closure& quit_closure); | 22 const base::Closure& quit_closure); |
| 23 | 23 |
| 24 class FileService | 24 class FileService |
| 25 : public shell::Service, | 25 : public service_manager::Service, |
| 26 public shell::InterfaceFactory<mojom::FileSystem>, | 26 public service_manager::InterfaceFactory<mojom::FileSystem>, |
| 27 public shell::InterfaceFactory<leveldb::mojom::LevelDBService> { | 27 public service_manager::InterfaceFactory<leveldb::mojom::LevelDBService> { |
| 28 public: | 28 public: |
| 29 FileService( | 29 FileService( |
| 30 scoped_refptr<base::SingleThreadTaskRunner> file_service_runner, | 30 scoped_refptr<base::SingleThreadTaskRunner> file_service_runner, |
| 31 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner); | 31 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner); |
| 32 ~FileService() override; | 32 ~FileService() override; |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 // |Service| override: | 35 // |Service| override: |
| 36 void OnStart(const shell::Identity& identity) override; | 36 void OnStart(const service_manager::Identity& identity) override; |
| 37 bool OnConnect(const shell::Identity& remote_identity, | 37 bool OnConnect(const service_manager::Identity& remote_identity, |
| 38 shell::InterfaceRegistry* registry) override; | 38 service_manager::InterfaceRegistry* registry) override; |
| 39 | 39 |
| 40 // |InterfaceFactory<mojom::FileSystem>| implementation: | 40 // |InterfaceFactory<mojom::FileSystem>| implementation: |
| 41 void Create(const shell::Identity& remote_identity, | 41 void Create(const service_manager::Identity& remote_identity, |
| 42 mojom::FileSystemRequest request) override; | 42 mojom::FileSystemRequest request) override; |
| 43 | 43 |
| 44 // |InterfaceFactory<LevelDBService>| implementation: | 44 // |InterfaceFactory<LevelDBService>| implementation: |
| 45 void Create(const shell::Identity& remote_identity, | 45 void Create(const service_manager::Identity& remote_identity, |
| 46 leveldb::mojom::LevelDBServiceRequest request) override; | 46 leveldb::mojom::LevelDBServiceRequest request) override; |
| 47 | 47 |
| 48 void OnLevelDBServiceError(); | 48 void OnLevelDBServiceError(); |
| 49 | 49 |
| 50 scoped_refptr<base::SingleThreadTaskRunner> file_service_runner_; | 50 scoped_refptr<base::SingleThreadTaskRunner> file_service_runner_; |
| 51 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner_; | 51 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner_; |
| 52 | 52 |
| 53 // We create these two objects so we can delete them on the correct task | 53 // We create these two objects so we can delete them on the correct task |
| 54 // runners. | 54 // runners. |
| 55 class FileSystemObjects; | 55 class FileSystemObjects; |
| 56 std::unique_ptr<FileSystemObjects> file_system_objects_; | 56 std::unique_ptr<FileSystemObjects> file_system_objects_; |
| 57 | 57 |
| 58 class LevelDBServiceObjects; | 58 class LevelDBServiceObjects; |
| 59 std::unique_ptr<LevelDBServiceObjects> leveldb_objects_; | 59 std::unique_ptr<LevelDBServiceObjects> leveldb_objects_; |
| 60 | 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(FileService); | 61 DISALLOW_COPY_AND_ASSIGN(FileService); |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 } // namespace file | 64 } // namespace file |
| 65 | 65 |
| 66 #endif // SERVICES_FILE_FILE_SERVICE_H_ | 66 #endif // SERVICES_FILE_FILE_SERVICE_H_ |
| OLD | NEW |