1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_MEDIA_DEVICE_SALT_MEDIA_DEVICE_ID_SALT_H_
6 #define COMPONENTS_MEDIA_DEVICE_SALT_MEDIA_DEVICE_ID_SALT_H_
10 #include "base/memory/ref_counted.h"
11 #include "components/pref_registry/pref_registry_syncable.h"
12 #include "components/prefs/pref_member.h"
16 namespace media_device_salt {
19 extern const char kMediaDeviceIdSalt[];
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.
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> {
30 explicit MediaDeviceIDSalt(PrefService* pref_service);
32 MediaDeviceIDSalt(const MediaDeviceIDSalt&) = delete;
33 MediaDeviceIDSalt& operator=(const MediaDeviceIDSalt&) = delete;
35 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
37 std::string GetSalt() const;
38 static void Reset(PrefService* pref_service);
41 friend class base::RefCountedThreadSafe<MediaDeviceIDSalt>;
44 mutable StringPrefMember media_device_id_salt_;
47 } // namespace media_device_salt
49 #endif // COMPONENTS_MEDIA_DEVICE_SALT_MEDIA_DEVICE_ID_SALT_H_