| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CHROMECAST_BASE_DEVICE_CAPABILITIES_IMPL_H_ | 5 #ifndef CHROMECAST_BASE_DEVICE_CAPABILITIES_IMPL_H_ |
| 6 #define CHROMECAST_BASE_DEVICE_CAPABILITIES_IMPL_H_ | 6 #define CHROMECAST_BASE_DEVICE_CAPABILITIES_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| 11 #include "chromecast/base/device_capabilities.h" | 11 #include "chromecast/base/device_capabilities.h" |
| 12 | 12 |
| 13 namespace chromecast { | 13 namespace chromecast { |
| 14 | 14 |
| 15 class DeviceCapabilitiesImpl : public DeviceCapabilities { | 15 class DeviceCapabilitiesImpl : public DeviceCapabilities { |
| 16 public: | 16 public: |
| 17 ~DeviceCapabilitiesImpl() override; | 17 ~DeviceCapabilitiesImpl() override; |
| 18 | 18 |
| 19 // DeviceCapabilities implementation: | 19 // DeviceCapabilities implementation: |
| 20 void Register(const std::string& key, | 20 void Register(const std::string& key, Validator* validator) override; |
| 21 scoped_ptr<base::Value> init_value, | |
| 22 Validator* validator) override; | |
| 23 void Unregister(const std::string& key, const Validator* validator) override; | 21 void Unregister(const std::string& key, const Validator* validator) override; |
| 22 Validator* GetValidator(const std::string& key) const override; |
| 24 bool BluetoothSupported() const override; | 23 bool BluetoothSupported() const override; |
| 25 bool DisplaySupported() const override; | 24 bool DisplaySupported() const override; |
| 26 bool GetCapability(const std::string& path, | 25 bool GetCapability(const std::string& path, |
| 27 const base::Value** out_value) const override; | 26 const base::Value** out_value) const override; |
| 28 const std::string& GetCapabilitiesString() const override; | 27 const std::string& GetCapabilitiesString() const override; |
| 29 const base::DictionaryValue* GetCapabilities() const override; | 28 const base::DictionaryValue* GetCapabilities() const override; |
| 30 void SetCapability(const std::string& path, | 29 void SetCapability(const std::string& path, |
| 31 scoped_ptr<base::Value> proposed_value) override; | 30 scoped_ptr<base::Value> proposed_value) override; |
| 32 void MergeDictionary(const base::DictionaryValue& dict_value) override; | 31 void MergeDictionary(const base::DictionaryValue& dict_value) override; |
| 33 void AddCapabilitiesObserver(Observer* observer) override; | 32 void AddCapabilitiesObserver(Observer* observer) override; |
| 34 void RemoveCapabilitiesObserver(Observer* observer) override; | 33 void RemoveCapabilitiesObserver(Observer* observer) override; |
| 35 | 34 |
| 36 private: | 35 private: |
| 37 // For DeviceCapabilitiesImpl() | 36 // For DeviceCapabilitiesImpl() |
| 38 friend class DeviceCapabilities; | 37 friend class DeviceCapabilities; |
| 39 // For SetValidatedValueInternal() | 38 // For SetValidatedValueInternal() |
| 40 friend class DeviceCapabilities::Validator; | 39 friend class DeviceCapabilities::Validator; |
| 41 | 40 |
| 42 // Map from capability key to corresponding Validator. Gets updated | 41 // Map from capability key to corresponding Validator. Gets updated |
| 43 // in Register()/Unregister(). | 42 // in Register()/Unregister(). |
| 44 typedef base::hash_map<std::string, Validator*> ValidatorMap; | 43 typedef base::hash_map<std::string, Validator*> ValidatorMap; |
| 45 | 44 |
| 46 // Internal constructor used by static DeviceCapabilities::Create*() methods. | 45 // Internal constructor used by static DeviceCapabilities::Create*() methods. |
| 47 DeviceCapabilitiesImpl(); | 46 DeviceCapabilitiesImpl(); |
| 48 | 47 |
| 49 void SetValidatedValueInternal(const std::string& path, | 48 void SetValidatedValueInternal(const std::string& path, |
| 50 scoped_ptr<base::Value> new_value) override; | 49 scoped_ptr<base::Value> new_value) override; |
| 51 | |
| 52 void AddValidator(const std::string& key, Validator* validator); | |
| 53 void UpdateStrAndNotifyChanged(const std::string& path); | 50 void UpdateStrAndNotifyChanged(const std::string& path); |
| 54 | 51 |
| 55 scoped_ptr<base::DictionaryValue> capabilities_; | 52 scoped_ptr<base::DictionaryValue> capabilities_; |
| 56 scoped_ptr<const std::string> capabilities_str_; | 53 scoped_ptr<const std::string> capabilities_str_; |
| 57 | 54 |
| 58 ValidatorMap validator_map_; | 55 ValidatorMap validator_map_; |
| 59 base::ObserverList<Observer> observer_list_; | 56 base::ObserverList<Observer> observer_list_; |
| 60 base::ThreadChecker thread_checker_; | 57 base::ThreadChecker thread_checker_; |
| 61 | 58 |
| 62 DISALLOW_COPY_AND_ASSIGN(DeviceCapabilitiesImpl); | 59 DISALLOW_COPY_AND_ASSIGN(DeviceCapabilitiesImpl); |
| 63 }; | 60 }; |
| 64 | 61 |
| 65 } // namespace chromecast | 62 } // namespace chromecast |
| 66 | 63 |
| 67 #endif // CHROMECAST_BASE_DEVICE_CAPABILITIES_IMPL_H_ | 64 #endif // CHROMECAST_BASE_DEVICE_CAPABILITIES_IMPL_H_ |
| OLD | NEW |