Index: components/cdm/browser/media_drm_storage_impl.cc |
diff --git a/components/cdm/browser/media_drm_storage_impl.cc b/components/cdm/browser/media_drm_storage_impl.cc |
index 3a054ee86c4836cd1cc819fb3ca02926225c0831..458a48f03001ac6913a220e3a162a6b1bb8c17db 100644 |
--- a/components/cdm/browser/media_drm_storage_impl.cc |
+++ b/components/cdm/browser/media_drm_storage_impl.cc |
@@ -9,6 +9,7 @@ |
#include "components/prefs/pref_registry_simple.h" |
#include "components/prefs/pref_service.h" |
#include "components/prefs/scoped_user_pref_update.h" |
+#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/navigation_handle.h" |
// The storage will be managed by PrefService. All data will be stored in a |
@@ -36,50 +37,6 @@ |
namespace { |
const char kMediaDrmStorage[] = "media.media_drm_storage"; |
-const char kCreationTime[] = "creation_time"; |
-const char kSessions[] = "sessions"; |
-const char kKeySetId[] = "key_set_id"; |
-const char kMimeType[] = "mime_type"; |
- |
-std::unique_ptr<base::DictionaryValue> CreateOriginDictionary() { |
- auto dict = base::MakeUnique<base::DictionaryValue>(); |
- // TODO(xhwang): Create |origin_id|. |
- dict->SetDouble(kCreationTime, base::Time::Now().ToDoubleT()); |
- return dict; |
-} |
- |
-std::unique_ptr<base::DictionaryValue> CreateSessionDictionary( |
- const std::vector<uint8_t>& key_set_id, |
- const std::string& mime_type) { |
- auto dict = base::MakeUnique<base::DictionaryValue>(); |
- dict->SetString(kKeySetId, |
- std::string(reinterpret_cast<const char*>(key_set_id.data()), |
- key_set_id.size())); |
- dict->SetString(kMimeType, mime_type); |
- dict->SetDouble(kCreationTime, base::Time::Now().ToDoubleT()); |
- return dict; |
-} |
- |
-bool GetSessionData(const base::DictionaryValue* sesssion_dict, |
- std::vector<uint8_t>* key_set_id, |
- std::string* mime_type) { |
- std::string key_set_id_string; |
- if (!sesssion_dict->GetString(kKeySetId, &key_set_id_string)) |
- return false; |
- |
- if (!sesssion_dict->GetString(kMimeType, mime_type)) |
- return false; |
- |
- key_set_id->assign(key_set_id_string.begin(), key_set_id_string.end()); |
- return true; |
-} |
- |
-#if DCHECK_IS_ON() |
-// Returns whether |dict| has a value assocaited with the |key|. |
-bool HasEntry(const base::DictionaryValue& dict, const std::string& key) { |
- return dict.GetDictionaryWithoutPathExpansion(key, nullptr); |
-} |
-#endif |
} // namespace |
@@ -96,12 +53,10 @@ |
: render_frame_host_(render_frame_host), |
pref_service_(pref_service), |
origin_(origin), |
- origin_string_(origin.Serialize()), |
binding_(this, std::move(request)) { |
DVLOG(1) << __func__ << ": origin = " << origin; |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
DCHECK(pref_service_); |
- DCHECK(!origin_string_.empty()); |
// |this| owns |binding_|, so unretained is safe. |
binding_.set_connection_error_handler( |
@@ -110,14 +65,14 @@ |
MediaDrmStorageImpl::~MediaDrmStorageImpl() { |
DVLOG(1) << __func__; |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
} |
// TODO(xhwang): Update this function to return an origin ID. If the origin is |
// not the same as |origin_|, return an empty origin ID. |
void MediaDrmStorageImpl::Initialize(const url::Origin& origin) { |
DVLOG(1) << __func__ << ": origin = " << origin; |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
DCHECK(!initialized_); |
initialized_ = true; |
@@ -125,7 +80,7 @@ |
void MediaDrmStorageImpl::OnProvisioned(const OnProvisionedCallback& callback) { |
DVLOG(1) << __func__; |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
if (!initialized_) { |
DVLOG(1) << __func__ << ": Not initialized."; |
@@ -133,18 +88,8 @@ |
return; |
} |
- DictionaryPrefUpdate update(pref_service_, kMediaDrmStorage); |
- base::DictionaryValue* storage_dict = update.Get(); |
- DCHECK(storage_dict); |
- |
- // The origin string may contain dots. Do not use path expansion. |
- DVLOG_IF(1, HasEntry(*storage_dict, origin_string_)) |
- << __func__ << ": Entry for origin " << origin_string_ |
- << " already exists and will be cleared"; |
- |
- storage_dict->SetWithoutPathExpansion(origin_string_, |
- CreateOriginDictionary()); |
- callback.Run(true); |
+ NOTIMPLEMENTED(); |
+ callback.Run(false); |
} |
void MediaDrmStorageImpl::SavePersistentSession( |
@@ -152,7 +97,7 @@ |
media::mojom::SessionDataPtr session_data, |
const SavePersistentSessionCallback& callback) { |
DVLOG(2) << __func__; |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
if (!initialized_) { |
DVLOG(1) << __func__ << ": Not initialized."; |
@@ -160,43 +105,15 @@ |
return; |
} |
- DictionaryPrefUpdate update(pref_service_, kMediaDrmStorage); |
- base::DictionaryValue* storage_dict = update.Get(); |
- DCHECK(storage_dict); |
- |
- base::DictionaryValue* origin_dict = nullptr; |
- // The origin string may contain dots. Do not use path expansion. |
- storage_dict->GetDictionaryWithoutPathExpansion(origin_string_, &origin_dict); |
- if (!origin_dict) { |
- DVLOG(1) << __func__ |
- << ": Failed to save persistent session data; entry for origin " |
- << origin_string_ << " does not exist."; |
- callback.Run(false); |
- return; |
- } |
- |
- base::DictionaryValue* sessions_dict = nullptr; |
- if (!origin_dict->GetDictionary(kSessions, &sessions_dict)) { |
- DVLOG(2) << __func__ << ": No session exists; creating a new dict."; |
- origin_dict->Set(kSessions, base::MakeUnique<base::DictionaryValue>()); |
- DCHECK(origin_dict->GetDictionary(kSessions, &sessions_dict)); |
- } |
- |
- DVLOG_IF(1, HasEntry(*sessions_dict, session_id)) |
- << __func__ << ": Session ID already exists and will be replaced."; |
- |
- sessions_dict->SetWithoutPathExpansion( |
- session_id, CreateSessionDictionary(session_data->key_set_id, |
- session_data->mime_type)); |
- |
- callback.Run(true); |
+ NOTIMPLEMENTED(); |
+ callback.Run(false); |
} |
void MediaDrmStorageImpl::LoadPersistentSession( |
const std::string& session_id, |
const LoadPersistentSessionCallback& callback) { |
DVLOG(2) << __func__; |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
if (!initialized_) { |
DVLOG(1) << __func__ << ": Not initialized."; |
@@ -204,51 +121,15 @@ |
return; |
} |
- const base::DictionaryValue* storage_dict = |
- pref_service_->GetDictionary(kMediaDrmStorage); |
- |
- const base::DictionaryValue* origin_dict = nullptr; |
- // The origin string may contain dots. Do not use path expansion. |
- storage_dict->GetDictionaryWithoutPathExpansion(origin_string_, &origin_dict); |
- if (!origin_dict) { |
- DVLOG(1) << __func__ |
- << ": Failed to save persistent session data; entry for origin " |
- << origin_ << " does not exist."; |
- callback.Run(nullptr); |
- return; |
- } |
- |
- const base::DictionaryValue* sessions_dict = nullptr; |
- if (!origin_dict->GetDictionary(kSessions, &sessions_dict)) { |
- DVLOG(2) << __func__ << ": Sessions dictionary does not exist."; |
- callback.Run(nullptr); |
- return; |
- } |
- |
- const base::DictionaryValue* session_dict = nullptr; |
- if (!sessions_dict->GetDictionaryWithoutPathExpansion(session_id, |
- &session_dict)) { |
- DVLOG(2) << __func__ << ": Session dictionary does not exist."; |
- callback.Run(nullptr); |
- return; |
- } |
- |
- std::vector<uint8_t> key_set_id; |
- std::string mime_type; |
- if (!GetSessionData(session_dict, &key_set_id, &mime_type)) { |
- DVLOG(2) << __func__ << ": Failed to read session data."; |
- callback.Run(nullptr); |
- return; |
- } |
- |
- callback.Run(media::mojom::SessionData::New(key_set_id, mime_type)); |
+ NOTIMPLEMENTED(); |
+ callback.Run(nullptr); |
} |
void MediaDrmStorageImpl::RemovePersistentSession( |
const std::string& session_id, |
const RemovePersistentSessionCallback& callback) { |
DVLOG(2) << __func__; |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
if (!initialized_) { |
DVLOG(1) << __func__ << ": Not initialized."; |
@@ -256,35 +137,12 @@ |
return; |
} |
- DictionaryPrefUpdate update(pref_service_, kMediaDrmStorage); |
- base::DictionaryValue* storage_dict = update.Get(); |
- DCHECK(storage_dict); |
- |
- base::DictionaryValue* origin_dict = nullptr; |
- // The origin string may contain dots. Do not use path expansion. |
- storage_dict->GetDictionaryWithoutPathExpansion(origin_string_, &origin_dict); |
- if (!origin_dict) { |
- DVLOG(1) << __func__ << ": Entry for rigin " << origin_string_ |
- << " does not exist."; |
- callback.Run(true); |
- return; |
- } |
- |
- base::DictionaryValue* sessions_dict = nullptr; |
- if (!origin_dict->GetDictionary(kSessions, &sessions_dict)) { |
- DVLOG(2) << __func__ << ": Sessions dictionary does not exist."; |
- callback.Run(true); |
- return; |
- } |
- |
- sessions_dict->RemoveWithoutPathExpansion(session_id, nullptr); |
- callback.Run(true); |
+ NOTIMPLEMENTED(); |
+ callback.Run(false); |
} |
void MediaDrmStorageImpl::RenderFrameDeleted( |
content::RenderFrameHost* render_frame_host) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
- |
if (render_frame_host == render_frame_host_) { |
DVLOG(1) << __func__ << ": RenderFrame destroyed."; |
Close(); |
@@ -293,8 +151,6 @@ |
void MediaDrmStorageImpl::DidFinishNavigation( |
content::NavigationHandle* navigation_handle) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
- |
if (navigation_handle->GetRenderFrameHost() == render_frame_host_) { |
DVLOG(1) << __func__ << ": Close connection on navigation."; |
Close(); |
@@ -303,7 +159,7 @@ |
void MediaDrmStorageImpl::Close() { |
DVLOG(1) << __func__; |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
delete this; |
} |