Commit 4541bd67 authored by sergeyu's avatar sergeyu Committed by Commit bot

Move name_value_map to remoting/base

Also updated base/chromoting_event.cc to use NameValueMap

Review-Url: https://codereview.chromium.org/2807803002
Cr-Commit-Position: refs/heads/master@{#463370}
parent 18f13966
......@@ -22,6 +22,7 @@ source_set("base") {
"constants.h",
"leaky_bucket.cc",
"leaky_bucket.h",
"name_value_map.h",
"rate_counter.cc",
"rate_counter.h",
"remoting_bot.cc",
......
......@@ -7,9 +7,23 @@
#include "base/strings/string_util.h"
#include "base/strings/stringize_macros.h"
#include "base/sys_info.h"
#include "remoting/base/name_value_map.h"
namespace remoting {
namespace {
const NameMapElement<ChromotingEvent::Os> kOsNames[] = {
{ChromotingEvent::Os::CHROMOTING_LINUX, "linux"},
{ChromotingEvent::Os::CHROMOTING_CHROMEOS, "chromeos"},
{ChromotingEvent::Os::CHROMOTING_MAC, "mac"},
{ChromotingEvent::Os::CHROMOTING_WINDOWS, "windows"},
{ChromotingEvent::Os::CHROMOTING_ANDROID, "android"},
{ChromotingEvent::Os::CHROMOTING_IOS, "ios"},
};
} // namespace
const char ChromotingEvent::kCaptureLatencyKey[] = "capture_latency";
const char ChromotingEvent::kConnectionErrorKey[] = "connection_error";
const char ChromotingEvent::kCpuKey[] = "cpu";
......@@ -126,23 +140,12 @@ bool ChromotingEvent::IsEndOfSession(SessionState state) {
// static
ChromotingEvent::Os ChromotingEvent::ParseOsFromString(const std::string& os) {
std::string lower_os = base::ToLowerASCII(os);
// TODO(yuweih): Refactor remoting/protocol/name_value_map.h and use it to
// map the value.
if (lower_os == "linux") {
return Os::CHROMOTING_LINUX;
} else if (lower_os == "chromeos") {
return Os::CHROMOTING_CHROMEOS;
} else if (lower_os == "mac") {
return Os::CHROMOTING_MAC;
} else if (lower_os == "windows") {
return Os::CHROMOTING_WINDOWS;
} else if (lower_os == "android") {
return Os::CHROMOTING_ANDROID;
} else if (lower_os == "ios") {
return Os::CHROMOTING_IOS;
ChromotingEvent::Os result;
if (!NameToValue(kOsNames, base::ToLowerASCII(os), &result)) {
return Os::OTHER;
}
return Os::OTHER;
return result;
}
} // namespace remoting
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Helper functions that allow to map enum values to strings.
#ifndef REMOTING_PROTOCOL_NAME_VALUE_MAP_H_
#define REMOTING_PROTOCOL_NAME_VALUE_MAP_H_
#ifndef REMOTING_BASE_NAME_VALUE_MAP_H_
#define REMOTING_BASE_NAME_VALUE_MAP_H_
#include <stddef.h>
#include "base/logging.h"
namespace remoting {
namespace protocol {
template <typename T>
struct NameMapElement {
......@@ -43,7 +42,6 @@ bool NameToValue(const NameMapElement<T> (&map)[N],
return false;
}
} // namespace protocol
} // namespace remoting
#endif // REMOTING_PROTOCOL_NAME_VALUE_MAP_H_
#endif // REMOTING_BASE_NAME_VALUE_MAP_H_
......@@ -4,9 +4,7 @@
#include "remoting/host/host_exit_codes.h"
#include "remoting/protocol/name_value_map.h"
using remoting::protocol::NameMapElement;
#include "remoting/base/name_value_map.h"
namespace remoting {
......
......@@ -25,11 +25,11 @@
#include "net/socket/client_socket_factory.h"
#include "net/url_request/url_request_context_getter.h"
#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/base/name_value_map.h"
#include "remoting/base/service_urls.h"
#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/host_exit_codes.h"
#include "remoting/host/policy_watcher.h"
#include "remoting/protocol/name_value_map.h"
#include "remoting/signaling/delegating_signal_strategy.h"
#if defined(OS_WIN)
......@@ -43,7 +43,7 @@ namespace remoting {
namespace {
const remoting::protocol::NameMapElement<It2MeHostState> kIt2MeHostStates[] = {
const NameMapElement<It2MeHostState> kIt2MeHostStates[] = {
{kDisconnected, "DISCONNECTED"},
{kStarting, "STARTING"},
{kRequestedAccessCode, "REQUESTED_ACCESS_CODE"},
......
......@@ -104,7 +104,6 @@ static_library("protocol") {
"monitored_video_stub.h",
"mouse_input_filter.cc",
"mouse_input_filter.h",
"name_value_map.h",
"negotiating_authenticator_base.cc",
"negotiating_authenticator_base.h",
"negotiating_client_authenticator.cc",
......
......@@ -11,8 +11,8 @@
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "remoting/base/constants.h"
#include "remoting/base/name_value_map.h"
#include "remoting/protocol/authenticator.h"
#include "remoting/protocol/name_value_map.h"
#include "third_party/libjingle_xmpp/xmllite/xmlelement.h"
using buzz::QName;
......
......@@ -5,7 +5,7 @@
#include "remoting/protocol/errors.h"
#include "base/logging.h"
#include "remoting/protocol/name_value_map.h"
#include "remoting/base/name_value_map.h"
namespace remoting {
namespace protocol {
......
......@@ -7,9 +7,9 @@
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "remoting/base/constants.h"
#include "remoting/base/name_value_map.h"
#include "remoting/base/remoting_bot.h"
#include "remoting/protocol/content_description.h"
#include "remoting/protocol/name_value_map.h"
#include "remoting/protocol/session_plugin.h"
#include "remoting/signaling/jid_util.h"
#include "third_party/libjingle_xmpp/xmllite/xmlelement.h"
......
......@@ -12,9 +12,9 @@
#include "base/logging.h"
#include "base/strings/string_split.h"
#include "remoting/base/constants.h"
#include "remoting/base/name_value_map.h"
#include "remoting/base/rsa_key_pair.h"
#include "remoting/protocol/channel_authenticator.h"
#include "remoting/protocol/name_value_map.h"
#include "third_party/libjingle_xmpp/xmllite/xmlelement.h"
namespace remoting {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment