OLD | NEW |
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 std::string GetValueByName(const std::vector<std::string>& metadata, | 18 std::string GetValueByName(const std::vector<std::string>& metadata, |
19 const std::string& name) { | 19 const std::string& name) { |
20 std::string prefix(name + "="); | 20 std::string prefix(name + "="); |
21 for (const std::string& record : metadata) { | 21 for (const std::string& record : metadata) { |
22 if (base::StartsWithASCII(record, prefix, false)) { | 22 if (base::StartsWith(record, prefix, |
| 23 base::CompareCase::INSENSITIVE_ASCII)) { |
23 return record.substr(prefix.size()); | 24 return record.substr(prefix.size()); |
24 } | 25 } |
25 } | 26 } |
26 return std::string(); | 27 return std::string(); |
27 } | 28 } |
28 | 29 |
29 } // namespace | 30 } // namespace |
30 | 31 |
31 DeviceDescription::DeviceDescription() : version(0) { | 32 DeviceDescription::DeviceDescription() : version(0) { |
32 } | 33 } |
(...skipping 15 matching lines...) Expand all Loading... |
48 } else { | 49 } else { |
49 type = GetValueByName(metadata, kPrivetTxtKeyType); | 50 type = GetValueByName(metadata, kPrivetTxtKeyType); |
50 id = GetValueByName(metadata, kPrivetTxtKeyID); | 51 id = GetValueByName(metadata, kPrivetTxtKeyID); |
51 } | 52 } |
52 } | 53 } |
53 | 54 |
54 DeviceDescription::~DeviceDescription() { | 55 DeviceDescription::~DeviceDescription() { |
55 } | 56 } |
56 | 57 |
57 } // namespace local_discovery | 58 } // namespace local_discovery |
OLD | NEW |