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