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 COMPONENTS_PROFILE_SERVICE_PROFILE_APP_H_ |
6 #define COMPONENTS_PROFILE_SERVICE_PROFILE_APP_H_ | 6 #define COMPONENTS_PROFILE_SERVICE_PROFILE_APP_H_ |
7 | 7 |
8 #include "components/filesystem/lock_table.h" | 8 #include "components/filesystem/lock_table.h" |
9 #include "components/leveldb/public/interfaces/leveldb.mojom.h" | |
10 #include "components/profile_service/public/interfaces/profile.mojom.h" | 9 #include "components/profile_service/public/interfaces/profile.mojom.h" |
11 #include "mojo/public/cpp/bindings/binding_set.h" | 10 #include "mojo/public/cpp/bindings/binding_set.h" |
12 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 11 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
13 #include "mojo/shell/public/cpp/interface_factory.h" | 12 #include "mojo/shell/public/cpp/interface_factory.h" |
14 #include "mojo/shell/public/cpp/shell_client.h" | 13 #include "mojo/shell/public/cpp/shell_client.h" |
15 | 14 |
16 namespace filesystem { | 15 namespace filesystem { |
17 class LockTable; | 16 class LockTable; |
18 } | 17 } |
19 | 18 |
20 namespace profile { | 19 namespace profile { |
21 | 20 |
22 scoped_ptr<mojo::ShellClient> CreateProfileApp(); | 21 scoped_ptr<mojo::ShellClient> CreateProfileApp(); |
23 | 22 |
24 // Application which hands off per-profile services. | 23 // Application which hands off per-profile services. |
25 // | 24 // |
26 // This Application serves ProfileService, and serves LevelDBService since most | 25 // This Application serves ProfileService. In the future, this application will |
27 // of the users of leveldb will want to write directly to the Directory | 26 // probably also offer any service that most Profile using applications will |
28 // provided by the ProfileService; we want file handling to be done in the same | 27 // need, such as preferences, but these will need to be served off of separate |
29 // process to minimize IPC. | 28 // threads; this class will have to be made into a application which is an |
30 // | 29 // InterfaceProvider which internally spawns threads for different |
31 // In the future, this application will probably also offer any service that | 30 // sub-applications. |
Ben Goodger (Google)
2016/03/04 20:50:49
what's the reason for needing to provide interface
Elliot Glaysher
2016/03/10 21:00:35
[Discussed in person; leaving the comment here for
| |
32 // most Profile using applications will need, such as preferences. | |
33 class ProfileApp : public mojo::ShellClient, | 31 class ProfileApp : public mojo::ShellClient, |
34 public mojo::InterfaceFactory<ProfileService>, | 32 public mojo::InterfaceFactory<ProfileService> { |
35 public mojo::InterfaceFactory<leveldb::LevelDBService> { | |
36 public: | 33 public: |
37 ProfileApp(); | 34 ProfileApp(); |
38 ~ProfileApp() override; | 35 ~ProfileApp() override; |
39 | 36 |
40 // Currently, ProfileApp is run from within the chrome process. This means it | 37 // Currently, ProfileApp is run from within the chrome process. This means it |
41 // that the ApplicationLoader is registered during MojoShellContext startup, | 38 // that the ApplicationLoader is registered during MojoShellContext startup, |
42 // even though the application itself is not started. As soon as a | 39 // even though the application itself is not started. As soon as a |
43 // BrowserContext is created, the BrowserContext will choose a |user_id| for | 40 // BrowserContext is created, the BrowserContext will choose a |user_id| for |
44 // itself and call us to register the mapping from |user_id| to | 41 // itself and call us to register the mapping from |user_id| to |
45 // |profile_data_dir|. | 42 // |profile_data_dir|. |
46 // | 43 // |
47 // This data is then accessed when we get our Initialize() call. | 44 // This data is then accessed when we get our Initialize() call. |
48 // | 45 // |
49 // TODO(erg): This is a temporary hack until we redo how we initialize mojo | 46 // TODO(erg): This is a temporary hack until we redo how we initialize mojo |
50 // applications inside of chrome in general; this system won't work once | 47 // applications inside of chrome in general; this system won't work once |
51 // ProfileApp gets put in its own sandboxed process. | 48 // ProfileApp gets put in its own sandboxed process. |
52 static void AssociateMojoUserIDWithProfileDir( | 49 static void AssociateMojoUserIDWithProfileDir( |
53 uint32_t user_id, | 50 uint32_t user_id, |
54 const base::FilePath& profile_data_dir); | 51 const base::FilePath& profile_data_dir); |
55 | 52 |
56 private: | 53 private: |
54 void OnProfileServiceDestroyed(); | |
55 | |
57 // |ShellClient| override: | 56 // |ShellClient| override: |
58 void Initialize(mojo::Connector* connector, | 57 void Initialize(mojo::Connector* connector, |
59 const std::string& url, | 58 const std::string& url, |
60 uint32_t id, | 59 uint32_t id, |
61 uint32_t user_id) override; | 60 uint32_t user_id) override; |
62 bool AcceptConnection(mojo::Connection* connection) override; | 61 bool AcceptConnection(mojo::Connection* connection) override; |
63 | 62 |
64 // |InterfaceFactory<ProfileService>| implementation: | 63 // |InterfaceFactory<ProfileService>| implementation: |
65 void Create(mojo::Connection* connection, | 64 void Create(mojo::Connection* connection, |
66 mojo::InterfaceRequest<ProfileService> request) override; | 65 mojo::InterfaceRequest<ProfileService> request) override; |
67 | 66 |
68 // |InterfaceFactory<LevelDBService>| implementation: | |
69 void Create(mojo::Connection* connection, | |
70 mojo::InterfaceRequest<leveldb::LevelDBService> request) override; | |
71 | |
72 mojo::TracingImpl tracing_; | 67 mojo::TracingImpl tracing_; |
73 | 68 |
74 scoped_ptr<ProfileService> profile_service_; | 69 scoped_ptr<ProfileService> profile_service_; |
75 mojo::BindingSet<ProfileService> profile_bindings_; | 70 mojo::BindingSet<ProfileService> profile_bindings_; |
76 | 71 |
77 scoped_ptr<leveldb::LevelDBService> leveldb_service_; | |
78 mojo::BindingSet<leveldb::LevelDBService> leveldb_bindings_; | |
79 | |
80 scoped_ptr<filesystem::LockTable> lock_table_; | 72 scoped_ptr<filesystem::LockTable> lock_table_; |
81 | 73 |
82 base::FilePath profile_data_dir_; | 74 base::FilePath profile_data_dir_; |
83 | 75 |
76 int profiles_outstanding_; | |
77 | |
84 DISALLOW_COPY_AND_ASSIGN(ProfileApp); | 78 DISALLOW_COPY_AND_ASSIGN(ProfileApp); |
85 }; | 79 }; |
86 | 80 |
87 } // namespace profile | 81 } // namespace profile |
88 | 82 |
89 #endif // COMPONENTS_PROFILE_SERVICE_PROFILE_APP_H_ | 83 #endif // COMPONENTS_PROFILE_SERVICE_PROFILE_APP_H_ |
OLD | NEW |