Skip to content

Commit

Permalink
Rename all methods accessing Singleton<T> as GetInstance().
Browse files Browse the repository at this point in the history
This is in preparation to a subsequent CL where Singleton<T> will restrict access to only the type being made singleton.

I also moved pepper::ResourceTracker to a lazy instance since there were too many places in code where this class was being accessed from and this was a smaller change than renaming methods in that case.

BUG=65298
TEST=all existing tests should pass.

Review URL: http://codereview.chromium.org/5685007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68982 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
satish@chromium.org committed Dec 13, 2010
1 parent 1bc1c69 commit 8e8bb6d
Show file tree
Hide file tree
Showing 92 changed files with 220 additions and 196 deletions.
9 changes: 7 additions & 2 deletions app/active_window_watcher_x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@

static Atom kNetActiveWindowAtom = None;

// static
ActiveWindowWatcherX* ActiveWindowWatcherX::GetInstance() {
return Singleton<ActiveWindowWatcherX>::get();
}

// static
void ActiveWindowWatcherX::AddObserver(Observer* observer) {
Singleton<ActiveWindowWatcherX>::get()->observers_.AddObserver(observer);
GetInstance()->observers_.AddObserver(observer);
}

// static
void ActiveWindowWatcherX::RemoveObserver(Observer* observer) {
Singleton<ActiveWindowWatcherX>::get()->observers_.RemoveObserver(observer);
GetInstance()->observers_.RemoveObserver(observer);
}

ActiveWindowWatcherX::ActiveWindowWatcherX() {
Expand Down
2 changes: 2 additions & 0 deletions app/active_window_watcher_x.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class ActiveWindowWatcherX {
ActiveWindowWatcherX();
~ActiveWindowWatcherX();

static ActiveWindowWatcherX* GetInstance();

void Init();

// Sends a notification out through the NotificationService that the active
Expand Down
6 changes: 3 additions & 3 deletions app/surface/io_surface_support_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef CGLError (*CGLTexImageIOSurface2DProcPtr)(CGLContextObj ctx,

class IOSurfaceSupportImpl : public IOSurfaceSupport {
public:
static IOSurfaceSupportImpl* Initialize();
static IOSurfaceSupportImpl* GetInstance();

bool InitializedSuccessfully() {
return initialized_successfully_;
Expand Down Expand Up @@ -80,7 +80,7 @@ class IOSurfaceSupportImpl : public IOSurfaceSupport {
DISALLOW_COPY_AND_ASSIGN(IOSurfaceSupportImpl);
};

IOSurfaceSupportImpl* IOSurfaceSupportImpl::Initialize() {
IOSurfaceSupportImpl* IOSurfaceSupportImpl::GetInstance() {
IOSurfaceSupportImpl* impl = Singleton<IOSurfaceSupportImpl>::get();
if (impl->InitializedSuccessfully())
return impl;
Expand Down Expand Up @@ -259,7 +259,7 @@ IOSurfaceSupportImpl::~IOSurfaceSupportImpl() {
}

IOSurfaceSupport* IOSurfaceSupport::Initialize() {
return IOSurfaceSupportImpl::Initialize();
return IOSurfaceSupportImpl::GetInstance();
}

IOSurfaceSupport::IOSurfaceSupport() {
Expand Down
4 changes: 2 additions & 2 deletions base/debug/stack_trace_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace {
// just ignore it.
class SymbolContext {
public:
static SymbolContext* Get() {
static SymbolContext* GetInstance() {
// We use a leaky singleton because code may call this during process
// termination.
return
Expand Down Expand Up @@ -179,7 +179,7 @@ void StackTrace::PrintBacktrace() {
}

void StackTrace::OutputToStream(std::ostream* os) {
SymbolContext* context = SymbolContext::Get();
SymbolContext* context = SymbolContext::GetInstance();
DWORD error = context->init_error();
if (error != ERROR_SUCCESS) {
(*os) << "Error initializing symbols (" << error
Expand Down
12 changes: 8 additions & 4 deletions ceee/common/process_utils_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ ProcessCompatibilityCheck::ProcessCompatibilityCheck()
StandardInitialize();
}

// static
ProcessCompatibilityCheck* ProcessCompatibilityCheck::GetInstance() {
return Singleton<ProcessCompatibilityCheck>::get();
}

void ProcessCompatibilityCheck::StandardInitialize() {
HRESULT hr = S_OK;

Expand Down Expand Up @@ -199,8 +204,7 @@ HRESULT ProcessCompatibilityCheck::IsCompatible(HWND process_window,

HRESULT ProcessCompatibilityCheck::IsCompatible(DWORD process_id,
bool* is_compatible) {
ProcessCompatibilityCheck* instance
= Singleton<ProcessCompatibilityCheck>::get();
ProcessCompatibilityCheck* instance = GetInstance();

DCHECK(instance != NULL);
DCHECK(is_compatible != NULL);
Expand Down Expand Up @@ -306,7 +310,7 @@ void ProcessCompatibilityCheck::PatchState(
CloseHandleFuncType close_handle_func,
IsWOW64ProcessFuncType is_wow64_process_func) {
PatchState(open_process_func, close_handle_func, is_wow64_process_func);
Singleton<ProcessCompatibilityCheck>::get()->KnownStateInitialize(
GetInstance()->KnownStateInitialize(
system_type, current_process_wow64,
check_integrity, current_process_integrity);
}
Expand All @@ -324,7 +328,7 @@ void ProcessCompatibilityCheck::PatchState(

void ProcessCompatibilityCheck::ResetState() {
PatchState(OpenProcess, CloseHandle, IsWow64Process);
Singleton<ProcessCompatibilityCheck>::get()->StandardInitialize();
GetInstance()->StandardInitialize();
}

} // namespace com
2 changes: 2 additions & 0 deletions ceee/common/process_utils_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ HRESULT IsCurrentProcessUacElevated(bool* running_as_admin);
// with implementation.
class ProcessCompatibilityCheck {
public:
static ProcessCompatibilityCheck* GetInstance();

// Is the process associated with the given window compatible with the
// current process. If the call returns an error code, the value of
// *is_compatible is undefined.
Expand Down
6 changes: 2 additions & 4 deletions ceee/ie/broker/executors_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ ExecutorsManager* ExecutorsManager::GetInstance() {
}

bool ExecutorsManager::IsKnownWindow(HWND window) {
return Singleton<ExecutorsManager, ExecutorsManager::SingletonTraits>::get()->
IsKnownWindowImpl(window);
return GetInstance()->IsKnownWindowImpl(window);
}

bool ExecutorsManager::IsKnownWindowImpl(HWND window) {
Expand All @@ -86,8 +85,7 @@ bool ExecutorsManager::IsKnownWindowImpl(HWND window) {
}

HWND ExecutorsManager::FindTabChild(HWND window) {
return Singleton<ExecutorsManager, ExecutorsManager::SingletonTraits>::get()->
FindTabChildImpl(window);
return GetInstance()->FindTabChildImpl(window);
}

HWND ExecutorsManager::FindTabChildImpl(HWND window) {
Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class FlagsState {
void reset();

// Returns the singleton instance of this class
static FlagsState* instance() {
static FlagsState* GetInstance() {
return Singleton<FlagsState>::get();
}

Expand Down Expand Up @@ -467,7 +467,7 @@ Value* CreateChoiceData(const Experiment& experiment,
} // namespace

void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) {
FlagsState::instance()->ConvertFlagsToSwitches(prefs, command_line);
FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line);
}

ListValue* GetFlagsExperimentsData(PrefService* prefs) {
Expand Down Expand Up @@ -504,17 +504,17 @@ ListValue* GetFlagsExperimentsData(PrefService* prefs) {
}

bool IsRestartNeededToCommitChanges() {
return FlagsState::instance()->IsRestartNeededToCommitChanges();
return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
}

void SetExperimentEnabled(
PrefService* prefs, const std::string& internal_name, bool enable) {
FlagsState::instance()->SetExperimentEnabled(prefs, internal_name, enable);
FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable);
}

void RemoveFlagsSwitches(
std::map<std::string, CommandLine::StringType>* switch_list) {
FlagsState::instance()->RemoveFlagsSwitches(switch_list);
FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
}

int GetCurrentPlatform() {
Expand Down Expand Up @@ -683,7 +683,7 @@ namespace testing {
const char kMultiSeparator[] = "@";

void ClearState() {
FlagsState::instance()->reset();
FlagsState::GetInstance()->reset();
}

void SetExperiments(const Experiment* e, size_t count) {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/background_page_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void BackgroundPageTracker::RegisterPrefs(PrefService* prefs) {
}

// static
BackgroundPageTracker* BackgroundPageTracker::GetSingleton() {
BackgroundPageTracker* BackgroundPageTracker::GetInstance() {
return Singleton<BackgroundPageTracker>::get();
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/background_page_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BackgroundPageTracker : public NotificationObserver {
static void RegisterPrefs(PrefService* prefs);

// Convenience routine which gets the singleton object.
static BackgroundPageTracker* GetSingleton();
static BackgroundPageTracker* GetInstance();

// Returns the number of background apps/extensions currently loaded.
int GetBackgroundPageCount();
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/browser_about_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -764,14 +764,14 @@ void DxDiagNodeToHTML(std::string* output, const DxDiagNode& node) {
}

std::string AboutGpu() {
const GPUInfo& gpu_info = GpuProcessHostUIShim::Get()->gpu_info();
const GPUInfo& gpu_info = GpuProcessHostUIShim::GetInstance()->gpu_info();

std::string html;

html.append("<html><head><title>About GPU</title></head>\n");

if (gpu_info.progress() != GPUInfo::kComplete) {
GpuProcessHostUIShim::Get()->CollectGraphicsInfoAsynchronously();
GpuProcessHostUIShim::GetInstance()->CollectGraphicsInfoAsynchronously();

// If it's not fully initialized yet, set a timeout to reload the page.
html.append("<body onload=\"setTimeout('window.location.reload(true)',");
Expand Down Expand Up @@ -1166,11 +1166,11 @@ bool WillHandleBrowserAboutURL(GURL* url, Profile* profile) {

// Handle URLs to wreck the gpu process.
if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutGpuCrashURL)) {
GpuProcessHostUIShim::Get()->SendAboutGpuCrash();
GpuProcessHostUIShim::GetInstance()->SendAboutGpuCrash();
return true;
}
if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutGpuHangURL)) {
GpuProcessHostUIShim::Get()->SendAboutGpuHang();
GpuProcessHostUIShim::GetInstance()->SendAboutGpuHang();
return true;
}

Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/browser_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1598,8 +1598,9 @@ int BrowserMain(const MainFunctionParams& parameters) {
// TODO(hclam): Need to check for cloud print proxy too.
if (parsed_command_line.HasSwitch(switches::kEnableRemoting)) {
if (user_prefs->GetBoolean(prefs::kRemotingHasSetupCompleted)) {
ServiceProcessControl* control = ServiceProcessControlManager::instance()
->GetProcessControl(profile);
ServiceProcessControl* control =
ServiceProcessControlManager::GetInstance()->GetProcessControl(
profile);
control->Launch(NULL, NULL);
}
}
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/browser_process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ void BrowserProcessImpl::CreateLocalState() {
// in the plugin blacklist.
local_state_->RegisterListPref(prefs::kPluginsPluginsBlacklist);
pref_change_registrar_.Add(prefs::kPluginsPluginsBlacklist,
PluginUpdater::GetPluginUpdater());
PluginUpdater::GetInstance());

// Initialize and set up notifications for the printing enabled
// preference.
Expand Down Expand Up @@ -764,9 +764,9 @@ DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowserProcessImpl);
void BrowserProcessImpl::SetIPCLoggingEnabled(bool enable) {
// First enable myself.
if (enable)
IPC::Logging::current()->Enable();
IPC::Logging::GetInstance()->Enable();
else
IPC::Logging::current()->Disable();
IPC::Logging::GetInstance()->Disable();

// Now tell subprocesses. Messages to ChildProcess-derived
// processes must be done on the IO thread.
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/browser_shutdown.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void Shutdown() {
NewRunnableFunction(&ChromePluginLib::UnloadAllPlugins));

// Shutdown all IPC channels to service processes.
ServiceProcessControlManager::instance()->Shutdown();
ServiceProcessControlManager::GetInstance()->Shutdown();

// WARNING: During logoff/shutdown (WM_ENDSESSION) we may not have enough
// time to get here. If you have something that *must* happen on end session,
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/cert_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct MatchSecond {
};

// static
CertStore* CertStore::GetSharedInstance() {
CertStore* CertStore::GetInstance() {
return Singleton<CertStore>::get();
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/cert_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class CertStore : public NotificationObserver {
public:
// Returns the singleton instance of the CertStore.
static CertStore* GetSharedInstance();
static CertStore* GetInstance();

// Stores the specified cert and returns the id associated with it. The cert
// is associated to the specified RenderProcessHost.
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/certificate_viewer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

void ShowCertificateViewerByID(gfx::NativeWindow parent, int cert_id) {
scoped_refptr<net::X509Certificate> cert;
CertStore::GetSharedInstance()->RetrieveCert(cert_id, &cert);
CertStore::GetInstance()->RetrieveCert(cert_id, &cert);
if (!cert.get()) {
// The certificate was not found. Could be that the renderer crashed before
// we displayed the page info.
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_plugin_browsing_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "chrome/browser/browser_thread.h"
#include "chrome/common/notification_service.h"

CPBrowsingContextManager* CPBrowsingContextManager::Instance() {
CPBrowsingContextManager* CPBrowsingContextManager::GetInstance() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
return Singleton<CPBrowsingContextManager>::get();
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_plugin_browsing_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class URLRequestContext;
// Note: This class should be used on the IO thread only.
class CPBrowsingContextManager : public NotificationObserver {
public:
static CPBrowsingContextManager* Instance();
static CPBrowsingContextManager* GetInstance();

// Note: don't call these directly - use Instance() above. They are public
// so Singleton can access them.
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/chrome_plugin_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class PluginRequestInterceptor
return NULL;

CPBrowsingContext context =
CPBrowsingContextManager::Instance()->Lookup(request->context());
CPBrowsingContextManager::GetInstance()->Lookup(request->context());
scoped_ptr<ScopableCPRequest> cprequest(
new ScopableCPRequest(request->url().spec().c_str(),
request->method().c_str(),
Expand Down Expand Up @@ -156,7 +156,7 @@ class PluginRequestHandler : public PluginHelper,
: PluginHelper(plugin), cprequest_(cprequest), user_buffer_(NULL) {
cprequest_->data = this; // see FromCPRequest().

URLRequestContext* context = CPBrowsingContextManager::Instance()->
URLRequestContext* context = CPBrowsingContextManager::GetInstance()->
ToURLRequestContext(cprequest_->context);
// TODO(mpcomplete): remove fallback case when Gears support is prevalent.
if (!context)
Expand Down Expand Up @@ -386,7 +386,7 @@ void STDCALL CPB_SetKeepProcessAlive(CPID id, CPBool keep_alive) {
CPError STDCALL CPB_GetCookies(CPID id, CPBrowsingContext bcontext,
const char* url, char** cookies) {
CHECK(ChromePluginLib::IsPluginThread());
URLRequestContext* context = CPBrowsingContextManager::Instance()->
URLRequestContext* context = CPBrowsingContextManager::GetInstance()->
ToURLRequestContext(bcontext);
// TODO(mpcomplete): remove fallback case when Gears support is prevalent.
if (!context) {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/gview_request_interceptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptResponse(
}

net::URLRequest::Interceptor*
GViewRequestInterceptor::GetGViewRequestInterceptor() {
GViewRequestInterceptor::GetInstance() {
return Singleton<GViewRequestInterceptor>::get();
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/gview_request_interceptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class GViewRequestInterceptor : public net::URLRequest::Interceptor {
virtual net::URLRequestJob* MaybeInterceptResponse(net::URLRequest* request);

// Singleton accessor.
static net::URLRequest::Interceptor* GetGViewRequestInterceptor();
static net::URLRequest::Interceptor* GetInstance();

private:
friend struct DefaultSingletonTraits<GViewRequestInterceptor>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GViewRequestInterceptorTest : public testing::Test {
virtual void SetUp() {
net::URLRequest::RegisterProtocolFactory("http",
&GViewRequestInterceptorTest::Factory);
interceptor_ = GViewRequestInterceptor::GetGViewRequestInterceptor();
interceptor_ = GViewRequestInterceptor::GetInstance();
ASSERT_TRUE(PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path_));
}

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/dom_ui/conflicts_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ void ConflictsDOMHandler::HandleRequestModuleList(const ListValue* args) {
// This request is handled asynchronously. See Observe for when we reply back.
registrar_.Add(this, NotificationType::MODULE_LIST_ENUMERATED,
NotificationService::AllSources());
EnumerateModulesModel::GetSingleton()->ScanNow();
EnumerateModulesModel::GetInstance()->ScanNow();
}

void ConflictsDOMHandler::SendModuleList() {
EnumerateModulesModel* loaded_modules = EnumerateModulesModel::GetSingleton();
EnumerateModulesModel* loaded_modules = EnumerateModulesModel::GetInstance();
ListValue* list = loaded_modules->GetModuleList();
DictionaryValue results;
results.Set("moduleList", list);
Expand Down
Loading

0 comments on commit 8e8bb6d

Please sign in to comment.