| 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_DEVICE_DATA_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_DEVICE_DATA_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_DEVICE_DATA_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_DEVICE_DATA_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 namespace extensions { | 15 namespace media_router { |
| 16 namespace api { | |
| 17 namespace dial { | |
| 18 | |
| 19 struct DialDevice; | |
| 20 | 16 |
| 21 // Dial device information that is used within the DialService and Registry on | 17 // Dial device information that is used within the DialService and Registry on |
| 22 // the IO thread. It is updated as new information arrives and a list of | 18 // the IO thread. It is updated as new information arrives and a list of |
| 23 // DialDeviceData is copied and sent to event listeners on the UI thread. | 19 // DialDeviceData is copied and sent to event listeners on the UI thread. |
| 24 class DialDeviceData { | 20 class DialDeviceData { |
| 25 public: | 21 public: |
| 26 DialDeviceData(); | 22 DialDeviceData(); |
| 27 DialDeviceData(const std::string& device_id, | 23 DialDeviceData(const std::string& device_id, |
| 28 const GURL& device_description_url, | 24 const GURL& device_description_url, |
| 29 const base::Time& response_time); | 25 const base::Time& response_time); |
| 30 DialDeviceData(const DialDeviceData& other); | 26 DialDeviceData(const DialDeviceData& other); |
| 31 ~DialDeviceData(); | 27 ~DialDeviceData(); |
| 32 | 28 |
| 33 bool operator==(const DialDeviceData& other_data) const { | 29 bool operator==(const DialDeviceData& other_data) const { |
| 34 return device_id_ == other_data.device_id_; | 30 return device_id_ == other_data.device_id_; |
| 35 } | 31 } |
| 36 | 32 |
| 37 const std::string& device_id() const { return device_id_; } | 33 const std::string& device_id() const { return device_id_; } |
| 38 void set_device_id(const std::string& id) { | 34 void set_device_id(const std::string& id) { device_id_ = id; } |
| 39 device_id_ = id; | |
| 40 } | |
| 41 | 35 |
| 42 const std::string& label() const { return label_; } | 36 const std::string& label() const { return label_; } |
| 43 void set_label(const std::string& label) { | 37 void set_label(const std::string& label) { label_ = label; } |
| 44 label_ = label; | |
| 45 } | |
| 46 | 38 |
| 47 const GURL& device_description_url() const; | 39 const GURL& device_description_url() const; |
| 48 void set_device_description_url(const GURL& url); | 40 void set_device_description_url(const GURL& url); |
| 49 | 41 |
| 50 const base::Time& response_time() const { return response_time_; } | 42 const base::Time& response_time() const { return response_time_; } |
| 51 void set_response_time(const base::Time& response_time) { | 43 void set_response_time(const base::Time& response_time) { |
| 52 response_time_ = response_time; | 44 response_time_ = response_time; |
| 53 } | 45 } |
| 54 | 46 |
| 55 int max_age() const { return max_age_; } | 47 int max_age() const { return max_age_; } |
| 56 void set_max_age(int max_age) { max_age_ = max_age; } | 48 void set_max_age(int max_age) { max_age_ = max_age; } |
| 57 bool has_max_age() const { return max_age_ >= 0; } | 49 bool has_max_age() const { return max_age_ >= 0; } |
| 58 | 50 |
| 59 int config_id() const { return config_id_; } | 51 int config_id() const { return config_id_; } |
| 60 void set_config_id(int config_id) { config_id_ = config_id; } | 52 void set_config_id(int config_id) { config_id_ = config_id; } |
| 61 bool has_config_id() const { return config_id_ >= 0; } | 53 bool has_config_id() const { return config_id_ >= 0; } |
| 62 | 54 |
| 63 // Fills the |device| API struct from this instance. | |
| 64 void FillDialDevice(api::dial::DialDevice* device) const; | |
| 65 | |
| 66 // Updates this DeviceData based on information from a new response in | 55 // Updates this DeviceData based on information from a new response in |
| 67 // |new_data|. Returns |true| if a field was updated that is visible through | 56 // |new_data|. Returns |true| if a field was updated that is visible through |
| 68 // the DIAL API. | 57 // the DIAL API. |
| 69 bool UpdateFrom(const DialDeviceData& new_data); | 58 bool UpdateFrom(const DialDeviceData& new_data); |
| 70 | 59 |
| 71 // Validates that the URL is valid for the device description. | 60 // Validates that the URL is valid for the device description. |
| 72 static bool IsDeviceDescriptionUrl(const GURL& url); | 61 static bool IsDeviceDescriptionUrl(const GURL& url); |
| 73 | 62 |
| 74 private: | 63 private: |
| 75 // Hardware identifier from the DIAL response. Not exposed to API clients. | 64 // Hardware identifier from the DIAL response. Not exposed to API clients. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 95 struct DialDeviceDescriptionData { | 84 struct DialDeviceDescriptionData { |
| 96 public: | 85 public: |
| 97 DialDeviceDescriptionData() = default; | 86 DialDeviceDescriptionData() = default; |
| 98 DialDeviceDescriptionData(const std::string& device_description, | 87 DialDeviceDescriptionData(const std::string& device_description, |
| 99 const GURL& app_url); | 88 const GURL& app_url); |
| 100 | 89 |
| 101 std::string device_description; | 90 std::string device_description; |
| 102 GURL app_url; | 91 GURL app_url; |
| 103 }; | 92 }; |
| 104 | 93 |
| 105 } // namespace dial | 94 } // namespace media_router |
| 106 } // namespace api | |
| 107 } // namespace extensions | |
| 108 | 95 |
| 109 #endif // CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_DEVICE_DATA_H_ | 96 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_DEVICE_DATA_H_ |
| OLD | NEW |