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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/media_device_id_salt.h
diff --git a/chrome/browser/media/media_device_id_salt.h b/chrome/browser/media/media_device_id_salt.h
index a98e3fb7ebe4b15837fd69a6d90b83e19358e723..46df854078910d0132d92038e3e2611053eb0a8a 100644
--- a/chrome/browser/media/media_device_id_salt.h
+++ b/chrome/browser/media/media_device_id_salt.h
@@ -7,6 +7,7 @@
#include <string>
+#include "base/memory/ref_counted.h"
#include "base/prefs/pref_member.h"
#include "components/user_prefs/pref_registry_syncable.h"
@@ -15,11 +16,12 @@ class PrefService;
// MediaDeviceIDSalt is responsible for creating and retrieving a salt string
// that is used for creating MediaSource IDs that can be cached by a web
// service. If the cache is cleared, the MediaSourceIds are invalidated.
-class MediaDeviceIDSalt {
+//
+// The class is reference counted so that it can be used in the
+// callback returned by ResourceContext::GetMediaDeviceIDSalt.
+class MediaDeviceIDSalt : public base::RefCountedThreadSafe<MediaDeviceIDSalt> {
public:
- MediaDeviceIDSalt(PrefService* pref_service,
- bool incognito);
- ~MediaDeviceIDSalt();
+ MediaDeviceIDSalt(PrefService* pref_service, bool incognito);
void ShutdownOnUIThread();
std::string GetSalt() const;
@@ -28,6 +30,9 @@ class MediaDeviceIDSalt {
static void Reset(PrefService* pref_service);
private:
+ friend class base::RefCountedThreadSafe<MediaDeviceIDSalt>;
+ ~MediaDeviceIDSalt();
+
// |incognito_salt_| is initialized in ctor on UI thread but only read
// on the IO thread.
std::string incognito_salt_;

Powered by Google App Engine
This is Rietveld 408576698