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

Unified Diff: media/base/media_win.cc

Issue 14891002: Remove function level static initializers media library initialization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/media_stub.cc ('k') | media/base/run_all_unittests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/media_win.cc
diff --git a/media/base/media_win.cc b/media/base/media_win.cc
index b6602f94da71a38d11abae52a417fd2483c178ae..43bf6a7f45875571927c7272a87cf4a43831f269 100644
--- a/media/base/media_win.cc
+++ b/media/base/media_win.cc
@@ -12,56 +12,28 @@
#include <delayimp.h>
#include "base/files/file_path.h"
-#include "base/logging.h"
-#include "base/native_library.h"
-#include "base/path_service.h"
#pragma comment(lib, "delayimp.lib")
namespace media {
+namespace internal {
-// FFmpeg library name.
-static const char kFFmpegDLL[] = "ffmpegsumo.dll";
-
-// Use a global to indicate whether the library has been initialized or not. We
-// rely on function level static initialization in InitializeMediaLibrary() to
-// guarantee this is only set once in a thread safe manner.
-static bool g_media_library_is_initialized = false;
-
-static bool InitializeMediaLibraryInternal(const base::FilePath& base_path) {
- DCHECK(!g_media_library_is_initialized);
-
+bool InitializeMediaLibraryInternal(const base::FilePath& module_dir) {
// LoadLibraryEx(..., LOAD_WITH_ALTERED_SEARCH_PATH) cannot handle
// relative path.
- if (!base_path.IsAbsolute())
+ if (!module_dir.IsAbsolute())
return false;
// Use alternate DLL search path so we don't load dependencies from the
// system path. Refer to http://crbug.com/35857
+ static const char kFFmpegDLL[] = "ffmpegsumo.dll";
HMODULE lib = ::LoadLibraryEx(
- base_path.AppendASCII(kFFmpegDLL).value().c_str(), NULL,
+ module_dir.AppendASCII(kFFmpegDLL).value().c_str(), NULL,
LOAD_WITH_ALTERED_SEARCH_PATH);
// Check that we loaded the library successfully.
- g_media_library_is_initialized = (lib != NULL);
- return g_media_library_is_initialized;
-}
-
-bool InitializeMediaLibrary(const base::FilePath& base_path) {
- static const bool kMediaLibraryInitialized =
- InitializeMediaLibraryInternal(base_path);
- DCHECK_EQ(kMediaLibraryInitialized, g_media_library_is_initialized);
- return kMediaLibraryInitialized;
-}
-
-void InitializeMediaLibraryForTesting() {
- base::FilePath file_path;
- CHECK(PathService::Get(base::DIR_EXE, &file_path));
- CHECK(InitializeMediaLibrary(file_path));
-}
-
-bool IsMediaLibraryInitialized() {
- return g_media_library_is_initialized;
+ return lib != NULL;
}
+} // namespace internal
} // namespace media
« no previous file with comments | « media/base/media_stub.cc ('k') | media/base/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698