summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_about_handler.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-10 00:10:06 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-10 00:10:06 +0000
commit6c9881982a4c92146479c3e288ff9834a1a49379 (patch)
treec6385d4ea0ab2034bd90ef9a8d8adc87333e3b21 /chrome/browser/browser_about_handler.cc
parenta340f0e92c4293be6194316541ee6ba05f6f7a57 (diff)
downloadchromium_src-6c9881982a4c92146479c3e288ff9834a1a49379.zip
chromium_src-6c9881982a4c92146479c3e288ff9834a1a49379.tar.gz
chromium_src-6c9881982a4c92146479c3e288ff9834a1a49379.tar.bz2
Revert 74340 - Attempt 2 at: Splits ChromeURLDataManager into 2 chunks:
. ChromeURLDataManager is no longer a singleton and is always used on the UI thread. ChromeURLDataManager is now profile specific (you get from the profile). . ChromeURLDataManagerBackend handles the URLRequests and the DataSources. ChromeURLDataManagerBackend is created by ChromeURLRequestContext. All DataSources are now profile specific. There were two that wanted to be global, but have been converted. This differs from the version I landed in that there is now a NULL check in ChromeURLDataManager::DeleteDataSources. BUG=52022 71868 TEST=none TBR=willchan, evan, ahendrickson Review URL: http://codereview.chromium.org/6462036 TBR=sky@chromium.org Review URL: http://codereview.chromium.org/6478010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74384 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_about_handler.cc')
-rw-r--r--chrome/browser/browser_about_handler.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc
index c4747d9..9e7b48c 100644
--- a/chrome/browser/browser_about_handler.cc
+++ b/chrome/browser/browser_about_handler.cc
@@ -160,6 +160,9 @@ const char *kAllAboutPaths[] = {
#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 @@ std::string VersionNumberToString(uint32 value) {
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 @@ bool WillHandleBrowserAboutURL(GURL* url, Profile* profile) {
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 @@ bool WillHandleBrowserAboutURL(GURL* url, Profile* profile) {
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