Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..67eba0ebaea41333f7991a4676bded5e7d73384a |
| --- /dev/null |
| +++ b/components/cdm/browser/media_drm_storage_impl.cc |
| @@ -0,0 +1,110 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/cdm/browser/media_drm_storage_impl.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/memory/ptr_util.h" |
| +#include "base/optional.h" |
| +#include "components/pref_registry/pref_registry_syncable.h" |
| +#include "components/prefs/pref_service.h" |
| +#include "components/prefs/scoped_user_pref_update.h" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +// The storage will be managed by PrefService. All data will be stored in a |
| +// dictionary under the key "media.media_drm_storage". The dictionary is |
| +// structured as follows: |
| +// |
| +// { |
| +// $origin: { |
| +// "origin_id": $origin_id |
| +// "creation_time": $creation_time |
| +// "sessions" : { |
| +// $session_id: { |
| +// "key_set_id": $key_set_id, |
| +// "mime_type": $mime_type, |
| +// "creation_time": $creation_time |
| +// }, |
| +// # more session_id map... |
| +// } |
| +// }, |
| +// # more origin map... |
| +// } |
| + |
| +namespace cdm { |
| + |
| +namespace { |
| + |
| +const char kMediaDrmStorage[] = "media.media_drm_storage"; |
| + |
| +} // namespace |
| + |
| +// static |
| +void MediaDrmStorageImpl::RegisterProfilePrefs( |
| + user_prefs::PrefRegistrySyncable* registry) { |
| + registry->RegisterDictionaryPref(kMediaDrmStorage, |
| + new base::DictionaryValue()); |
| +} |
| + |
| +MediaDrmStorageImpl::MediaDrmStorageImpl(PrefService* pref_service) |
| + : pref_service_(pref_service), weak_factory_(this) { |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + DCHECK(pref_service_); |
| +} |
| + |
| +MediaDrmStorageImpl::~MediaDrmStorageImpl() { |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| +} |
| + |
| +void MediaDrmStorageImpl::Initialize(const url::Origin& origin) { |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + DCHECK(!origin.unique()); |
| + origin_ = origin.Serialize(); |
|
dcheng
2017/03/29 01:17:23
Rather than passing the origin over Mojo, can we j
xhwang
2017/03/29 20:47:25
Yeah, that's what we chat about before and propose
dcheng
2017/03/29 21:15:12
I think I'm missing something: the GPU process is
xhwang
2017/03/29 21:30:44
We have many out-of-process media components. For
dcheng
2017/03/30 00:29:15
There are some complexities with plumbing here, bu
|
| +} |
| + |
| +void MediaDrmStorageImpl::OnProvisioned(const OnProvisionedCallback& callback) { |
| + DVLOG(2) << __func__; |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + DCHECK(!origin_.empty()); |
|
dcheng
2017/03/29 01:17:23
Note that we shouldn't be DCHECKing these sorts of
xhwang
2017/03/29 20:47:25
FWIW, the CDM (MediaDrm) is actually running in th
|
| + |
| + NOTIMPLEMENTED(); |
|
xhwang
2017/03/24 21:22:38
Partial implementation of these functions and some
|
| + callback.Run(false); |
| +} |
| + |
| +void MediaDrmStorageImpl::SavePersistentSession( |
| + const std::string& session_id, |
| + const std::vector<uint8_t>& key_set_id, |
| + const std::string& mime_type, |
| + const SavePersistentSessionCallback& callback) { |
| + DVLOG(2) << __func__; |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + DCHECK(!origin_.empty()); |
| + |
| + NOTIMPLEMENTED(); |
| + callback.Run(false); |
| +} |
| + |
| +void MediaDrmStorageImpl::LoadPersistentSession( |
| + const std::string& session_id, |
| + const LoadPersistentSessionCallback& callback) { |
| + DVLOG(2) << __func__; |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + DCHECK(!origin_.empty()); |
| + |
| + NOTIMPLEMENTED(); |
| + callback.Run(false, {}, ""); |
| +} |
| + |
| +void MediaDrmStorageImpl::RemovePersistentSession( |
| + const std::string& session_id, |
| + const RemovePersistentSessionCallback& callback) { |
| + DVLOG(2) << __func__; |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + DCHECK(!origin_.empty()); |
| + |
| + NOTIMPLEMENTED(); |
| + callback.Run(false); |
| +} |
| + |
| +} // namespace cdm |