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

Unified Diff: media/cdm/ppapi/external_clear_key/clear_key_cdm.cc

Issue 1428753010: Add unit tests for CdmAdapter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes for bots Created 5 years, 1 month 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: media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
diff --git a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
index f6c77815303af428b5a131b4fa5e5915b4234691..0c8bbf307785efa40f8d96ff2217a9193496f0bf 100644
--- a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
+++ b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
@@ -212,23 +212,25 @@ void ConvertCdmKeysInfo(const std::vector<media::CdmKeyInformation*>& keys_info,
}
}
-template<typename Type>
-class ScopedResetter {
- public:
- explicit ScopedResetter(Type* object) : object_(object) {}
- ~ScopedResetter() { object_->Reset(); }
-
- private:
- Type* const object_;
-};
+// If GURL::EmptyGURL() is used then a static object is created, and
+// never freed. This means the LeakSanitizer will complain that that
+// an object is never freed. Creating our own copy, which also verifies
+// that DeinitializeCdmModule() is called.
+static GURL* empty_gurl;
void INITIALIZE_CDM_MODULE() {
+ DVLOG(1) << __FUNCTION__;
+ DCHECK(!empty_gurl) << "Only call INITIALIZE_CDM_MODULE() once.";
+
+ empty_gurl = new GURL();
#if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
av_register_all();
#endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER
}
void DeinitializeCdmModule() {
+ DVLOG(1) << __FUNCTION__;
+ delete empty_gurl;
}
void* CreateCdmInstance(int cdm_interface_version,
@@ -255,7 +257,7 @@ void* CreateCdmInstance(int cdm_interface_version,
return NULL;
// TODO(jrummell): Obtain the proper origin for this instance.
- return new media::ClearKeyCdm(host, key_system_string, GURL::EmptyGURL());
+ return new media::ClearKeyCdm(host, key_system_string, *empty_gurl);
xhwang 2015/11/13 00:03:22 Can we just create a temp local GURL here instead
jrummell 2015/11/13 00:35:20 Done.
}
const char* GetCdmVersion() {

Powered by Google App Engine
This is Rietveld 408576698