OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MASH_SESSION_SESSION_H_ | 5 #ifndef MASH_SESSION_SESSION_H_ |
6 #define MASH_SESSION_SESSION_H_ | 6 #define MASH_SESSION_SESSION_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "mash/session/public/interfaces/session.mojom.h" | 13 #include "mash/session/public/interfaces/session.mojom.h" |
14 #include "mojo/public/cpp/bindings/binding_set.h" | 14 #include "mojo/public/cpp/bindings/binding_set.h" |
15 #include "mojo/public/cpp/bindings/interface_ptr_set.h" | 15 #include "mojo/public/cpp/bindings/interface_ptr_set.h" |
16 #include "services/service_manager/public/cpp/interface_factory.h" | 16 #include "services/service_manager/public/cpp/interface_factory.h" |
17 #include "services/service_manager/public/cpp/service.h" | 17 #include "services/service_manager/public/cpp/service.h" |
18 | 18 |
19 namespace service_manager { | 19 namespace service_manager { |
20 class Connection; | 20 class Connection; |
21 class ServiceContext; | |
22 } | 21 } |
23 | 22 |
24 namespace mash { | 23 namespace mash { |
25 namespace session { | 24 namespace session { |
26 | 25 |
27 class Session : public service_manager::Service, | 26 class Session : public service_manager::Service, |
28 public mojom::Session, | 27 public mojom::Session, |
29 public service_manager::InterfaceFactory<mojom::Session> { | 28 public service_manager::InterfaceFactory<mojom::Session> { |
30 public: | 29 public: |
31 Session(); | 30 Session(); |
32 ~Session() override; | 31 ~Session() override; |
33 | 32 |
34 private: | 33 private: |
35 // service_manager::Service: | 34 // service_manager::Service: |
36 void OnStart(service_manager::ServiceContext* context) override; | 35 void OnStart() override; |
37 bool OnConnect(const service_manager::ServiceInfo& remote_info, | 36 bool OnConnect(const service_manager::ServiceInfo& remote_info, |
38 service_manager::InterfaceRegistry* registry) override; | 37 service_manager::InterfaceRegistry* registry) override; |
39 | 38 |
40 // mojom::Session: | 39 // mojom::Session: |
41 void Logout() override; | 40 void Logout() override; |
42 void SwitchUser() override; | 41 void SwitchUser() override; |
43 void AddScreenlockStateListener( | 42 void AddScreenlockStateListener( |
44 mojom::ScreenlockStateListenerPtr listener) override; | 43 mojom::ScreenlockStateListenerPtr listener) override; |
45 void LockScreen() override; | 44 void LockScreen() override; |
46 void UnlockScreen() override; | 45 void UnlockScreen() override; |
47 | 46 |
48 // service_manager::InterfaceFactory<mojom::Session>: | 47 // service_manager::InterfaceFactory<mojom::Session>: |
49 void Create(const service_manager::Identity& remote_identity, | 48 void Create(const service_manager::Identity& remote_identity, |
50 mojom::SessionRequest request) override; | 49 mojom::SessionRequest request) override; |
51 | 50 |
52 void StartWindowManager(); | 51 void StartWindowManager(); |
53 void StartQuickLaunch(); | 52 void StartQuickLaunch(); |
54 | 53 |
55 void StartScreenlock(); | 54 void StartScreenlock(); |
56 void StopScreenlock(); | 55 void StopScreenlock(); |
57 | 56 |
58 // Starts the application at |url|, running |restart_callback| if the | 57 // Starts the application at |url|, running |restart_callback| if the |
59 // connection to the application is closed. | 58 // connection to the application is closed. |
60 void StartRestartableService(const std::string& url, | 59 void StartRestartableService(const std::string& url, |
61 const base::Closure& restart_callback); | 60 const base::Closure& restart_callback); |
62 | 61 |
63 service_manager::ServiceContext* context_ = nullptr; | |
64 | |
65 std::map<std::string, std::unique_ptr<service_manager::Connection>> | 62 std::map<std::string, std::unique_ptr<service_manager::Connection>> |
66 connections_; | 63 connections_; |
67 bool screen_locked_; | 64 bool screen_locked_; |
68 mojo::BindingSet<mojom::Session> bindings_; | 65 mojo::BindingSet<mojom::Session> bindings_; |
69 mojo::InterfacePtrSet<mojom::ScreenlockStateListener> screenlock_listeners_; | 66 mojo::InterfacePtrSet<mojom::ScreenlockStateListener> screenlock_listeners_; |
70 | 67 |
71 DISALLOW_COPY_AND_ASSIGN(Session); | 68 DISALLOW_COPY_AND_ASSIGN(Session); |
72 }; | 69 }; |
73 | 70 |
74 } // namespace session | 71 } // namespace session |
75 } // namespace mash | 72 } // namespace mash |
76 | 73 |
77 #endif // MASH_SESSION_SESSION_H_ | 74 #endif // MASH_SESSION_SESSION_H_ |
OLD | NEW |