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

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

Issue 2858813002: [Chromoting] Use ProcessStatsSender in host process
Patch Set: Created 3 years, 7 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_number_conversions.h"
10 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
12 13
13 namespace remoting { 14 namespace remoting {
14 15
15 namespace { 16 namespace {
16 17
17 static constexpr char kSeparator = ','; 18 static constexpr char kSeparator = ',';
18 static constexpr char kKeyValueSeparator = ':'; 19 static constexpr char kKeyValueSeparator = ':';
19 20
(...skipping 27 matching lines...) Expand all
47 48
48 base::Optional<std::string> HostSessionOptions::Get( 49 base::Optional<std::string> HostSessionOptions::Get(
49 const std::string& key) const { 50 const std::string& key) const {
50 auto it = options_.find(key); 51 auto it = options_.find(key);
51 if (it == options_.end()) { 52 if (it == options_.end()) {
52 return base::nullopt; 53 return base::nullopt;
53 } 54 }
54 return it->second; 55 return it->second;
55 } 56 }
56 57
58 base::Optional<bool> HostSessionOptions::GetBool(const std::string& key) const {
59 base::Optional<std::string> value = Get(key);
60 if (!value) {
61 return base::nullopt;
62 }
63 return base::ToLowerASCII(*value) == "true" ||
64 (*value) == "1" ||
65 (*value).empty();
66 }
67
68 base::Optional<int> HostSessionOptions::GetInt(const std::string& key) const {
69 base::Optional<std::string> value = Get(key);
70 int result;
71 if (!value || !base::StringToInt(*value, &result)) {
72 return base::nullopt;
73 }
74 return result;
75 }
76
57 std::string HostSessionOptions::Export() const { 77 std::string HostSessionOptions::Export() const {
58 std::string result; 78 std::string result;
59 for (const auto& pair : options_) { 79 for (const auto& pair : options_) {
60 if (!result.empty()) { 80 if (!result.empty()) {
61 result += kSeparator; 81 result += kSeparator;
62 } 82 }
63 if (!pair.first.empty()) { 83 if (!pair.first.empty()) {
64 result += pair.first; 84 result += pair.first;
65 result.push_back(kKeyValueSeparator); 85 result.push_back(kKeyValueSeparator);
66 result += pair.second; 86 result += pair.second;
(...skipping 10 matching lines...) Expand all
77 kSeparator, 97 kSeparator,
78 &result); 98 &result);
79 for (const auto& pair : result) { 99 for (const auto& pair : result) {
80 if (KeyIsValid(pair.first) && ValueIsValid(pair.second)) { 100 if (KeyIsValid(pair.first) && ValueIsValid(pair.second)) {
81 Append(pair.first, pair.second); 101 Append(pair.first, pair.second);
82 } 102 }
83 } 103 }
84 } 104 }
85 105
86 } // namespace remoting 106 } // 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