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

Side by Side Diff: components/profile_service/profile_app.h

Issue 1737933002: mojo leveldb: Get profile and leveldb connected to DOMStorageContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove stray mark. Created 4 years, 9 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_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 "base/memory/ref_counted.h"
8 #include "components/filesystem/lock_table.h" 9 #include "components/filesystem/lock_table.h"
9 #include "components/leveldb/public/interfaces/leveldb.mojom.h" 10 #include "components/leveldb/public/interfaces/leveldb.mojom.h"
10 #include "components/profile_service/public/interfaces/profile.mojom.h" 11 #include "components/profile_service/public/interfaces/profile.mojom.h"
11 #include "mojo/public/cpp/bindings/binding_set.h" 12 #include "mojo/public/cpp/bindings/binding_set.h"
12 #include "mojo/services/tracing/public/cpp/tracing_impl.h" 13 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
13 #include "mojo/shell/public/cpp/interface_factory.h" 14 #include "mojo/shell/public/cpp/interface_factory.h"
14 #include "mojo/shell/public/cpp/shell_client.h" 15 #include "mojo/shell/public/cpp/shell_client.h"
15 16
16 namespace filesystem {
17 class LockTable;
18 }
19
20 namespace profile { 17 namespace profile {
21 18
22 scoped_ptr<mojo::ShellClient> CreateProfileApp(); 19 scoped_ptr<mojo::ShellClient> CreateProfileApp(
20 const scoped_refptr<base::SingleThreadTaskRunner>& profile_service_runner,
21 const scoped_refptr<base::SingleThreadTaskRunner>& leveldb_service_runner);
michaeln 2016/03/17 22:35:41 ditto smartptr passing mavens
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; this class will have to be made into a
29 // process to minimize IPC. 28 // application which is an InterfaceProvider which internally spawns threads
30 // 29 // for different sub-applications.
31 // In the future, this application will probably also offer any service that
32 // most Profile using applications will need, such as preferences.
33 class ProfileApp : public mojo::ShellClient, 30 class ProfileApp : public mojo::ShellClient,
34 public mojo::InterfaceFactory<ProfileService>, 31 public mojo::InterfaceFactory<ProfileService>,
35 public mojo::InterfaceFactory<leveldb::LevelDBService> { 32 public mojo::InterfaceFactory<leveldb::LevelDBService> {
36 public: 33 public:
37 ProfileApp(); 34 ProfileApp(
35 const scoped_refptr<base::SingleThreadTaskRunner>& profile_service_runner,
36 const scoped_refptr<base::SingleThreadTaskRunner>&
37 leveldb_service_runner);
38 ~ProfileApp() override; 38 ~ProfileApp() override;
39 39
40 // Currently, ProfileApp is run from within the chrome process. This means it
41 // that the ApplicationLoader is registered during MojoShellContext startup,
42 // even though the application itself is not started. As soon as a
43 // BrowserContext is created, the BrowserContext will choose a |user_id| for
44 // itself and call us to register the mapping from |user_id| to
45 // |profile_data_dir|.
46 //
47 // This data is then accessed when we get our Initialize() call.
48 //
49 // 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
51 // ProfileApp gets put in its own sandboxed process.
52 static void AssociateMojoUserIDWithProfileDir(
53 const std::string& user_id,
54 const base::FilePath& profile_data_dir);
55
56 private: 40 private:
57 // |ShellClient| override: 41 // |ShellClient| override:
58 void Initialize(mojo::Connector* connector, 42 void Initialize(mojo::Connector* connector,
59 const mojo::Identity& identity, 43 const mojo::Identity& identity,
60 uint32_t id) override; 44 uint32_t id) override;
61 bool AcceptConnection(mojo::Connection* connection) override; 45 bool AcceptConnection(mojo::Connection* connection) override;
62 46
63 // |InterfaceFactory<ProfileService>| implementation: 47 // |InterfaceFactory<ProfileService>| implementation:
64 void Create(mojo::Connection* connection, 48 void Create(mojo::Connection* connection,
65 ProfileServiceRequest request) override; 49 ProfileServiceRequest request) override;
66 50
67 // |InterfaceFactory<LevelDBService>| implementation: 51 // |InterfaceFactory<LevelDBService>| implementation:
68 void Create(mojo::Connection* connection, 52 void Create(mojo::Connection* connection,
69 leveldb::LevelDBServiceRequest request) override; 53 leveldb::LevelDBServiceRequest request) override;
70 54
55 void OnLevelDBServiceRequest(mojo::Connection* connection,
56 leveldb::LevelDBServiceRequest request);
57 void OnLevelDBServiceError();
58
59 scoped_refptr<base::SingleThreadTaskRunner> profile_service_runner_;
60 scoped_refptr<base::SingleThreadTaskRunner> leveldb_service_runner_;
61
71 mojo::TracingImpl tracing_; 62 mojo::TracingImpl tracing_;
72 63
73 scoped_ptr<ProfileService> profile_service_; 64 // We create these two objects so we can delete them on the correct task
74 mojo::BindingSet<ProfileService> profile_bindings_; 65 // runners.
66 class ProfileServiceObjects;
67 scoped_ptr<ProfileServiceObjects> profile_objects_;
75 68
76 scoped_ptr<leveldb::LevelDBService> leveldb_service_; 69 class LevelDBServiceObjects;
77 mojo::BindingSet<leveldb::LevelDBService> leveldb_bindings_; 70 scoped_ptr<LevelDBServiceObjects> leveldb_objects_;
78
79 scoped_ptr<filesystem::LockTable> lock_table_;
80
81 base::FilePath profile_data_dir_;
82 71
83 DISALLOW_COPY_AND_ASSIGN(ProfileApp); 72 DISALLOW_COPY_AND_ASSIGN(ProfileApp);
84 }; 73 };
85 74
86 } // namespace profile 75 } // namespace profile
87 76
88 #endif // COMPONENTS_PROFILE_SERVICE_PROFILE_APP_H_ 77 #endif // COMPONENTS_PROFILE_SERVICE_PROFILE_APP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698