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

Side by Side Diff: chrome/browser/extensions/api/dial/dial_device_data.cc

Issue 2756483007: [Device Discovery] Move files from browser/extensions/api/dial to browser/media/router/discovery/di… (Closed)
Patch Set: resolve code review comments from Devlin Created 3 years, 9 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 (c) 2012 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/extensions/api/dial/dial_device_data.h"
6
7 #include "chrome/common/extensions/api/dial.h"
8
9 namespace extensions {
10 namespace api {
11 namespace dial {
12
13 DialDeviceData::DialDeviceData() : max_age_(-1), config_id_(-1) { }
14
15 DialDeviceData::DialDeviceData(const std::string& device_id,
16 const GURL& device_description_url,
17 const base::Time& response_time)
18 : device_id_(device_id), device_description_url_(device_description_url),
19 response_time_(response_time), max_age_(-1), config_id_(-1) {
20 }
21
22 DialDeviceData::DialDeviceData(const DialDeviceData& other) = default;
23
24 DialDeviceData::~DialDeviceData() { }
25
26 const GURL& DialDeviceData::device_description_url() const {
27 return device_description_url_;
28 }
29
30 void DialDeviceData::set_device_description_url(const GURL& url) {
31 device_description_url_ = url;
32 }
33
34 // static
35 bool DialDeviceData::IsDeviceDescriptionUrl(const GURL& url) {
36 return url.is_valid() && !url.is_empty() && url.SchemeIsHTTPOrHTTPS();
37 }
38
39 bool DialDeviceData::UpdateFrom(const DialDeviceData& new_data) {
40 DCHECK(new_data.device_id() == device_id_);
41 DCHECK(new_data.label().empty());
42 std::string label_tmp(label_);
43 bool updated_api_visible_field =
44 (new_data.device_description_url() != device_description_url_) ||
45 (new_data.config_id() != config_id_);
46 *this = new_data;
47 label_ = label_tmp;
48 return updated_api_visible_field;
49 }
50
51 void DialDeviceData::FillDialDevice(api::dial::DialDevice* device) const {
52 DCHECK(!device_id_.empty());
53 DCHECK(IsDeviceDescriptionUrl(device_description_url_));
54 device->device_label = label_;
55 device->device_description_url = device_description_url_.spec();
56 if (has_config_id())
57 device->config_id.reset(new int(config_id_));
58 }
59
60 DialDeviceDescriptionData::DialDeviceDescriptionData(
61 const std::string& device_description,
62 const GURL& app_url)
63 : device_description(device_description), app_url(app_url) {}
64
65 } // namespace dial
66 } // namespace api
67 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/dial/dial_device_data.h ('k') | chrome/browser/extensions/api/dial/dial_device_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698