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

Side by Side Diff: trunk/src/chrome/browser/local_discovery/device_description.cc

Issue 474483002: Revert 289312 "Move StringToUpperASCII and LowerCaseEqualsASCII ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/chrome/browser/io_thread.cc ('k') | trunk/src/chrome/browser/memory_details.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/local_discovery/device_description.h" 5 #include "chrome/browser/local_discovery/device_description.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "chrome/browser/local_discovery/privet_constants.h" 11 #include "chrome/browser/local_discovery/privet_constants.h"
12 #include "chrome/common/local_discovery/service_discovery_client.h" 12 #include "chrome/common/local_discovery/service_discovery_client.h"
13 13
14 namespace local_discovery { 14 namespace local_discovery {
15 15
16 namespace { 16 namespace {
17 17
18 DeviceDescription::ConnectionState 18 DeviceDescription::ConnectionState
19 ConnectionStateFromString(const std::string& str) { 19 ConnectionStateFromString(const std::string& str) {
20 if (base::LowerCaseEqualsASCII(str, kPrivetConnectionStatusOnline)) { 20 if (LowerCaseEqualsASCII(str, kPrivetConnectionStatusOnline)) {
21 return DeviceDescription::ONLINE; 21 return DeviceDescription::ONLINE;
22 } else if (base::LowerCaseEqualsASCII(str, kPrivetConnectionStatusOffline)) { 22 } else if (LowerCaseEqualsASCII(str, kPrivetConnectionStatusOffline)) {
23 return DeviceDescription::OFFLINE; 23 return DeviceDescription::OFFLINE;
24 } else if (base::LowerCaseEqualsASCII(str, 24 } else if (LowerCaseEqualsASCII(str, kPrivetConnectionStatusConnecting)) {
25 kPrivetConnectionStatusConnecting)) {
26 return DeviceDescription::CONNECTING; 25 return DeviceDescription::CONNECTING;
27 } else if (base::LowerCaseEqualsASCII(str, 26 } else if (LowerCaseEqualsASCII(str, kPrivetConnectionStatusNotConfigured)) {
28 kPrivetConnectionStatusNotConfigured)) {
29 return DeviceDescription::NOT_CONFIGURED; 27 return DeviceDescription::NOT_CONFIGURED;
30 } 28 }
31 29
32 return DeviceDescription::UNKNOWN; 30 return DeviceDescription::UNKNOWN;
33 } 31 }
34 32
35 } // namespace 33 } // namespace
36 34
37 DeviceDescription::DeviceDescription() 35 DeviceDescription::DeviceDescription()
38 : version(0), 36 : version(0),
(...skipping 13 matching lines...) Expand all
52 service_description.metadata.begin(); 50 service_description.metadata.begin();
53 i != service_description.metadata.end(); 51 i != service_description.metadata.end();
54 i++) { 52 i++) {
55 size_t equals_pos = i->find_first_of('='); 53 size_t equals_pos = i->find_first_of('=');
56 if (equals_pos == std::string::npos) 54 if (equals_pos == std::string::npos)
57 continue; // We do not parse non key-value TXT records 55 continue; // We do not parse non key-value TXT records
58 56
59 std::string key = i->substr(0, equals_pos); 57 std::string key = i->substr(0, equals_pos);
60 std::string value = i->substr(equals_pos + 1); 58 std::string value = i->substr(equals_pos + 1);
61 59
62 if (base::LowerCaseEqualsASCII(key, kPrivetTxtKeyVersion)) { 60 if (LowerCaseEqualsASCII(key, kPrivetTxtKeyVersion)) {
63 if (!base::StringToInt(value, &version)) 61 if (!base::StringToInt(value, &version))
64 continue; // Unknown version. 62 continue; // Unknown version.
65 } else if (base::LowerCaseEqualsASCII(key, kPrivetTxtKeyName)) { 63 } else if (LowerCaseEqualsASCII(key, kPrivetTxtKeyName)) {
66 name = value; 64 name = value;
67 } else if (base::LowerCaseEqualsASCII(key, kPrivetTxtKeyDescription)) { 65 } else if (LowerCaseEqualsASCII(key, kPrivetTxtKeyDescription)) {
68 description = value; 66 description = value;
69 } else if (base::LowerCaseEqualsASCII(key, kPrivetTxtKeyURL)) { 67 } else if (LowerCaseEqualsASCII(key, kPrivetTxtKeyURL)) {
70 url = value; 68 url = value;
71 } else if (base::LowerCaseEqualsASCII(key, kPrivetTxtKeyType)) { 69 } else if (LowerCaseEqualsASCII(key, kPrivetTxtKeyType)) {
72 type = value; 70 type = value;
73 } else if (base::LowerCaseEqualsASCII(key, kPrivetTxtKeyID)) { 71 } else if (LowerCaseEqualsASCII(key, kPrivetTxtKeyID)) {
74 id = value; 72 id = value;
75 } else if (base::LowerCaseEqualsASCII(key, kPrivetTxtKeyConnectionState)) { 73 } else if (LowerCaseEqualsASCII(key, kPrivetTxtKeyConnectionState)) {
76 connection_state = ConnectionStateFromString(value); 74 connection_state = ConnectionStateFromString(value);
77 } 75 }
78 } 76 }
79 } 77 }
80 78
81 79
82 } // namespace local_discovery 80 } // namespace local_discovery
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/io_thread.cc ('k') | trunk/src/chrome/browser/memory_details.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698