Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Side by Side Diff: remoting/host/host_session_options.cc

Issue 2615113005: [Chromoting] Use HostExperimentSessionPlugin in host (Closed)
Patch Set: Resolve review comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/host/host_session_options.h ('k') | remoting/host/host_session_options_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "remoting/host/host_session_options.h" 5 #include "remoting/host/host_session_options.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 12
13 namespace remoting { 13 namespace remoting {
14 namespace protocol {
15 14
16 namespace { 15 namespace {
17 16
18 static constexpr char kSeparator = ','; 17 static constexpr char kSeparator = ',';
19 static constexpr char kKeyValueSeparator = ':'; 18 static constexpr char kKeyValueSeparator = ':';
20 19
21 // Whether |value| is good to be added to HostSessionOptions as a value. 20 // Whether |value| is good to be added to HostSessionOptions as a value.
22 bool ValueIsValid(const std::string& value) { 21 bool ValueIsValid(const std::string& value) {
23 return value.find(kSeparator) == std::string::npos && 22 return value.find(kSeparator) == std::string::npos &&
24 value.find(kKeyValueSeparator) == std::string::npos && 23 value.find(kKeyValueSeparator) == std::string::npos &&
25 base::IsStringASCII(value); 24 base::IsStringASCII(value);
26 } 25 }
27 26
28 // Whether |key| is good to be added to HostSessionOptions as a key. 27 // Whether |key| is good to be added to HostSessionOptions as a key.
29 bool KeyIsValid(const std::string& key) { 28 bool KeyIsValid(const std::string& key) {
30 return !key.empty() && ValueIsValid(key); 29 return !key.empty() && ValueIsValid(key);
31 } 30 }
32 31
33 } // namespace 32 } // namespace
34 33
35 HostSessionOptions::HostSessionOptions() = default; 34 HostSessionOptions::HostSessionOptions() = default;
36 HostSessionOptions::~HostSessionOptions() = default; 35 HostSessionOptions::~HostSessionOptions() = default;
37 36
37 HostSessionOptions::HostSessionOptions(const std::string& parameter) {
38 Import(parameter);
39 }
40
38 void HostSessionOptions::Append(const std::string& key, 41 void HostSessionOptions::Append(const std::string& key,
39 const std::string& value) { 42 const std::string& value) {
40 DCHECK(KeyIsValid(key)); 43 DCHECK(KeyIsValid(key));
41 DCHECK(ValueIsValid(value)); 44 DCHECK(ValueIsValid(value));
42 options_[key] = value; 45 options_[key] = value;
43 } 46 }
44 47
45 base::Optional<std::string> HostSessionOptions::Get( 48 base::Optional<std::string> HostSessionOptions::Get(
46 const std::string& key) const { 49 const std::string& key) const {
47 auto it = options_.find(key); 50 auto it = options_.find(key);
(...skipping 25 matching lines...) Expand all
73 kKeyValueSeparator, 76 kKeyValueSeparator,
74 kSeparator, 77 kSeparator,
75 &result); 78 &result);
76 for (const auto& pair : result) { 79 for (const auto& pair : result) {
77 if (KeyIsValid(pair.first) && ValueIsValid(pair.second)) { 80 if (KeyIsValid(pair.first) && ValueIsValid(pair.second)) {
78 Append(pair.first, pair.second); 81 Append(pair.first, pair.second);
79 } 82 }
80 } 83 }
81 } 84 }
82 85
83 } // namespace protocol
84 } // namespace remoting 86 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_session_options.h ('k') | remoting/host/host_session_options_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698