zijiehe | 21d8d391 | 2016-11-18 20:14:21 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
zijiehe | f38c972 | 2017-02-08 02:05:29 | [diff] [blame] | 5 | #ifndef REMOTING_HOST_HOST_SESSION_OPTIONS_H_ |
| 6 | #define REMOTING_HOST_HOST_SESSION_OPTIONS_H_ |
zijiehe | 21d8d391 | 2016-11-18 20:14:21 | [diff] [blame] | 7 | |
| 8 | #include <map> |
| 9 | #include <string> |
| 10 | |
| 11 | #include "base/macros.h" |
| 12 | #include "base/optional.h" |
| 13 | |
| 14 | namespace remoting { |
zijiehe | 21d8d391 | 2016-11-18 20:14:21 | [diff] [blame] | 15 | |
| 16 | // Session based host options sending from client. This class parses and stores |
| 17 | // session configuration from client side to control the behavior of other host |
| 18 | // components. |
| 19 | class HostSessionOptions final { |
| 20 | public: |
| 21 | HostSessionOptions(); |
| 22 | ~HostSessionOptions(); |
| 23 | |
zijiehe | f38c972 | 2017-02-08 02:05:29 | [diff] [blame] | 24 | HostSessionOptions(const std::string& parameter); |
| 25 | |
zijiehe | 21d8d391 | 2016-11-18 20:14:21 | [diff] [blame] | 26 | // Appends one key-value pair into current instance. |
| 27 | void Append(const std::string& key, const std::string& value); |
| 28 | |
| 29 | // Retrieves the value of |key|. Returns a true Optional if |key| has been |
| 30 | // found, value of the Optional wil be set to corresponding value. |
| 31 | base::Optional<std::string> Get(const std::string& key) const; |
| 32 | |
| 33 | // Returns a string to represent current instance. Consumers can rebuild an |
| 34 | // exactly same instance with Import() function. |
| 35 | std::string Export() const; |
| 36 | |
| 37 | // Overwrite current instance with |parameter|, which is a string returned by |
| 38 | // Export() function. So a parent process can send HostSessionOptions to a |
| 39 | // child process. |
| 40 | void Import(const std::string& parameter); |
| 41 | |
| 42 | private: |
| 43 | std::map<std::string, std::string> options_; |
| 44 | |
| 45 | HostSessionOptions(HostSessionOptions&&) = delete; |
| 46 | HostSessionOptions& operator=(HostSessionOptions&&) = delete; |
| 47 | DISALLOW_COPY_AND_ASSIGN(HostSessionOptions); |
| 48 | }; |
| 49 | |
zijiehe | 21d8d391 | 2016-11-18 20:14:21 | [diff] [blame] | 50 | } // namespace remoting |
| 51 | |
zijiehe | f38c972 | 2017-02-08 02:05:29 | [diff] [blame] | 52 | #endif // REMOTING_HOST_HOST_SESSION_OPTIONS_H_ |