perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 1 | // Copyright 2013 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. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ |
| 6 | #define CHROME_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
joi@chromium.org | f9583f8 | 2014-02-13 15:34:21 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 11 | #include "base/prefs/pref_member.h" |
tfarina@chromium.org | f0c8c499 | 2014-05-15 17:37:26 | [diff] [blame^] | 12 | #include "components/pref_registry/pref_registry_syncable.h" |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 13 | |
| 14 | class PrefService; |
| 15 | |
| 16 | // MediaDeviceIDSalt is responsible for creating and retrieving a salt string |
| 17 | // that is used for creating MediaSource IDs that can be cached by a web |
| 18 | // service. If the cache is cleared, the MediaSourceIds are invalidated. |
joi@chromium.org | f9583f8 | 2014-02-13 15:34:21 | [diff] [blame] | 19 | // |
| 20 | // The class is reference counted so that it can be used in the |
| 21 | // callback returned by ResourceContext::GetMediaDeviceIDSalt. |
| 22 | class MediaDeviceIDSalt : public base::RefCountedThreadSafe<MediaDeviceIDSalt> { |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 23 | public: |
joi@chromium.org | f9583f8 | 2014-02-13 15:34:21 | [diff] [blame] | 24 | MediaDeviceIDSalt(PrefService* pref_service, bool incognito); |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 25 | void ShutdownOnUIThread(); |
| 26 | |
| 27 | std::string GetSalt() const; |
| 28 | |
| 29 | static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 30 | static void Reset(PrefService* pref_service); |
| 31 | |
| 32 | private: |
joi@chromium.org | f9583f8 | 2014-02-13 15:34:21 | [diff] [blame] | 33 | friend class base::RefCountedThreadSafe<MediaDeviceIDSalt>; |
| 34 | ~MediaDeviceIDSalt(); |
| 35 | |
perkj@chromium.org | cd80cce | 2013-12-02 15:19:19 | [diff] [blame] | 36 | // |incognito_salt_| is initialized in ctor on UI thread but only read |
| 37 | // on the IO thread. |
| 38 | std::string incognito_salt_; |
| 39 | mutable StringPrefMember media_device_id_salt_; |
| 40 | |
| 41 | DISALLOW_COPY_AND_ASSIGN(MediaDeviceIDSalt); |
| 42 | }; |
| 43 | |
| 44 | #endif // CHROME_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ |