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

Unified Diff: chrome/browser/dom_ui/chrome_url_data_manager.cc

Issue 350007: Convert chrome_url_data_manager (previously a global) into a Singleton. This (Closed)
Patch Set: Created 11 years, 2 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 | « chrome/browser/dom_ui/chrome_url_data_manager.h ('k') | chrome/browser/dom_ui/downloads_dom_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/chrome_url_data_manager.cc
diff --git a/chrome/browser/dom_ui/chrome_url_data_manager.cc b/chrome/browser/dom_ui/chrome_url_data_manager.cc
index 2f2959a5ab71e2f26a2b0152889c99f0a70d73bc..3da06c1549266e49b260e6b94a504fa24f98eb36 100644
--- a/chrome/browser/dom_ui/chrome_url_data_manager.cc
+++ b/chrome/browser/dom_ui/chrome_url_data_manager.cc
@@ -8,6 +8,7 @@
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/path_service.h"
+#include "base/singleton.h"
#include "base/string_util.h"
#include "base/thread.h"
#include "base/values.h"
@@ -30,9 +31,6 @@
// TODO(glen): Choose a better location for this.
static const char kChromeURLScheme[] = "chrome";
-// The single global instance of ChromeURLDataManager.
-ChromeURLDataManager chrome_url_data_manager;
-
// URLRequestChromeJob is a URLRequestJob that manages running chrome-internal
// resource requests asynchronously.
// It hands off URL requests to ChromeURLDataManager, which asynchronously
@@ -105,9 +103,10 @@ void RegisterURLRequestChromeJob() {
// all features of in-process Web Inspector and Console Debugger. For the
// time being we need to serve the same content from chrome://inspector
// for the Console Debugger and in-process Web Inspector.
- chrome_url_data_manager.AddFileSource("inspector", inspector_dir);
- chrome_url_data_manager.AddFileSource(chrome::kChromeUIDevToolsHost,
- inspector_dir);
+ Singleton<ChromeURLDataManager>()->AddFileSource("inspector",
+ inspector_dir);
+ Singleton<ChromeURLDataManager>()->AddFileSource(
+ chrome::kChromeUIDevToolsHost, inspector_dir);
}
URLRequest::RegisterProtocolFactory(kChromeURLScheme,
@@ -119,8 +118,9 @@ void RegisterURLRequestChromeJob() {
void UnregisterURLRequestChromeJob() {
FilePath inspector_dir;
if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) {
- chrome_url_data_manager.RemoveFileSource("inspector");
- chrome_url_data_manager.RemoveFileSource(chrome::kChromeUIDevToolsHost);
+ Singleton<ChromeURLDataManager>()->RemoveFileSource("inspector");
+ Singleton<ChromeURLDataManager>()->RemoveFileSource(
+ chrome::kChromeUIDevToolsHost);
}
}
@@ -164,8 +164,8 @@ bool ChromeURLDataManager::URLToFilePath(const GURL& url,
URLToRequest(url, &source_name, &relative_path);
FileSourceMap::const_iterator i(
- chrome_url_data_manager.file_sources_.find(source_name));
- if (i == chrome_url_data_manager.file_sources_.end())
+ Singleton<ChromeURLDataManager>()->file_sources_.find(source_name));
+ if (i == Singleton<ChromeURLDataManager>()->file_sources_.end())
return false;
*file_path = i->second.AppendASCII(relative_path);
@@ -275,7 +275,7 @@ void ChromeURLDataManager::DataSource::SendResponse(
RefCountedMemory* bytes) {
ChromeThread::PostTask(
ChromeThread::IO, FROM_HERE,
- NewRunnableMethod(&chrome_url_data_manager,
+ NewRunnableMethod(Singleton<ChromeURLDataManager>().get(),
&ChromeURLDataManager::DataAvailable,
request_id, scoped_refptr<RefCountedMemory>(bytes)));
}
@@ -350,7 +350,7 @@ URLRequestChromeJob::URLRequestChromeJob(URLRequest* request)
}
URLRequestChromeJob::~URLRequestChromeJob() {
- CHECK(!chrome_url_data_manager.HasPendingJob(this));
+ CHECK(!Singleton<ChromeURLDataManager>()->HasPendingJob(this));
}
void URLRequestChromeJob::Start() {
@@ -361,7 +361,7 @@ void URLRequestChromeJob::Start() {
}
void URLRequestChromeJob::Kill() {
- chrome_url_data_manager.RemoveRequest(this);
+ Singleton<ChromeURLDataManager>()->RemoveRequest(this);
}
bool URLRequestChromeJob::GetMimeType(std::string* mime_type) const {
@@ -421,7 +421,7 @@ void URLRequestChromeJob::StartAsync() {
if (!request_)
return;
- if (chrome_url_data_manager.StartRequest(request_->url(), this)) {
+ if (Singleton<ChromeURLDataManager>()->StartRequest(request_->url(), this)) {
NotifyHeadersComplete();
} else {
NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED,
« no previous file with comments | « chrome/browser/dom_ui/chrome_url_data_manager.h ('k') | chrome/browser/dom_ui/downloads_dom_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698