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

Side by Side Diff: services/file/file_service.h

Issue 2722293002: Fix lifetime of leveldb::MojoEnv instances. (Closed)
Patch Set: annotate leaks Created 3 years, 8 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
OLDNEW
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/binder_registry.h" 14 #include "services/service_manager/public/cpp/binder_registry.h"
15 #include "services/service_manager/public/cpp/interface_factory.h" 15 #include "services/service_manager/public/cpp/interface_factory.h"
16 #include "services/service_manager/public/cpp/service.h" 16 #include "services/service_manager/public/cpp/service.h"
17 17
18 namespace leveldb {
19 class MojoEnv;
20 }
21
18 namespace file { 22 namespace file {
19 23
20 std::unique_ptr<service_manager::Service> CreateFileService( 24 std::unique_ptr<service_manager::Service> CreateFileService(
21 scoped_refptr<base::SingleThreadTaskRunner> file_service_runner, 25 leveldb::MojoEnv* leveldb_env,
22 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner); 26 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner);
23 27
24 class FileService 28 class FileService
25 : public service_manager::Service, 29 : public service_manager::Service,
26 public service_manager::InterfaceFactory<mojom::FileSystem>, 30 public service_manager::InterfaceFactory<mojom::FileSystem>,
27 public service_manager::InterfaceFactory<leveldb::mojom::LevelDBService> { 31 public service_manager::InterfaceFactory<leveldb::mojom::LevelDBService> {
28 public: 32 public:
29 FileService( 33 FileService(
30 scoped_refptr<base::SingleThreadTaskRunner> file_service_runner, 34 leveldb::MojoEnv* leveldb_env,
31 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner); 35 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner);
32 ~FileService() override; 36 ~FileService() override;
33 37
34 private: 38 private:
35 // |Service| override: 39 // |Service| override:
36 void OnStart() override; 40 void OnStart() override;
37 void OnBindInterface(const service_manager::ServiceInfo& source_info, 41 void OnBindInterface(const service_manager::ServiceInfo& source_info,
38 const std::string& interface_name, 42 const std::string& interface_name,
39 mojo::ScopedMessagePipeHandle interface_pipe) override; 43 mojo::ScopedMessagePipeHandle interface_pipe) override;
40 44
41 // |InterfaceFactory<mojom::FileSystem>| implementation: 45 // |InterfaceFactory<mojom::FileSystem>| implementation:
42 void Create(const service_manager::Identity& remote_identity, 46 void Create(const service_manager::Identity& remote_identity,
43 mojom::FileSystemRequest request) override; 47 mojom::FileSystemRequest request) override;
44 48
45 // |InterfaceFactory<LevelDBService>| implementation: 49 // |InterfaceFactory<LevelDBService>| implementation:
46 void Create(const service_manager::Identity& remote_identity, 50 void Create(const service_manager::Identity& remote_identity,
47 leveldb::mojom::LevelDBServiceRequest request) override; 51 leveldb::mojom::LevelDBServiceRequest request) override;
48 52
49 void OnLevelDBServiceError(); 53 void OnLevelDBServiceError();
50 54
55 leveldb::MojoEnv* leveldb_env_;
51 scoped_refptr<base::SingleThreadTaskRunner> file_service_runner_; 56 scoped_refptr<base::SingleThreadTaskRunner> file_service_runner_;
52 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner_; 57 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner_;
53 58
54 // We create these two objects so we can delete them on the correct task 59 // We create these two objects so we can delete them on the correct task
55 // runners. 60 // runners.
56 class FileSystemObjects; 61 class FileSystemObjects;
57 std::unique_ptr<FileSystemObjects> file_system_objects_; 62 std::unique_ptr<FileSystemObjects> file_system_objects_;
58 63
59 class LevelDBServiceObjects; 64 class LevelDBServiceObjects;
60 std::unique_ptr<LevelDBServiceObjects> leveldb_objects_; 65 std::unique_ptr<LevelDBServiceObjects> leveldb_objects_;
61 66
62 service_manager::BinderRegistry registry_; 67 service_manager::BinderRegistry registry_;
63 68
64 DISALLOW_COPY_AND_ASSIGN(FileService); 69 DISALLOW_COPY_AND_ASSIGN(FileService);
65 }; 70 };
66 71
67 } // namespace file 72 } // namespace file
68 73
69 #endif // SERVICES_FILE_FILE_SERVICE_H_ 74 #endif // SERVICES_FILE_FILE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698