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 COMPONENTS_PROFILE_SERVICE_PROFILE_APP_H_ | 5 #ifndef SERVICES_USER_USER_SHELL_CLIENT_H_ |
6 #define COMPONENTS_PROFILE_SERVICE_PROFILE_APP_H_ | 6 #define SERVICES_USER_USER_SHELL_CLIENT_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "components/filesystem/lock_table.h" | 9 #include "components/filesystem/lock_table.h" |
10 #include "components/leveldb/public/interfaces/leveldb.mojom.h" | 10 #include "components/leveldb/public/interfaces/leveldb.mojom.h" |
11 #include "components/profile_service/public/interfaces/profile.mojom.h" | |
12 #include "mojo/public/cpp/bindings/binding_set.h" | 11 #include "mojo/public/cpp/bindings/binding_set.h" |
13 #include "services/shell/public/cpp/interface_factory.h" | 12 #include "services/shell/public/cpp/interface_factory.h" |
14 #include "services/shell/public/cpp/shell_client.h" | 13 #include "services/shell/public/cpp/shell_client.h" |
15 #include "services/tracing/public/cpp/tracing_impl.h" | 14 #include "services/tracing/public/cpp/tracing_impl.h" |
| 15 #include "services/user/public/interfaces/user_service.mojom.h" |
16 | 16 |
17 namespace profile { | 17 namespace user_service { |
18 | 18 |
19 scoped_ptr<mojo::ShellClient> CreateProfileApp( | 19 scoped_ptr<mojo::ShellClient> CreateUserShellClient( |
20 scoped_refptr<base::SingleThreadTaskRunner> profile_service_runner, | 20 scoped_refptr<base::SingleThreadTaskRunner> user_service_runner, |
21 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner); | 21 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner); |
22 | 22 |
23 // Application which hands off per-profile services. | 23 class UserShellClient : public mojo::ShellClient, |
24 // | 24 public mojo::InterfaceFactory<mojom::UserService>, |
25 // This Application serves ProfileService. In the future, this application will | 25 public mojo::InterfaceFactory<leveldb::LevelDBService> { |
26 // probably also offer any service that most Profile using applications will | |
27 // need, such as preferences; this class will have to be made into a | |
28 // application which is an InterfaceProvider which internally spawns threads | |
29 // for different sub-applications. | |
30 class ProfileApp : public mojo::ShellClient, | |
31 public mojo::InterfaceFactory<ProfileService>, | |
32 public mojo::InterfaceFactory<leveldb::LevelDBService> { | |
33 public: | 26 public: |
34 ProfileApp( | 27 UserShellClient( |
35 scoped_refptr<base::SingleThreadTaskRunner> profile_service_runner, | 28 scoped_refptr<base::SingleThreadTaskRunner> user_service_runner, |
36 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner); | 29 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner); |
37 ~ProfileApp() override; | 30 ~UserShellClient() override; |
38 | 31 |
39 private: | 32 private: |
40 // |ShellClient| override: | 33 // |ShellClient| override: |
41 void Initialize(mojo::Connector* connector, | 34 void Initialize(mojo::Connector* connector, |
42 const mojo::Identity& identity, | 35 const mojo::Identity& identity, |
43 uint32_t id) override; | 36 uint32_t id) override; |
44 bool AcceptConnection(mojo::Connection* connection) override; | 37 bool AcceptConnection(mojo::Connection* connection) override; |
45 | 38 |
46 // |InterfaceFactory<ProfileService>| implementation: | 39 // |InterfaceFactory<mojom::UserService>| implementation: |
47 void Create(mojo::Connection* connection, | 40 void Create(mojo::Connection* connection, |
48 ProfileServiceRequest request) override; | 41 mojom::UserServiceRequest request) override; |
49 | 42 |
50 // |InterfaceFactory<LevelDBService>| implementation: | 43 // |InterfaceFactory<LevelDBService>| implementation: |
51 void Create(mojo::Connection* connection, | 44 void Create(mojo::Connection* connection, |
52 leveldb::LevelDBServiceRequest request) override; | 45 leveldb::LevelDBServiceRequest request) override; |
53 | 46 |
54 void OnLevelDBServiceRequest(mojo::Connection* connection, | 47 void OnLevelDBServiceRequest(mojo::Connection* connection, |
55 leveldb::LevelDBServiceRequest request); | 48 leveldb::LevelDBServiceRequest request); |
56 void OnLevelDBServiceError(); | 49 void OnLevelDBServiceError(); |
57 | 50 |
58 scoped_refptr<base::SingleThreadTaskRunner> profile_service_runner_; | 51 scoped_refptr<base::SingleThreadTaskRunner> user_service_runner_; |
59 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner_; | 52 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner_; |
60 | 53 |
61 mojo::TracingImpl tracing_; | 54 mojo::TracingImpl tracing_; |
62 | 55 |
63 // We create these two objects so we can delete them on the correct task | 56 // We create these two objects so we can delete them on the correct task |
64 // runners. | 57 // runners. |
65 class ProfileServiceObjects; | 58 class UserServiceObjects; |
66 scoped_ptr<ProfileServiceObjects> profile_objects_; | 59 scoped_ptr<UserServiceObjects> user_objects_; |
67 | 60 |
68 class LevelDBServiceObjects; | 61 class LevelDBServiceObjects; |
69 scoped_ptr<LevelDBServiceObjects> leveldb_objects_; | 62 scoped_ptr<LevelDBServiceObjects> leveldb_objects_; |
70 | 63 |
71 DISALLOW_COPY_AND_ASSIGN(ProfileApp); | 64 DISALLOW_COPY_AND_ASSIGN(UserShellClient); |
72 }; | 65 }; |
73 | 66 |
74 } // namespace profile | 67 } // namespace user_service |
75 | 68 |
76 #endif // COMPONENTS_PROFILE_SERVICE_PROFILE_APP_H_ | 69 #endif // SERVICES_USER_USER_SHELL_CLIENT_H_ |
OLD | NEW |