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

Side by Side Diff: media/cdm/external_clear_key_test_helper.cc

Issue 2668813002: Remove LazyInstance usage from media/ (Closed)
Patch Set: Fix presubmit comments. Created 3 years, 10 months 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 unified diff | Download patch
« no previous file with comments | « media/cast/test/utility/udp_proxy_main.cc ('k') | media/filters/ffmpeg_glue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « media/cast/test/utility/udp_proxy_main.cc ('k') | media/filters/ffmpeg_glue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698