OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/cdm/external_clear_key_test_helper.h" | 5 #include "media/cdm/external_clear_key_test_helper.h" |
6 | 6 |
| 7 #include "base/debug/leak_annotations.h" |
7 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
9 #include "base/native_library.h" | 10 #include "base/native_library.h" |
10 #include "base/path_service.h" | 11 #include "base/path_service.h" |
11 #include "media/cdm/api/content_decryption_module.h" | 12 #include "media/cdm/api/content_decryption_module.h" |
12 #include "media/cdm/cdm_paths.h" | 13 #include "media/cdm/cdm_paths.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace media { | 16 namespace media { |
16 | 17 |
(...skipping 27 matching lines...) Expand all Loading... |
44 // Now load the CDM library. | 45 // Now load the CDM library. |
45 base::NativeLibraryLoadError error; | 46 base::NativeLibraryLoadError error; |
46 library_.Reset(base::LoadNativeLibrary(library_path_, &error)); | 47 library_.Reset(base::LoadNativeLibrary(library_path_, &error)); |
47 ASSERT_TRUE(library_.is_valid()) << error.ToString(); | 48 ASSERT_TRUE(library_.is_valid()) << error.ToString(); |
48 | 49 |
49 // Call INITIALIZE_CDM_MODULE() | 50 // Call INITIALIZE_CDM_MODULE() |
50 typedef void (*InitializeCdmFunc)(); | 51 typedef void (*InitializeCdmFunc)(); |
51 InitializeCdmFunc initialize_cdm_func = reinterpret_cast<InitializeCdmFunc>( | 52 InitializeCdmFunc initialize_cdm_func = reinterpret_cast<InitializeCdmFunc>( |
52 library_.GetFunctionPointer(MAKE_STRING(INITIALIZE_CDM_MODULE))); | 53 library_.GetFunctionPointer(MAKE_STRING(INITIALIZE_CDM_MODULE))); |
53 ASSERT_TRUE(initialize_cdm_func) << "No INITIALIZE_CDM_MODULE in library"; | 54 ASSERT_TRUE(initialize_cdm_func) << "No INITIALIZE_CDM_MODULE in library"; |
| 55 |
| 56 // Loading and unloading this library leaks all static allocations; previously |
| 57 // these were suppressed by a similar annotation in base::LazyInstance. With |
| 58 // the switch to thread-safe statics, we lost the annotation. |
| 59 // |
| 60 // TODO(xhwang): Investigate if we are actually leaking memory during the |
| 61 // normal process by which Chrome uses this library. http://crbug.com/691132. |
| 62 ANNOTATE_SCOPED_MEMORY_LEAK; |
54 initialize_cdm_func(); | 63 initialize_cdm_func(); |
55 } | 64 } |
56 | 65 |
57 void ExternalClearKeyTestHelper::UnloadLibrary() { | 66 void ExternalClearKeyTestHelper::UnloadLibrary() { |
58 // Call DeinitializeCdmModule() | 67 // Call DeinitializeCdmModule() |
59 typedef void (*DeinitializeCdmFunc)(); | 68 typedef void (*DeinitializeCdmFunc)(); |
60 DeinitializeCdmFunc deinitialize_cdm_func = | 69 DeinitializeCdmFunc deinitialize_cdm_func = |
61 reinterpret_cast<DeinitializeCdmFunc>( | 70 reinterpret_cast<DeinitializeCdmFunc>( |
62 library_.GetFunctionPointer("DeinitializeCdmModule")); | 71 library_.GetFunctionPointer("DeinitializeCdmModule")); |
63 ASSERT_TRUE(deinitialize_cdm_func) << "No DeinitializeCdmModule() in library"; | 72 ASSERT_TRUE(deinitialize_cdm_func) << "No DeinitializeCdmModule() in library"; |
64 deinitialize_cdm_func(); | 73 deinitialize_cdm_func(); |
65 } | 74 } |
66 | 75 |
67 } // namespace media | 76 } // namespace media |
OLD | NEW |