OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ | 5 #ifndef COMPONENTS_MEDIA_DEVICE_ID_SALT_MEDIA_DEVICE_ID_SALT_H_ |
6 #define CHROME_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ | 6 #define COMPONENTS_MEDIA_DEVICE_ID_SALT_MEDIA_DEVICE_ID_SALT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "components/pref_registry/pref_registry_syncable.h" | 12 #include "components/pref_registry/pref_registry_syncable.h" |
13 #include "components/prefs/pref_member.h" | 13 #include "components/prefs/pref_member.h" |
14 | 14 |
15 class PrefService; | 15 class PrefService; |
16 | 16 |
| 17 namespace media_device_id_salt { |
| 18 |
| 19 namespace prefs { |
| 20 |
| 21 // The salt used for creating random MediaSource IDs. |
| 22 extern const char kMediaDeviceIdSalt[]; |
| 23 |
| 24 } // namespace prefs |
| 25 |
17 // MediaDeviceIDSalt is responsible for creating and retrieving a salt string | 26 // MediaDeviceIDSalt is responsible for creating and retrieving a salt string |
18 // that is used for creating MediaSource IDs that can be cached by a web | 27 // that is used for creating MediaSource IDs that can be cached by a web |
19 // service. If the cache is cleared, the MediaSourceIds are invalidated. | 28 // service. If the cache is cleared, the MediaSourceIds are invalidated. |
20 // | 29 // |
21 // The class is reference counted so that it can be used in the | 30 // The class is reference counted so that it can be used in the |
22 // callback returned by ResourceContext::GetMediaDeviceIDSalt. | 31 // callback returned by ResourceContext::GetMediaDeviceIDSalt. |
23 class MediaDeviceIDSalt : public base::RefCountedThreadSafe<MediaDeviceIDSalt> { | 32 class MediaDeviceIDSalt : public base::RefCountedThreadSafe<MediaDeviceIDSalt> { |
24 public: | 33 public: |
25 MediaDeviceIDSalt(PrefService* pref_service, bool incognito); | 34 MediaDeviceIDSalt(PrefService* pref_service, bool incognito); |
26 void ShutdownOnUIThread(); | 35 void ShutdownOnUIThread(); |
27 | 36 |
28 std::string GetSalt() const; | 37 std::string GetSalt() const; |
29 | 38 |
30 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 39 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
31 static void Reset(PrefService* pref_service); | 40 static void Reset(PrefService* pref_service); |
32 | 41 |
33 private: | 42 private: |
34 friend class base::RefCountedThreadSafe<MediaDeviceIDSalt>; | 43 friend class base::RefCountedThreadSafe<MediaDeviceIDSalt>; |
35 ~MediaDeviceIDSalt(); | 44 ~MediaDeviceIDSalt(); |
36 | 45 |
37 // |incognito_salt_| is initialized in ctor on UI thread but only read | 46 // |incognito_salt_| is initialized in ctor on UI thread but only read |
38 // on the IO thread. | 47 // on the IO thread. |
39 std::string incognito_salt_; | 48 std::string incognito_salt_; |
40 mutable StringPrefMember media_device_id_salt_; | 49 mutable StringPrefMember media_device_id_salt_; |
41 | 50 |
42 DISALLOW_COPY_AND_ASSIGN(MediaDeviceIDSalt); | 51 DISALLOW_COPY_AND_ASSIGN(MediaDeviceIDSalt); |
43 }; | 52 }; |
44 | 53 |
45 #endif // CHROME_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ | 54 } // namespace media_device_id_salt |
| 55 |
| 56 #endif // COMPONENTS_MEDIA_DEVICE_ID_SALT_MEDIA_DEVICE_ID_SALT_H_ |
OLD | NEW |