OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/native_library.h" | 10 #include "base/native_library.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/scoped_native_library.h" | 12 #include "base/scoped_native_library.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "ppapi/features/features.h" | |
17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "testing/perf/perf_test.h" | 17 #include "testing/perf/perf_test.h" |
19 | 18 |
20 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 19 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
21 | 20 |
22 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 21 #if defined(ENABLE_PEPPER_CDMS) |
23 #include "chrome/browser/media/pepper_cdm_test_constants.h" | 22 #include "chrome/browser/media/pepper_cdm_test_constants.h" |
24 #include "media/cdm/cdm_paths.h" | 23 #include "media/cdm/cdm_paths.h" |
25 #endif | 24 #endif |
26 | 25 |
27 namespace { | 26 namespace { |
28 | 27 |
29 // Measures the size (bytes) and time to load (sec) of a native library. | 28 // Measures the size (bytes) and time to load (sec) of a native library. |
30 // |library_relative_dir| is the relative path based on DIR_MODULE. | 29 // |library_relative_dir| is the relative path based on DIR_MODULE. |
31 void MeasureSizeAndTimeToLoadNativeLibrary( | 30 void MeasureSizeAndTimeToLoadNativeLibrary( |
32 const base::FilePath& library_relative_dir, | 31 const base::FilePath& library_relative_dir, |
(...skipping 21 matching lines...) Expand all Loading... |
54 ASSERT_TRUE(native_library) << "Error loading library: " << error.ToString(); | 53 ASSERT_TRUE(native_library) << "Error loading library: " << error.ToString(); |
55 base::UnloadNativeLibrary(native_library); | 54 base::UnloadNativeLibrary(native_library); |
56 perf_test::PrintResult("time_to_load_library", | 55 perf_test::PrintResult("time_to_load_library", |
57 "", | 56 "", |
58 library_name.AsUTF8Unsafe(), | 57 library_name.AsUTF8Unsafe(), |
59 delta, | 58 delta, |
60 "ms", | 59 "ms", |
61 true); | 60 true); |
62 } | 61 } |
63 | 62 |
64 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 63 #if defined(ENABLE_PEPPER_CDMS) |
65 | 64 |
66 void MeasureSizeAndTimeToLoadCdm(const std::string& cdm_base_dir, | 65 void MeasureSizeAndTimeToLoadCdm(const std::string& cdm_base_dir, |
67 const std::string& cdm_name) { | 66 const std::string& cdm_name) { |
68 MeasureSizeAndTimeToLoadNativeLibrary( | 67 MeasureSizeAndTimeToLoadNativeLibrary( |
69 media::GetPlatformSpecificDirectory(cdm_base_dir), | 68 media::GetPlatformSpecificDirectory(cdm_base_dir), |
70 base::FilePath::FromUTF8Unsafe(cdm_name)); | 69 base::FilePath::FromUTF8Unsafe(cdm_name)); |
71 } | 70 } |
72 | 71 |
73 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) | 72 #endif // defined(ENABLE_PEPPER_CDMS) |
74 | 73 |
75 } // namespace | 74 } // namespace |
76 | 75 |
77 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 76 #if defined(ENABLE_PEPPER_CDMS) |
78 #if defined(WIDEVINE_CDM_AVAILABLE) | 77 #if defined(WIDEVINE_CDM_AVAILABLE) |
79 TEST(LoadCDMPerfTest, Widevine) { | 78 TEST(LoadCDMPerfTest, Widevine) { |
80 MeasureSizeAndTimeToLoadCdm( | 79 MeasureSizeAndTimeToLoadCdm( |
81 kWidevineCdmBaseDirectory, | 80 kWidevineCdmBaseDirectory, |
82 base::GetNativeLibraryName(kWidevineCdmLibraryName)); | 81 base::GetNativeLibraryName(kWidevineCdmLibraryName)); |
83 } | 82 } |
84 | 83 |
85 TEST(LoadCDMPerfTest, WidevineAdapter) { | 84 TEST(LoadCDMPerfTest, WidevineAdapter) { |
86 MeasureSizeAndTimeToLoadCdm(kWidevineCdmBaseDirectory, | 85 MeasureSizeAndTimeToLoadCdm(kWidevineCdmBaseDirectory, |
87 kWidevineCdmAdapterFileName); | 86 kWidevineCdmAdapterFileName); |
88 } | 87 } |
89 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 88 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
90 | 89 |
91 TEST(LoadCDMPerfTest, ExternalClearKey) { | 90 TEST(LoadCDMPerfTest, ExternalClearKey) { |
92 MeasureSizeAndTimeToLoadCdm( | 91 MeasureSizeAndTimeToLoadCdm( |
93 kClearKeyCdmBaseDirectory, | 92 kClearKeyCdmBaseDirectory, |
94 base::GetNativeLibraryName(media::kClearKeyCdmLibraryName)); | 93 base::GetNativeLibraryName(media::kClearKeyCdmLibraryName)); |
95 } | 94 } |
96 | 95 |
97 TEST(LoadCDMPerfTest, ExternalClearKeyAdapter) { | 96 TEST(LoadCDMPerfTest, ExternalClearKeyAdapter) { |
98 MeasureSizeAndTimeToLoadCdm(kClearKeyCdmBaseDirectory, | 97 MeasureSizeAndTimeToLoadCdm(kClearKeyCdmBaseDirectory, |
99 kClearKeyCdmAdapterFileName); | 98 kClearKeyCdmAdapterFileName); |
100 } | 99 } |
101 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) | 100 #endif // defined(ENABLE_PEPPER_CDMS) |
OLD | NEW |