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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_DEVICE_DATA_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_DEVICE_DATA_H_
11 #include "base/time/time.h"
12 #include "base/values.h"
15 namespace extensions
{
23 // Dial device information that is used within the DialService and Registry on
24 // the IO thread. It is updated as new information arrives and a list of
25 // DialDeviceData is copied and sent to event listeners on the UI thread.
26 class DialDeviceData
{
29 DialDeviceData(const std::string
& device_id
,
30 const GURL
& device_description_url
,
31 const base::Time
& response_time
);
34 bool operator==(const DialDeviceData
& other_data
) const {
35 return device_id_
== other_data
.device_id_
;
38 const std::string
& device_id() const { return device_id_
; }
39 void set_device_id(const std::string
& id
) {
43 const std::string
& label() const { return label_
; }
44 void set_label(const std::string
& label
) {
48 const GURL
& device_description_url() const;
49 void set_device_description_url(const GURL
& url
);
51 const base::Time
& response_time() const { return response_time_
; }
52 void set_response_time(const base::Time
& response_time
) {
53 response_time_
= response_time
;
56 int max_age() const { return max_age_
; }
57 void set_max_age(int max_age
) { max_age_
= max_age
; }
58 bool has_max_age() const { return max_age_
>= 0; }
60 int config_id() const { return config_id_
; }
61 void set_config_id(int config_id
) { config_id_
= config_id
; }
62 bool has_config_id() const { return config_id_
>= 0; }
64 // Fills the |device| API struct from this instance.
65 void FillDialDevice(api::dial::DialDevice
* device
) const;
67 // Updates this DeviceData based on information from a new response in
68 // |new_data|. Returns |true| if a field was updated that is visible through
70 bool UpdateFrom(const DialDeviceData
& new_data
);
72 // Validates that the URL is valid for the device description.
73 static bool IsDeviceDescriptionUrl(const GURL
& url
);
76 // Hardware identifier from the DIAL response. Not exposed to API clients.
77 std::string device_id_
;
79 // Identifies this device to clients of the API as a proxy for the hardware
80 // identifier. Automatically generated by the DIAL registry.
83 // The device description URL.
84 GURL device_description_url_
;
86 // The time that the most recent response was received.
87 base::Time response_time_
;
89 // Optional (-1 means unset).
92 // Optional (-1 means unset).
96 } // namespace extensions
98 #endif // CHROME_BROWSER_EXTENSIONS_API_DIAL_DIAL_DEVICE_DATA_H_