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

Side by Side Diff: components/leveldb/leveldb_app.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 COMPONENTS_LEVELDB_LEVELDB_APP_H_ 5 #ifndef COMPONENTS_LEVELDB_LEVELDB_APP_H_
6 #define COMPONENTS_LEVELDB_LEVELDB_APP_H_ 6 #define COMPONENTS_LEVELDB_LEVELDB_APP_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.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/service_manager/public/cpp/binder_registry.h" 13 #include "services/service_manager/public/cpp/binder_registry.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 #include "services/tracing/public/cpp/provider.h" 16 #include "services/tracing/public/cpp/provider.h"
17 17
18 namespace leveldb { 18 namespace leveldb {
19 19
20 class MojoEnv;
21
20 class LevelDBApp 22 class LevelDBApp
21 : public service_manager::Service, 23 : public service_manager::Service,
22 public service_manager::InterfaceFactory<mojom::LevelDBService> { 24 public service_manager::InterfaceFactory<mojom::LevelDBService> {
23 public: 25 public:
24 LevelDBApp(); 26 LevelDBApp();
25 ~LevelDBApp() override; 27 ~LevelDBApp() override;
26 28
27 private: 29 private:
28 // |Service| override: 30 // |Service| override:
29 void OnStart() override; 31 void OnStart() override;
30 void OnBindInterface(const service_manager::ServiceInfo& source_info, 32 void OnBindInterface(const service_manager::ServiceInfo& source_info,
31 const std::string& interface_name, 33 const std::string& interface_name,
32 mojo::ScopedMessagePipeHandle interface_pipe) override; 34 mojo::ScopedMessagePipeHandle interface_pipe) override;
33 35
34 // |InterfaceFactory<mojom::LevelDBService>| implementation: 36 // |InterfaceFactory<mojom::LevelDBService>| implementation:
35 void Create(const service_manager::Identity& remote_identity, 37 void Create(const service_manager::Identity& remote_identity,
36 leveldb::mojom::LevelDBServiceRequest request) override; 38 leveldb::mojom::LevelDBServiceRequest request) override;
37 39
38 tracing::Provider tracing_; 40 tracing::Provider tracing_;
39 std::unique_ptr<mojom::LevelDBService> service_; 41 std::unique_ptr<mojom::LevelDBService> service_;
40 service_manager::BinderRegistry registry_; 42 service_manager::BinderRegistry registry_;
41 mojo::BindingSet<mojom::LevelDBService> bindings_; 43 mojo::BindingSet<mojom::LevelDBService> bindings_;
42 44
43 base::Thread file_thread_; 45 base::Thread file_thread_;
46 // env_ is owned by LevelDBApp (since it depends on the file_thread_ above),
cmumford 2017/04/12 21:51:34 The only reason ChromiumEnv has a NOTREACHED in th
Marijn Kruisselbrink 2017/04/12 22:00:34 That it not the only reason. Destroying ChromiumEn
cmumford 2017/04/12 23:06:39 That's right. Also, this was prior to your change
Marijn Kruisselbrink 2017/04/12 23:46:22 Yeah, maybe that's the way to go... If we do that,
47 // but doesn't support destruction, so it is leaked.
48 MojoEnv* env_;
44 49
45 DISALLOW_COPY_AND_ASSIGN(LevelDBApp); 50 DISALLOW_COPY_AND_ASSIGN(LevelDBApp);
46 }; 51 };
47 52
48 } // namespace leveldb 53 } // namespace leveldb
49 54
50 #endif // COMPONENTS_LEVELDB_LEVELDB_APP_H_ 55 #endif // COMPONENTS_LEVELDB_LEVELDB_APP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698