diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-11 09:13:54 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-11 09:13:54 +0000 |
commit | 49ab556cfe14de363a74ce771931832304a1a038 (patch) | |
tree | 7703457c54a035f2eebe38babecaba12b6bfb975 /media/tools | |
parent | 0310169705d607a78bc288e74038fe104b4474fd (diff) | |
download | chromium_src-49ab556cfe14de363a74ce771931832304a1a038.zip chromium_src-49ab556cfe14de363a74ce771931832304a1a038.tar.gz chromium_src-49ab556cfe14de363a74ce771931832304a1a038.tar.bz2 |
Make members of Singleton<T> private and only visible to the singleton type. This enforces that the Singleton<T> pattern can only be used within classes which want singleton-ness.
As part of this CL I have also fixed up files which got missed in my previous CLs to use a GetInstance() method and use Singleton<T> from the source file.
There are a small number of places where I have also switched to LazyInstance as that was more appropriate for types used in a single source file.
BUG=65298
TEST=all existing tests should continue to pass.
Review URL: http://codereview.chromium.org/5682008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68932 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/tools')
-rw-r--r-- | media/tools/player_wtl/mainfrm.h | 61 | ||||
-rw-r--r-- | media/tools/player_wtl/movie.cc | 5 | ||||
-rw-r--r-- | media/tools/player_wtl/movie.h | 7 | ||||
-rw-r--r-- | media/tools/player_wtl/player_wtl.cc | 2 | ||||
-rw-r--r-- | media/tools/player_wtl/props.h | 2 | ||||
-rw-r--r-- | media/tools/player_wtl/seek.h | 8 | ||||
-rw-r--r-- | media/tools/player_wtl/view.h | 5 |
7 files changed, 50 insertions, 40 deletions
diff --git a/media/tools/player_wtl/mainfrm.h b/media/tools/player_wtl/mainfrm.h index f92a97d..6c73957 100644 --- a/media/tools/player_wtl/mainfrm.h +++ b/media/tools/player_wtl/mainfrm.h @@ -61,10 +61,10 @@ class CMainFrame : public CFrameWindowImpl<CMainFrame>, virtual BOOL OnIdle() { BOOL bEnable = !m_view.bmp_.IsNull(); - BOOL bMovieOpen = media::Movie::get()->IsOpen() ? true : false; + BOOL bMovieOpen = media::Movie::GetInstance()->IsOpen() ? true : false; - float current_position = media::Movie::get()->GetPosition(); - float duration = media::Movie::get()->GetDuration(); + float current_position = media::Movie::GetInstance()->GetPosition(); + float duration = media::Movie::GetInstance()->GetDuration(); if (enable_exit && bEnable && duration > 0.0f && current_position >= duration) { OnFileExit(0, 0, 0); @@ -304,8 +304,8 @@ class CMainFrame : public CFrameWindowImpl<CMainFrame>, } void UpdateSpeedUICheck() { - if (media::Movie::get()) { - float play_rate = media::Movie::get()->GetPlayRate(); + if (media::Movie::GetInstance()) { + float play_rate = media::Movie::GetInstance()->GetPlayRate(); UISetCheck(ID_PLAY_HALFSPEED, (play_rate == 0.5f)); UISetCheck(ID_PLAY_NORMALSPEED, (play_rate == 1.0f)); UISetCheck(ID_PLAY_DOUBLESPEED, (play_rate == 2.0f)); @@ -422,10 +422,10 @@ class CMainFrame : public CFrameWindowImpl<CMainFrame>, TogglePrintPreview(); // If a movie is open, close it. - media::Movie::get()->Close(); + media::Movie::GetInstance()->Close(); if (IsMovie(file_name)) { - success = media::Movie::get()->Open(file_name, m_view.renderer_); + success = media::Movie::GetInstance()->Open(file_name, m_view.renderer_); } else { HBITMAP hbmp = NULL; hbmp = (HBITMAP)::LoadImage(NULL, file_name, IMAGE_BITMAP, 0, 0, @@ -590,7 +590,7 @@ class CMainFrame : public CFrameWindowImpl<CMainFrame>, if (m_bPrintPreview) TogglePrintPreview(); - media::Movie::get()->Close(); + media::Movie::GetInstance()->Close(); m_view.Reset(); UpdateTitleBar(NULL); m_szFilePath[0] = 0; @@ -643,44 +643,44 @@ class CMainFrame : public CFrameWindowImpl<CMainFrame>, } void OnPlayPlayPause(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/) { - bool paused = !media::Movie::get()->GetPause(); - media::Movie::get()->SetPause(paused); + bool paused = !media::Movie::GetInstance()->GetPause(); + media::Movie::GetInstance()->SetPause(paused); } void OnPlayStepForward(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/) { - float current_position = media::Movie::get()->GetPosition(); - media::Movie::get()->SetPosition(current_position + 10.0f); + float current_position = media::Movie::GetInstance()->GetPosition(); + media::Movie::GetInstance()->SetPosition(current_position + 10.0f); } void OnPlayStepBackward(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/) { - float current_position = media::Movie::get()->GetPosition(); - media::Movie::get()->SetPosition(current_position - 10.0f); + float current_position = media::Movie::GetInstance()->GetPosition(); + media::Movie::GetInstance()->SetPosition(current_position - 10.0f); } void OnPlayGotoStart(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/) { - media::Movie::get()->SetPosition(0.0); + media::Movie::GetInstance()->SetPosition(0.0); } void OnPlayGotoEnd(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/) { - float current_position = media::Movie::get()->GetDuration(); - media::Movie::get()->SetPosition(current_position - 30.0f); + float current_position = media::Movie::GetInstance()->GetDuration(); + media::Movie::GetInstance()->SetPosition(current_position - 30.0f); } void SetPlayRate(int play_speed) { if (play_speed == 0) { - media::Movie::get()->Play(0.5f); + media::Movie::GetInstance()->Play(0.5f); } else if (play_speed == 2) { - media::Movie::get()->Play(2.0f); + media::Movie::GetInstance()->Play(2.0f); } else if (play_speed == 3) { - media::Movie::get()->Play(3.0f); + media::Movie::GetInstance()->Play(3.0f); } else if (play_speed == 4) { - media::Movie::get()->Play(4.0f); + media::Movie::GetInstance()->Play(4.0f); } else if (play_speed == 5) { - media::Movie::get()->Play(8.0f); + media::Movie::GetInstance()->Play(8.0f); } else if (play_speed == 6) { - media::Movie::get()->Play(16.0f); + media::Movie::GetInstance()->Play(16.0f); } else { - media::Movie::get()->Play(1.0f); + media::Movie::GetInstance()->Play(1.0f); } } @@ -699,22 +699,23 @@ class CMainFrame : public CFrameWindowImpl<CMainFrame>, } void OnOptionsDraw(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/) { - bool enable_draw = !media::Movie::get()->GetDrawEnable(); - media::Movie::get()->SetDrawEnable(enable_draw); + bool enable_draw = !media::Movie::GetInstance()->GetDrawEnable(); + media::Movie::GetInstance()->SetDrawEnable(enable_draw); UISetCheck(ID_OPTIONS_DRAW, enable_draw); UpdateLayout(); } void OnOptionsAudio(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/) { - bool enable_audio = !media::Movie::get()->GetAudioEnable(); - media::Movie::get()->SetAudioEnable(enable_audio); + bool enable_audio = !media::Movie::GetInstance()->GetAudioEnable(); + media::Movie::GetInstance()->SetAudioEnable(enable_audio); UISetCheck(ID_OPTIONS_AUDIO, enable_audio); UpdateLayout(); } void OnOptionsDumpYUVFile(UINT /*uNotify*/, int /*nID*/, CWindow /*wnd*/) { - bool enable_dump_yuv_file = !media::Movie::get()->GetDumpYuvFileEnable(); - media::Movie::get()->SetDumpYuvFileEnable(enable_dump_yuv_file); + bool enable_dump_yuv_file = + !media::Movie::GetInstance()->GetDumpYuvFileEnable(); + media::Movie::GetInstance()->SetDumpYuvFileEnable(enable_dump_yuv_file); UISetCheck(ID_OPTIONS_DUMPYUVFILE, enable_dump_yuv_file); UpdateLayout(); } diff --git a/media/tools/player_wtl/movie.cc b/media/tools/player_wtl/movie.cc index 70ede51..7a06cb9 100644 --- a/media/tools/player_wtl/movie.cc +++ b/media/tools/player_wtl/movie.cc @@ -4,6 +4,7 @@ #include "media/tools/player_wtl/movie.h" +#include "base/singleton.h" #include "base/utf_string_conversions.h" #include "media/base/filter_collection.h" #include "media/base/pipeline_impl.h" @@ -39,6 +40,10 @@ Movie::Movie() Movie::~Movie() { } +Movie* Movie::GetInstance() { + return Singleton<Movie>::get(); +} + bool Movie::IsOpen() { return pipeline_ != NULL; } diff --git a/media/tools/player_wtl/movie.h b/media/tools/player_wtl/movie.h index e505165..581a0db 100644 --- a/media/tools/player_wtl/movie.h +++ b/media/tools/player_wtl/movie.h @@ -11,17 +11,20 @@ #include "base/ref_counted.h" #include "base/scoped_ptr.h" -#include "base/singleton.h" #include "base/thread.h" +template <typename T> struct DefaultSingletonTraits; class WtlVideoRenderer; namespace media { class PipelineImpl; -class Movie : public Singleton<Movie> { +class Movie { public: + // Returns the singleton instance. + static Movie* GetInstance(); + // Open a movie. bool Open(const wchar_t* url, WtlVideoRenderer* video_renderer); diff --git a/media/tools/player_wtl/player_wtl.cc b/media/tools/player_wtl/player_wtl.cc index 8fe9f1b..b1dbabc 100644 --- a/media/tools/player_wtl/player_wtl.cc +++ b/media/tools/player_wtl/player_wtl.cc @@ -55,7 +55,7 @@ int Run(wchar_t* win_cmd_line, int cmd_show) { int result = the_loop.Run(); - media::Movie::get()->Close(); + media::Movie::GetInstance()->Close(); g_module.RemoveMessageLoop(); return result; diff --git a/media/tools/player_wtl/props.h b/media/tools/player_wtl/props.h index 65224e5..d2b7dbb 100644 --- a/media/tools/player_wtl/props.h +++ b/media/tools/player_wtl/props.h @@ -124,7 +124,7 @@ class CPageOne : public CPropertyPageImpl<CPageOne> { SetDlgItemText(IDC_FILESIZE, szBuff); // TODO(fbarchard): We need a pipeline property for frame rate. - float duration = media::Movie::get()->GetDuration(); + float duration = media::Movie::GetInstance()->GetDuration(); float fps = 29.97f; wsprintf(szBuff, L"%i.%2i Seconds, %i Frames", static_cast<int>(duration), diff --git a/media/tools/player_wtl/seek.h b/media/tools/player_wtl/seek.h index 84f3c95..d5cf464 100644 --- a/media/tools/player_wtl/seek.h +++ b/media/tools/player_wtl/seek.h @@ -34,12 +34,12 @@ class CSeek : public CSimpleDialog<IDD_SEEK>, BOOL& bHandled) { static float previous_position = -1.0f; - float position = media::Movie::get()->GetPosition(); + float position = media::Movie::GetInstance()->GetPosition(); if (static_cast<int>(position * 10) != static_cast<int>(previous_position * 10)) { previous_position = position; wchar_t szBuff[200]; - float duration = media::Movie::get()->GetDuration(); + float duration = media::Movie::GetInstance()->GetDuration(); float fps = 29.97f; wsprintf(szBuff, L"%i.%i / %i.%i, %i / %i", static_cast<int>(position), @@ -58,8 +58,8 @@ class CSeek : public CSimpleDialog<IDD_SEEK>, virtual BOOL OnIdle() { wchar_t szBuff[200]; - float position = media::Movie::get()->GetPosition(); - float duration = media::Movie::get()->GetDuration(); + float position = media::Movie::GetInstance()->GetPosition(); + float duration = media::Movie::GetInstance()->GetDuration(); // TODO(fbarchard): Use frame rate property when it exists. float fps = 29.97f; wsprintf(szBuff, L"%i.%i / %i.%i, %i / %i", diff --git a/media/tools/player_wtl/view.h b/media/tools/player_wtl/view.h index dd1aaaf..cbb0a48 100644 --- a/media/tools/player_wtl/view.h +++ b/media/tools/player_wtl/view.h @@ -182,7 +182,8 @@ class WtlVideoWindow : public CScrollWindowImpl<WtlVideoWindow> { } // Append each frame to end of file. - bool enable_dump_yuv_file = media::Movie::get()->GetDumpYuvFileEnable(); + bool enable_dump_yuv_file = + media::Movie::GetInstance()->GetDumpYuvFileEnable(); if (enable_dump_yuv_file) { DumpYUV(video_frame); } @@ -191,7 +192,7 @@ class WtlVideoWindow : public CScrollWindowImpl<WtlVideoWindow> { double yuv_time_start = GetTime(); // Start timer. #endif - bool enable_draw = media::Movie::get()->GetDrawEnable(); + bool enable_draw = media::Movie::GetInstance()->GetDrawEnable(); if (enable_draw) { DCHECK(bm.bmBitsPixel == 32); DrawYUV(video_frame, |