OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_ | 5 #ifndef REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_ |
6 #define REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_ | 6 #define REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/scoped_vector.h" | |
13 | 13 |
14 namespace remoting { | 14 namespace remoting { |
15 | 15 |
16 class ClientSessionDetails; | 16 class ClientSessionDetails; |
17 class HostExtension; | 17 class HostExtension; |
18 class HostExtensionSession; | 18 class HostExtensionSession; |
19 | 19 |
20 namespace protocol { | 20 namespace protocol { |
21 class ClientStub; | 21 class ClientStub; |
22 class ExtensionMessage; | 22 class ExtensionMessage; |
23 } | 23 } |
24 | 24 |
25 // Helper class used to create and manage a set of HostExtensionSession | 25 // Helper class used to create and manage a set of HostExtensionSession |
26 // instances depending upon the set of registered HostExtensions, and the | 26 // instances depending upon the set of registered HostExtensions, and the |
27 // set of capabilities negotiated between client and host. | 27 // set of capabilities negotiated between client and host. |
28 class HostExtensionSessionManager { | 28 class HostExtensionSessionManager { |
29 public: | 29 public: |
30 typedef std::vector<HostExtension*> HostExtensions; | 30 using HostExtensions = std::vector<HostExtension*>; |
31 | 31 |
32 // Creates an extension manager for the specified |extensions|. | 32 // Creates an extension manager for the specified |extensions|. |
33 HostExtensionSessionManager(const HostExtensions& extensions, | 33 HostExtensionSessionManager(const HostExtensions& extensions, |
34 ClientSessionDetails* client_session_details); | 34 ClientSessionDetails* client_session_details); |
35 virtual ~HostExtensionSessionManager(); | 35 virtual ~HostExtensionSessionManager(); |
36 | 36 |
37 // Returns the union of all capabilities supported by registered extensions. | 37 // Returns the union of all capabilities supported by registered extensions. |
38 std::string GetCapabilities() const; | 38 std::string GetCapabilities() const; |
39 | 39 |
40 // Handles completion of authentication and capabilities negotiation, creating | 40 // Handles completion of authentication and capabilities negotiation, creating |
41 // the set of HostExtensionSessions to match the client's capabilities. | 41 // the set of HostExtensionSessions to match the client's capabilities. |
42 void OnNegotiatedCapabilities(protocol::ClientStub* client_stub, | 42 void OnNegotiatedCapabilities(protocol::ClientStub* client_stub, |
43 const std::string& capabilities); | 43 const std::string& capabilities); |
44 | 44 |
45 // Passes |message| to each HostExtensionSession in turn until the message | 45 // Passes |message| to each HostExtensionSession in turn until the message |
46 // is handled, or none remain. Returns true if the message was handled. | 46 // is handled, or none remain. Returns true if the message was handled. |
47 // It is not valid for more than one extension to handle the same message. | 47 // It is not valid for more than one extension to handle the same message. |
48 bool OnExtensionMessage(const protocol::ExtensionMessage& message); | 48 bool OnExtensionMessage(const protocol::ExtensionMessage& message); |
49 | 49 |
50 private: | 50 private: |
51 typedef ScopedVector<HostExtensionSession> HostExtensionSessions; | 51 using HostExtensionSessions = |
| 52 std::vector<std::unique_ptr<HostExtensionSession>>; |
52 | 53 |
53 // Passed to HostExtensionSessions to allow them to send messages, | 54 // Passed to HostExtensionSessions to allow them to send messages, |
54 // disconnect the session, etc. | 55 // disconnect the session, etc. |
55 ClientSessionDetails* client_session_details_; | 56 ClientSessionDetails* client_session_details_; |
56 protocol::ClientStub* client_stub_; | 57 protocol::ClientStub* client_stub_; |
57 | 58 |
58 // The HostExtensions to instantiate for the session, if it reaches the | 59 // The HostExtensions to instantiate for the session, if it reaches the |
59 // authenticated state. | 60 // authenticated state. |
60 HostExtensions extensions_; | 61 HostExtensions extensions_; |
61 | 62 |
62 // The instantiated HostExtensionSessions, used to handle extension messages. | 63 // The instantiated HostExtensionSessions, used to handle extension messages. |
63 HostExtensionSessions extension_sessions_; | 64 HostExtensionSessions extension_sessions_; |
64 | 65 |
65 DISALLOW_COPY_AND_ASSIGN(HostExtensionSessionManager); | 66 DISALLOW_COPY_AND_ASSIGN(HostExtensionSessionManager); |
66 }; | 67 }; |
67 | 68 |
68 } // namespace remoting | 69 } // namespace remoting |
69 | 70 |
70 #endif // REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_ | 71 #endif // REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_ |
OLD | NEW |