Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / remoting / host / host_extension_session_manager.h
blob44c28ea54d22221328866348d239180e7c4e396b
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
3 // found in the LICENSE file.
5 #ifndef REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_
6 #define REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_
8 #include <string>
9 #include <vector>
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h"
14 namespace webrtc {
15 class DesktopCapturer;
18 namespace remoting {
20 class ClientSessionControl;
21 class HostExtension;
22 class HostExtensionSession;
23 class VideoEncoder;
25 namespace protocol {
26 class ClientStub;
27 class ExtensionMessage;
30 // Helper class used to create and manage a set of HostExtensionSession
31 // instances depending upon the set of registered HostExtensions, and the
32 // set of capabilities negotiated between client and host.
33 class HostExtensionSessionManager {
34 public:
35 typedef std::vector<HostExtension*> HostExtensions;
37 // Creates an extension manager for the specified |extensions|.
38 HostExtensionSessionManager(const HostExtensions& extensions,
39 ClientSessionControl* client_session_control);
40 virtual ~HostExtensionSessionManager();
42 // Returns the union of all capabilities supported by registered extensions.
43 std::string GetCapabilities() const;
45 // Calls the corresponding hook functions for each extension, to allow them
46 // to wrap or replace video pipeline components. Only extensions which return
47 // true from ModifiesVideoPipeline() will be called.
48 // The order in which extensions are called is undefined.
49 void OnCreateVideoCapturer(scoped_ptr<webrtc::DesktopCapturer>* capturer);
50 void OnCreateVideoEncoder(scoped_ptr<VideoEncoder>* encoder);
52 // Handles completion of authentication and capabilities negotiation, creating
53 // the set of HostExtensionSessions to match the client's capabilities.
54 void OnNegotiatedCapabilities(protocol::ClientStub* client_stub,
55 const std::string& capabilities);
57 // Passes |message| to each HostExtensionSession in turn until the message
58 // is handled, or none remain. Returns true if the message was handled.
59 // It is not valid for more than one extension to handle the same message.
60 bool OnExtensionMessage(const protocol::ExtensionMessage& message);
62 private:
63 typedef ScopedVector<HostExtensionSession> HostExtensionSessions;
65 // Passed to HostExtensionSessions to allow them to send messages,
66 // disconnect the session, etc.
67 ClientSessionControl* client_session_control_;
68 protocol::ClientStub* client_stub_;
70 // The HostExtensions to instantiate for the session, if it reaches the
71 // authenticated state.
72 HostExtensions extensions_;
74 // The instantiated HostExtensionSessions, used to handle extension messages.
75 HostExtensionSessions extension_sessions_;
77 DISALLOW_COPY_AND_ASSIGN(HostExtensionSessionManager);
80 } // namespace remoting
82 #endif // REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_