diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-09 08:15:04 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-09 08:15:04 +0000 |
commit | d3c6c0d77db083fbb68f81589acf4fc7c58a1fad (patch) | |
tree | c4f00bd9c7205cd3ec60533e86e2e2023acc6b83 /chrome/browser/renderer_host | |
parent | ee16679f293ca27ce3d822a97efad7d3fa8a049e (diff) | |
download | chromium_src-d3c6c0d77db083fbb68f81589acf4fc7c58a1fad.zip chromium_src-d3c6c0d77db083fbb68f81589acf4fc7c58a1fad.tar.gz chromium_src-d3c6c0d77db083fbb68f81589acf4fc7c58a1fad.tar.bz2 |
Add a new GetInstance() method for singleton classes used in chrome/browser files.
This CL includes half of the files under chrome/browser using Singleton<T>.
The rest of the files will be sent in a second CL.
In one case I used a LazyInstance<T> instead of Singleton<T> as that was simpler and necessary since T was a typedef and can't add member functions to it.
BUG=65298
TEST=all existing tests should continue to pass.
Review URL: http://codereview.chromium.org/5519016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68723 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
4 files changed, 14 insertions, 4 deletions
diff --git a/chrome/browser/renderer_host/render_sandbox_host_linux.cc b/chrome/browser/renderer_host/render_sandbox_host_linux.cc index 92105b4..51fa55b 100644 --- a/chrome/browser/renderer_host/render_sandbox_host_linux.cc +++ b/chrome/browser/renderer_host/render_sandbox_host_linux.cc @@ -23,6 +23,7 @@ #include "base/process_util.h" #include "base/scoped_ptr.h" #include "base/shared_memory.h" +#include "base/singleton.h" #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/unix_domain_socket_posix.h" @@ -643,6 +644,11 @@ RenderSandboxHostLinux::RenderSandboxHostLinux() pid_(0) { } +// static +RenderSandboxHostLinux* RenderSandboxHostLinux::GetInstance() { + return Singleton<RenderSandboxHostLinux>::get(); +} + void RenderSandboxHostLinux::Init(const std::string& sandbox_path) { DCHECK(!initialized_); initialized_ = true; diff --git a/chrome/browser/renderer_host/render_sandbox_host_linux.h b/chrome/browser/renderer_host/render_sandbox_host_linux.h index b0122e8..2cb0604 100644 --- a/chrome/browser/renderer_host/render_sandbox_host_linux.h +++ b/chrome/browser/renderer_host/render_sandbox_host_linux.h @@ -11,12 +11,16 @@ #include <string> #include "base/logging.h" -#include "base/singleton.h" + +template <typename T> struct DefaultSingletonTraits; // This is a singleton object which handles sandbox requests from the // renderers. class RenderSandboxHostLinux { public: + // Returns the singleton instance. + static RenderSandboxHostLinux* GetInstance(); + // Get the file descriptor which renderers should be given in order to signal // crashes to the browser. int GetRendererSocket() const { diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index c9ae516..e319e36 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -153,7 +153,7 @@ RenderViewHost::~RenderViewHost() { delegate()->RenderViewDeleted(this); // Be sure to clean up any leftover state from cross-site requests. - Singleton<CrossSiteRequestManager>()->SetHasPendingCrossSiteRequest( + CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( process()->id(), routing_id(), false); } @@ -368,7 +368,7 @@ void RenderViewHost::ClosePageIgnoringUnloadEvents() { void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request, int request_id) { - Singleton<CrossSiteRequestManager>()->SetHasPendingCrossSiteRequest( + CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( process()->id(), routing_id(), has_pending_request); pending_request_id_ = request_id; } diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index 9555ebc..4e6ecab 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -478,7 +478,7 @@ void ResourceDispatcherHost::BeginRequest( // not count as cross-site, otherwise it gets blocked indefinitely. if (request_data.resource_type == ResourceType::MAIN_FRAME && process_type == ChildProcessInfo::RENDER_PROCESS && - Singleton<CrossSiteRequestManager>::get()-> + CrossSiteRequestManager::GetInstance()-> HasPendingCrossSiteRequest(child_id, route_id)) { // Wrap the event handler to be sure the current page's onunload handler // has a chance to run before we render the new page. |