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

Unified Diff: chrome/browser/browser_about_handler.cc

Issue 6461024: Revert 74292 - Splits ChromeURLDataManager into 2 chunks:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 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/browser_about_handler.h ('k') | chrome/browser/browser_about_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_about_handler.cc
===================================================================
--- chrome/browser/browser_about_handler.cc (revision 74293)
+++ chrome/browser/browser_about_handler.cc (working copy)
@@ -160,6 +160,9 @@
#endif
};
+// Points to the singleton AboutSource object, if any.
+ChromeURLDataManager::DataSource* about_source = NULL;
+
// When you type about:memory, it actually loads an intermediate URL that
// redirects you to the final page. This avoids the problem where typing
// "about:memory" on the new tab page or any other page where a process
@@ -689,9 +692,21 @@
AboutSource::AboutSource()
: DataSource(chrome::kAboutScheme, MessageLoop::current()) {
+ // This should be a singleton.
+ DCHECK(!about_source);
+ about_source = this;
+
+ // Add us to the global URL handler on the IO thread.
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ ChromeURLDataManager::GetInstance(),
+ &ChromeURLDataManager::AddDataSource,
+ make_scoped_refptr(this)));
}
AboutSource::~AboutSource() {
+ about_source = NULL;
}
void AboutSource::StartDataRequest(const std::string& path_raw,
@@ -1039,7 +1054,7 @@
return false;
// Anything else requires our special handler; make sure it's initialized.
- InitializeAboutDataSource(profile);
+ InitializeAboutDataSource();
// Special case about:memory to go through a redirect before ending up on
// the final page. See GetAboutMemoryRedirectResponse above for why.
@@ -1057,8 +1072,14 @@
return true;
}
-void InitializeAboutDataSource(Profile* profile) {
- profile->GetChromeURLDataManager()->AddDataSource(new AboutSource());
+void InitializeAboutDataSource() {
+ // We only need to register the AboutSource once and it is kept globally.
+ // There is currently no way to remove a data source.
+ static bool initialized = false;
+ if (!initialized) {
+ about_source = new AboutSource();
+ initialized = true;
+ }
}
// This function gets called with the fixed-up chrome: URLs, so we have to
« no previous file with comments | « chrome/browser/browser_about_handler.h ('k') | chrome/browser/browser_about_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698