Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: chrome/browser/media/media_device_id_salt.h

Issue 143003031: Allow retrieval of media device ID salt even after ResourceContext has gone away. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add TODO about proper fix. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 CHROME_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_
6 #define CHROME_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ 6 #define CHROME_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h"
10 #include "base/prefs/pref_member.h" 11 #include "base/prefs/pref_member.h"
11 #include "components/user_prefs/pref_registry_syncable.h" 12 #include "components/user_prefs/pref_registry_syncable.h"
12 13
13 class PrefService; 14 class PrefService;
14 15
15 // MediaDeviceIDSalt is responsible for creating and retrieving a salt string 16 // MediaDeviceIDSalt is responsible for creating and retrieving a salt string
16 // that is used for creating MediaSource IDs that can be cached by a web 17 // that is used for creating MediaSource IDs that can be cached by a web
17 // service. If the cache is cleared, the MediaSourceIds are invalidated. 18 // service. If the cache is cleared, the MediaSourceIds are invalidated.
18 class MediaDeviceIDSalt { 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> {
19 public: 23 public:
20 MediaDeviceIDSalt(PrefService* pref_service, 24 MediaDeviceIDSalt(PrefService* pref_service, bool incognito);
21 bool incognito);
22 ~MediaDeviceIDSalt();
23 void ShutdownOnUIThread(); 25 void ShutdownOnUIThread();
24 26
25 std::string GetSalt() const; 27 std::string GetSalt() const;
26 28
27 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 29 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
28 static void Reset(PrefService* pref_service); 30 static void Reset(PrefService* pref_service);
29 31
30 private: 32 private:
33 friend class base::RefCountedThreadSafe<MediaDeviceIDSalt>;
34 ~MediaDeviceIDSalt();
35
31 // |incognito_salt_| is initialized in ctor on UI thread but only read 36 // |incognito_salt_| is initialized in ctor on UI thread but only read
32 // on the IO thread. 37 // on the IO thread.
33 std::string incognito_salt_; 38 std::string incognito_salt_;
34 mutable StringPrefMember media_device_id_salt_; 39 mutable StringPrefMember media_device_id_salt_;
35 40
36 DISALLOW_COPY_AND_ASSIGN(MediaDeviceIDSalt); 41 DISALLOW_COPY_AND_ASSIGN(MediaDeviceIDSalt);
37 }; 42 };
38 43
39 #endif // CHROME_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_ 44 #endif // CHROME_BROWSER_MEDIA_MEDIA_DEVICE_ID_SALT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698