Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/extensions/api/dial/dial_device_data.h" | 5 #include "chrome/browser/media/router/discovery/dial/dial_device_data.h" |
| 6 | 6 |
| 7 #include "chrome/common/extensions/api/dial.h" | 7 #include "chrome/common/extensions/api/dial.h" |
|
imcheng
2017/03/20 23:48:10
Remove?
zhaobin
2017/03/21 21:20:50
Done.
| |
| 8 | 8 |
| 9 namespace extensions { | 9 namespace media_router { |
| 10 namespace api { | |
| 11 namespace dial { | |
| 12 | 10 |
| 13 DialDeviceData::DialDeviceData() : max_age_(-1), config_id_(-1) { } | 11 DialDeviceData::DialDeviceData() : max_age_(-1), config_id_(-1) {} |
| 14 | 12 |
| 15 DialDeviceData::DialDeviceData(const std::string& device_id, | 13 DialDeviceData::DialDeviceData(const std::string& device_id, |
| 16 const GURL& device_description_url, | 14 const GURL& device_description_url, |
| 17 const base::Time& response_time) | 15 const base::Time& response_time) |
| 18 : device_id_(device_id), device_description_url_(device_description_url), | 16 : device_id_(device_id), |
| 19 response_time_(response_time), max_age_(-1), config_id_(-1) { | 17 device_description_url_(device_description_url), |
| 20 } | 18 response_time_(response_time), |
| 19 max_age_(-1), | |
| 20 config_id_(-1) {} | |
| 21 | 21 |
| 22 DialDeviceData::DialDeviceData(const DialDeviceData& other) = default; | 22 DialDeviceData::DialDeviceData(const DialDeviceData& other) = default; |
| 23 | 23 |
| 24 DialDeviceData::~DialDeviceData() { } | 24 DialDeviceData::~DialDeviceData() {} |
| 25 | 25 |
| 26 const GURL& DialDeviceData::device_description_url() const { | 26 const GURL& DialDeviceData::device_description_url() const { |
| 27 return device_description_url_; | 27 return device_description_url_; |
| 28 } | 28 } |
| 29 | 29 |
| 30 void DialDeviceData::set_device_description_url(const GURL& url) { | 30 void DialDeviceData::set_device_description_url(const GURL& url) { |
| 31 device_description_url_ = url; | 31 device_description_url_ = url; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // static | 34 // static |
| 35 bool DialDeviceData::IsDeviceDescriptionUrl(const GURL& url) { | 35 bool DialDeviceData::IsDeviceDescriptionUrl(const GURL& url) { |
| 36 return url.is_valid() && !url.is_empty() && url.SchemeIsHTTPOrHTTPS(); | 36 return url.is_valid() && !url.is_empty() && url.SchemeIsHTTPOrHTTPS(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 bool DialDeviceData::UpdateFrom(const DialDeviceData& new_data) { | 39 bool DialDeviceData::UpdateFrom(const DialDeviceData& new_data) { |
| 40 DCHECK(new_data.device_id() == device_id_); | 40 DCHECK(new_data.device_id() == device_id_); |
| 41 DCHECK(new_data.label().empty()); | 41 DCHECK(new_data.label().empty()); |
| 42 std::string label_tmp(label_); | 42 std::string label_tmp(label_); |
| 43 bool updated_api_visible_field = | 43 bool updated_api_visible_field = |
| 44 (new_data.device_description_url() != device_description_url_) || | 44 (new_data.device_description_url() != device_description_url_) || |
| 45 (new_data.config_id() != config_id_); | 45 (new_data.config_id() != config_id_); |
| 46 *this = new_data; | 46 *this = new_data; |
| 47 label_ = label_tmp; | 47 label_ = label_tmp; |
| 48 return updated_api_visible_field; | 48 return updated_api_visible_field; |
| 49 } | 49 } |
| 50 | 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( | 51 DialDeviceDescriptionData::DialDeviceDescriptionData( |
| 61 const std::string& device_description, | 52 const std::string& device_description, |
| 62 const GURL& app_url) | 53 const GURL& app_url) |
| 63 : device_description(device_description), app_url(app_url) {} | 54 : device_description(device_description), app_url(app_url) {} |
| 64 | 55 |
| 65 } // namespace dial | 56 } // namespace media_router |
| 66 } // namespace api | |
| 67 } // namespace extensions | |
| OLD | NEW |