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

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

Issue 1553333002: Move cloud print specific files out of local_discovery (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@moveprn
Patch Set: Created 4 years, 11 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/local_discovery/device_description.h"
6
7 #include <vector>
8
9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h"
11 #include "chrome/browser/local_discovery/privet_constants.h"
12 #include "chrome/common/local_discovery/service_discovery_client.h"
13
14 namespace local_discovery {
15
16 namespace {
17
18 std::string GetValueByName(const std::vector<std::string>& metadata,
19 const std::string& name) {
20 std::string prefix(name + "=");
21 for (const std::string& record : metadata) {
22 if (base::StartsWith(record, prefix,
23 base::CompareCase::INSENSITIVE_ASCII)) {
24 return record.substr(prefix.size());
25 }
26 }
27 return std::string();
28 }
29
30 } // namespace
31
32 DeviceDescription::DeviceDescription() : version(0) {
33 }
34
35 DeviceDescription::DeviceDescription(
36 const ServiceDescription& service_description) {
37 address = service_description.address;
38
39 const std::vector<std::string>& metadata = service_description.metadata;
40 if (!base::StringToInt(GetValueByName(metadata, kPrivetTxtKeyVersion),
41 &version)) {
42 version = 0;
43 }
44 name = GetValueByName(metadata, kPrivetTxtKeyName);
45 description = GetValueByName(metadata, kPrivetTxtKeyDescription);
46 if (version >= 3) {
47 type = GetValueByName(metadata, kPrivetTxtKeyDevicesClass);
48 id = GetValueByName(metadata, kPrivetTxtKeyGcdID);
49 } else {
50 type = GetValueByName(metadata, kPrivetTxtKeyType);
51 id = GetValueByName(metadata, kPrivetTxtKeyID);
52 }
53 }
54
55 DeviceDescription::~DeviceDescription() {
56 }
57
58 } // namespace local_discovery
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/device_description.h ('k') | chrome/browser/local_discovery/gcd_api_flow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698