Commit 5ba56be6 authored by xhwang's avatar xhwang Committed by Commit bot

media: Rename CdmService to CdmRegistry

TBR=nasko@chromium.org,waffles@chromium.org
BUG=672652

Review-Url: https://codereview.chromium.org/2565853003
Cr-Commit-Position: refs/heads/master@{#438091}
parent 3b099320
......@@ -33,7 +33,7 @@
#include "components/component_updater/default_component_installer.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/cdm_service.h"
#include "content/public/browser/cdm_registry.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/common/cdm_info.h"
#include "content/public/common/pepper_plugin_info.h"
......@@ -43,7 +43,7 @@
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT
using content::BrowserThread;
using content::CdmService;
using content::CdmRegistry;
using content::PluginService;
namespace component_updater {
......@@ -228,14 +228,14 @@ void RegisterWidevineCdmWithChrome(
PluginService::GetInstance()->RefreshPlugins();
PluginService::GetInstance()->PurgePluginListCache(NULL, false);
// Also register Widevine with the CdmService.
// Also register Widevine with the CdmRegistry.
const base::FilePath cdm_path =
GetPlatformDirectory(cdm_install_dir)
.AppendASCII(base::GetNativeLibraryName(kWidevineCdmLibraryName));
const std::vector<std::string> supported_codecs = base::SplitString(
codecs, std::string(1, kCdmSupportedCodecsValueDelimiter),
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
CdmService::GetInstance()->RegisterCdm(content::CdmInfo(
CdmRegistry::GetInstance()->RegisterCdm(content::CdmInfo(
kWidevineCdmType, cdm_version, cdm_path, supported_codecs));
}
......
......@@ -878,8 +878,8 @@ source_set("browser") {
"media/capture/window_activity_tracker_aura.h",
"media/capture/window_activity_tracker_mac.h",
"media/capture/window_activity_tracker_mac.mm",
"media/cdm_service_impl.cc",
"media/cdm_service_impl.h",
"media/cdm_registry_impl.cc",
"media/cdm_registry_impl.h",
"media/media_devices_permission_checker.cc",
"media/media_devices_permission_checker.h",
"media/media_interface_proxy.cc",
......
......@@ -190,7 +190,7 @@
#endif
#if defined(ENABLE_MOJO_CDM) && BUILDFLAG(ENABLE_PEPPER_CDMS)
#include "content/browser/media/cdm_service_impl.h"
#include "content/browser/media/cdm_registry_impl.h"
#endif
#if defined(USE_X11)
......@@ -854,7 +854,7 @@ int BrowserMainLoop::PreCreateThreads() {
// Prior to any processing happening on the IO thread, we create the
// CDM service as it is predominantly used from the IO thread. This must
// be called on the main thread since it involves file path checks.
CdmService::GetInstance()->Init();
CdmRegistry::GetInstance()->Init();
#endif
#if defined(OS_MACOSX)
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/media/cdm_service_impl.h"
#include "content/browser/media/cdm_registry_impl.h"
#include <stddef.h>
......@@ -11,35 +11,35 @@
namespace content {
static base::LazyInstance<CdmServiceImpl>::Leaky g_cdm_service =
static base::LazyInstance<CdmRegistryImpl>::Leaky g_cdm_registry =
LAZY_INSTANCE_INITIALIZER;
// static
CdmService* CdmService::GetInstance() {
return CdmServiceImpl::GetInstance();
CdmRegistry* CdmRegistry::GetInstance() {
return CdmRegistryImpl::GetInstance();
}
// static
CdmServiceImpl* CdmServiceImpl::GetInstance() {
return g_cdm_service.Pointer();
CdmRegistryImpl* CdmRegistryImpl::GetInstance() {
return g_cdm_registry.Pointer();
}
CdmServiceImpl::CdmServiceImpl() {}
CdmRegistryImpl::CdmRegistryImpl() {}
CdmServiceImpl::~CdmServiceImpl() {}
CdmRegistryImpl::~CdmRegistryImpl() {}
void CdmServiceImpl::Init() {
void CdmRegistryImpl::Init() {
// Let embedders register CDMs.
GetContentClient()->AddContentDecryptionModules(&cdms_);
}
void CdmServiceImpl::RegisterCdm(const CdmInfo& info) {
void CdmRegistryImpl::RegisterCdm(const CdmInfo& info) {
// Always register new CDMs at the beginning of the list, so that
// subsequent requests get the latest.
cdms_.insert(cdms_.begin(), info);
}
const std::vector<CdmInfo>& CdmServiceImpl::GetAllRegisteredCdms() {
const std::vector<CdmInfo>& CdmRegistryImpl::GetAllRegisteredCdms() {
return cdms_;
}
......
......@@ -2,42 +2,42 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_MEDIA_CDM_SERVICE_IMPL_H_
#define CONTENT_BROWSER_MEDIA_CDM_SERVICE_IMPL_H_
#ifndef CONTENT_BROWSER_MEDIA_CDM_REGISTRY_IMPL_H_
#define CONTENT_BROWSER_MEDIA_CDM_REGISTRY_IMPL_H_
#include <vector>
#include "base/lazy_instance.h"
#include "base/macros.h"
#include "content/common/content_export.h"
#include "content/public/browser/cdm_service.h"
#include "content/public/browser/cdm_registry.h"
namespace content {
struct CdmInfo;
class CONTENT_EXPORT CdmServiceImpl : NON_EXPORTED_BASE(public CdmService) {
class CONTENT_EXPORT CdmRegistryImpl : NON_EXPORTED_BASE(public CdmRegistry) {
public:
// Returns the CdmServiceImpl singleton.
static CdmServiceImpl* GetInstance();
// Returns the CdmRegistryImpl singleton.
static CdmRegistryImpl* GetInstance();
// CdmService implementation.
// CdmRegistry implementation.
void Init() override;
void RegisterCdm(const CdmInfo& info) override;
const std::vector<CdmInfo>& GetAllRegisteredCdms() override;
private:
friend struct base::DefaultLazyInstanceTraits<CdmServiceImpl>;
friend class CdmServiceImplTest;
friend struct base::DefaultLazyInstanceTraits<CdmRegistryImpl>;
friend class CdmRegistryImplTest;
CdmServiceImpl();
~CdmServiceImpl() override;
CdmRegistryImpl();
~CdmRegistryImpl() override;
std::vector<CdmInfo> cdms_;
DISALLOW_COPY_AND_ASSIGN(CdmServiceImpl);
DISALLOW_COPY_AND_ASSIGN(CdmRegistryImpl);
};
} // namespace content
#endif // CONTENT_BROWSER_MEDIA_CDM_SERVICE_IMPL_H_
#endif // CONTENT_BROWSER_MEDIA_CDM_REGISTRY_IMPL_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/media/cdm_service_impl.h"
#include "content/browser/media/cdm_registry_impl.h"
#include <algorithm>
#include <string>
......@@ -28,10 +28,10 @@ const char kCodecDelimiter[] = ",";
// For simplicity and to make failures easier to diagnose, this test uses
// std::string instead of base::FilePath and std::vector<std::string>.
class CdmServiceImplTest : public testing::Test {
class CdmRegistryImplTest : public testing::Test {
public:
CdmServiceImplTest() {}
~CdmServiceImplTest() override {}
CdmRegistryImplTest() {}
~CdmRegistryImplTest() override {}
protected:
void Register(const std::string& type,
......@@ -41,13 +41,13 @@ class CdmServiceImplTest : public testing::Test {
const std::vector<std::string> codecs =
base::SplitString(supported_codecs, kCodecDelimiter,
base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
cdm_service_.RegisterCdm(CdmInfo(type, base::Version(version),
base::FilePath::FromUTF8Unsafe(path),
codecs));
cdm_registry_.RegisterCdm(CdmInfo(type, base::Version(version),
base::FilePath::FromUTF8Unsafe(path),
codecs));
}
bool IsRegistered(const std::string& type, const std::string& version) {
for (const auto& cdm : cdm_service_.GetAllRegisteredCdms()) {
for (const auto& cdm : cdm_registry_.GetAllRegisteredCdms()) {
if (cdm.type == type && cdm.version.GetString() == version)
return true;
}
......@@ -56,7 +56,7 @@ class CdmServiceImplTest : public testing::Test {
std::vector<std::string> GetVersions(const std::string& type) {
std::vector<std::string> versions;
for (const auto& cdm : cdm_service_.GetAllRegisteredCdms()) {
for (const auto& cdm : cdm_registry_.GetAllRegisteredCdms()) {
if (cdm.type == type)
versions.push_back(cdm.version.GetString());
}
......@@ -64,19 +64,19 @@ class CdmServiceImplTest : public testing::Test {
}
private:
CdmServiceImpl cdm_service_;
CdmRegistryImpl cdm_registry_;
};
// Note that KeySystemService is a singleton, and thus the actions of
// one test impact other tests. So each test defines a different key system
// name to avoid conflicts.
TEST_F(CdmServiceImplTest, Register) {
TEST_F(CdmRegistryImplTest, Register) {
Register(kTestKeySystemType, kVersion1, kTestPath, kTestCodecs);
EXPECT_TRUE(IsRegistered(kTestKeySystemType, kVersion1));
}
TEST_F(CdmServiceImplTest, ReRegister) {
TEST_F(CdmRegistryImplTest, ReRegister) {
Register(kTestKeySystemType, kVersion1, "/bb/cc", "unknown");
EXPECT_TRUE(IsRegistered(kTestKeySystemType, kVersion1));
......@@ -85,14 +85,14 @@ TEST_F(CdmServiceImplTest, ReRegister) {
EXPECT_TRUE(IsRegistered(kTestKeySystemType, kVersion1));
}
TEST_F(CdmServiceImplTest, MultipleVersions) {
TEST_F(CdmRegistryImplTest, MultipleVersions) {
Register(kTestKeySystemType, kVersion1, kTestPath, kTestCodecs);
Register(kTestKeySystemType, kVersion2, "/bb/cc", "unknown");
EXPECT_TRUE(IsRegistered(kTestKeySystemType, kVersion1));
EXPECT_TRUE(IsRegistered(kTestKeySystemType, kVersion2));
}
TEST_F(CdmServiceImplTest, NewVersionInsertedFirst) {
TEST_F(CdmRegistryImplTest, NewVersionInsertedFirst) {
Register(kTestKeySystemType, kVersion1, kTestPath, kTestCodecs);
Register(kTestKeySystemType, kVersion2, "/bb/cc", "unknown");
......
......@@ -73,6 +73,7 @@ source_set("browser_sources") {
"browser_url_handler.h",
"cache_storage_context.h",
"cache_storage_usage_info.h",
"cdm_registry.h",
"certificate_request_result_type.h",
"child_process_data.h",
"child_process_security_policy.h",
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_BROWSER_CDM_SERVICE_H_
#define CONTENT_PUBLIC_BROWSER_CDM_SERVICE_H_
#ifndef CONTENT_PUBLIC_BROWSER_CDM_REGISTRY_H_
#define CONTENT_PUBLIC_BROWSER_CDM_REGISTRY_H_
#include <vector>
......@@ -14,12 +14,12 @@ namespace content {
struct CdmInfo;
// Keeps track of the Content Decryption Modules that are available.
class CONTENT_EXPORT CdmService {
class CONTENT_EXPORT CdmRegistry {
public:
// Returns the CdmService singleton.
static CdmService* GetInstance();
// Returns the CdmRegistry singleton.
static CdmRegistry* GetInstance();
virtual ~CdmService() {}
virtual ~CdmRegistry() {}
// Must be called on the instance to finish initialization.
virtual void Init() = 0;
......@@ -39,4 +39,4 @@ class CONTENT_EXPORT CdmService {
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_CDM_SERVICE_H_
#endif // CONTENT_PUBLIC_BROWSER_CDM_REGISTRY_H_
......@@ -1121,7 +1121,7 @@ test("content_unittests") {
"../browser/media/capture/cursor_renderer_aura_unittest.cc",
"../browser/media/capture/web_contents_audio_input_stream_unittest.cc",
"../browser/media/capture/web_contents_video_capture_device_unittest.cc",
"../browser/media/cdm_service_impl_unittest.cc",
"../browser/media/cdm_registry_impl_unittest.cc",
"../browser/media/media_internals_unittest.cc",
"../browser/media/midi_host_unittest.cc",
"../browser/media/session/audio_focus_manager_unittest.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment