Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Guido Urdaneta | 9f831c2 | 2023-06-22 13:44:34 | [diff] [blame] | 5 | #ifndef COMPONENTS_MEDIA_DEVICE_SALT_MEDIA_DEVICE_ID_SALT_H_ |
| 6 | #define COMPONENTS_MEDIA_DEVICE_SALT_MEDIA_DEVICE_ID_SALT_H_ |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | |
joi@chromium.org | f9583f8 | 2014-02-13 15:34:21 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
tfarina@chromium.org | f0c8c499 | 2014-05-15 17:37:26 | [diff] [blame] | 11 | #include "components/pref_registry/pref_registry_syncable.h" |
brettw | b1fc1b8 | 2016-02-02 00:19:08 | [diff] [blame] | 12 | #include "components/prefs/pref_member.h" |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 13 | |
| 14 | class PrefService; |
| 15 | |
Guido Urdaneta | 9f831c2 | 2023-06-22 13:44:34 | [diff] [blame] | 16 | namespace media_device_salt { |
| 17 | |
| 18 | namespace prefs { |
| 19 | extern const char kMediaDeviceIdSalt[]; |
| 20 | } |
| 21 | |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 22 | // MediaDeviceIDSalt is responsible for creating and retrieving a salt string |
| 23 | // that is used for creating MediaSource IDs that can be cached by a web |
| 24 | // service. If the cache is cleared, the MediaSourceIds are invalidated. |
joi@chromium.org | f9583f8 | 2014-02-13 15:34:21 | [diff] [blame] | 25 | // |
| 26 | // The class is reference counted so that it can be used in the |
| 27 | // callback returned by ResourceContext::GetMediaDeviceIDSalt. |
| 28 | class MediaDeviceIDSalt : public base::RefCountedThreadSafe<MediaDeviceIDSalt> { |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 29 | public: |
guidou | 91768ed | 2016-06-15 15:49:51 | [diff] [blame] | 30 | explicit MediaDeviceIDSalt(PrefService* pref_service); |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 31 | |
Peter Boström | fadb175 | 2021-09-30 19:17:01 | [diff] [blame] | 32 | MediaDeviceIDSalt(const MediaDeviceIDSalt&) = delete; |
| 33 | MediaDeviceIDSalt& operator=(const MediaDeviceIDSalt&) = delete; |
| 34 | |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 35 | static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
Guido Urdaneta | 9f831c2 | 2023-06-22 13:44:34 | [diff] [blame] | 36 | |
| 37 | std::string GetSalt() const; |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 38 | static void Reset(PrefService* pref_service); |
| 39 | |
| 40 | private: |
joi@chromium.org | f9583f8 | 2014-02-13 15:34:21 | [diff] [blame] | 41 | friend class base::RefCountedThreadSafe<MediaDeviceIDSalt>; |
| 42 | ~MediaDeviceIDSalt(); |
| 43 | |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 44 | mutable StringPrefMember media_device_id_salt_; |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 45 | }; |
| 46 | |
Guido Urdaneta | 9f831c2 | 2023-06-22 13:44:34 | [diff] [blame] | 47 | } // namespace media_device_salt |
| 48 | |
| 49 | #endif // COMPONENTS_MEDIA_DEVICE_SALT_MEDIA_DEVICE_ID_SALT_H_ |