summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-23 16:42:52 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-23 16:42:52 +0000
commitffe3d6fa42e9ca8743557a20db13c65d45baacf1 (patch)
tree3fabd1467b22480f6b21e2cb7d5f0677a940e42b /chrome
parent3de4ccf65c3987fb775cf2586e9c270edd03ea20 (diff)
downloadchromium_src-ffe3d6fa42e9ca8743557a20db13c65d45baacf1.zip
chromium_src-ffe3d6fa42e9ca8743557a20db13c65d45baacf1.tar.gz
chromium_src-ffe3d6fa42e9ca8743557a20db13c65d45baacf1.tar.bz2
Makes a handful of DataSources not replace the existing
DataSource. In the long term all DataSources should do this, but for now I've added a method that does it. I recently added the IsRegistered method thinking registration should look like: if (!contents->profile()->GetChromeURLDataManager()->IsRegistered( SomeSource::kSomeName)) { contents->profile()->GetChromeURLDataManager()->AddDataSource( new SomeSource()); } But this is too tedious. And long term we should make all sources replace the existing one. BUG=52022 TEST=none Review URL: http://codereview.chromium.org/6546078 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75752 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/sessions/session_restore_uitest.cc4
-rw-r--r--chrome/browser/webui/chrome_url_data_manager.cc9
-rw-r--r--chrome/browser/webui/chrome_url_data_manager.h20
-rw-r--r--chrome/browser/webui/chrome_url_data_manager_backend.cc5
-rw-r--r--chrome/browser/webui/new_tab_ui.cc4
-rw-r--r--chrome/browser/webui/new_tab_ui.h2
-rw-r--r--chrome/browser/webui/web_ui_favicon_source.cc6
-rw-r--r--chrome/browser/webui/web_ui_favicon_source.h4
-rw-r--r--chrome/browser/webui/web_ui_theme_source.cc4
-rw-r--r--chrome/browser/webui/web_ui_theme_source.h2
10 files changed, 39 insertions, 21 deletions
diff --git a/chrome/browser/sessions/session_restore_uitest.cc b/chrome/browser/sessions/session_restore_uitest.cc
index d79efa5..496f671 100644
--- a/chrome/browser/sessions/session_restore_uitest.cc
+++ b/chrome/browser/sessions/session_restore_uitest.cc
@@ -450,9 +450,7 @@ TEST_F(SessionRestoreUITest, TwoWindowsCloseOneRestoreOnlyOne) {
// process-per-site and process-per-site-instance, because we treat the new tab
// as a special case in process-per-site-instance so that it only ever uses one
// process.)
-//
-// Flaky: http://code.google.com/p/chromium/issues/detail?id=52022
-TEST_F(SessionRestoreUITest, FLAKY_ShareProcessesOnRestore) {
+TEST_F(SessionRestoreUITest, ShareProcessesOnRestore) {
if (ProxyLauncher::in_process_renderer()) {
// No point in running this test in single process mode.
return;
diff --git a/chrome/browser/webui/chrome_url_data_manager.cc b/chrome/browser/webui/chrome_url_data_manager.cc
index c560783..d7abed2 100644
--- a/chrome/browser/webui/chrome_url_data_manager.cc
+++ b/chrome/browser/webui/chrome_url_data_manager.cc
@@ -48,7 +48,6 @@ ChromeURLDataManager::~ChromeURLDataManager() {
void ChromeURLDataManager::AddDataSource(DataSource* source) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- registered_source_names_.insert(source->source_name());
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableFunction(AddDataSourceOnIOThread,
@@ -56,10 +55,6 @@ void ChromeURLDataManager::AddDataSource(DataSource* source) {
make_scoped_refptr(source)));
}
-bool ChromeURLDataManager::IsRegistered(const std::string& name) {
- return registered_source_names_.find(name) != registered_source_names_.end();
-}
-
// static
void ChromeURLDataManager::DeleteDataSources() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -149,6 +144,10 @@ MessageLoop* ChromeURLDataManager::DataSource::MessageLoopForRequestPath(
return message_loop_;
}
+bool ChromeURLDataManager::DataSource::ShouldReplaceExistingSource() const {
+ return true;
+}
+
// static
void ChromeURLDataManager::DataSource::SetFontAndTextDirection(
DictionaryValue* localized_strings) {
diff --git a/chrome/browser/webui/chrome_url_data_manager.h b/chrome/browser/webui/chrome_url_data_manager.h
index be4cab0..ec77efb 100644
--- a/chrome/browser/webui/chrome_url_data_manager.h
+++ b/chrome/browser/webui/chrome_url_data_manager.h
@@ -6,8 +6,6 @@
#define CHROME_BROWSER_WEBUI_CHROME_URL_DATA_MANAGER_H_
#pragma once
-#include <map>
-#include <set>
#include <string>
#include "base/ref_counted.h"
@@ -95,6 +93,15 @@ class ChromeURLDataManager {
const std::string& source_name() const { return source_name_; }
+ // Returns true if this DataSource should replace an existing DataSource
+ // with the same name that has already been registered. The default is
+ // true.
+ //
+ // WARNING: this is invoked on the IO thread.
+ //
+ // TODO: nuke this and convert all callers to not replace.
+ virtual bool ShouldReplaceExistingSource() const;
+
static void SetFontAndTextDirection(DictionaryValue* localized_strings);
protected:
@@ -144,9 +151,6 @@ class ChromeURLDataManager {
// destructed in the same thread as they are constructed (the UI thread).
void AddDataSource(DataSource* source);
- // Returns true if a DataSource has been added with the given name.
- bool IsRegistered(const std::string& name);
-
// Deletes any data sources no longer referenced. This is normally invoked
// for you, but can be invoked to force deletion (such as during shutdown).
static void DeleteDataSources();
@@ -165,12 +169,6 @@ class ChromeURLDataManager {
Profile* profile_;
- // Names of the DataSources that have been registered.
- // By caching this rather than accessing ChromeURLDataManagerBackend we avoid
- // a delay between when AddDataSource is invoked and when the IO thread
- // processes it.
- std::set<std::string> registered_source_names_;
-
// Lock used when accessing |data_sources_|.
static base::Lock delete_lock_;
diff --git a/chrome/browser/webui/chrome_url_data_manager_backend.cc b/chrome/browser/webui/chrome_url_data_manager_backend.cc
index fab67db..b49606b 100644
--- a/chrome/browser/webui/chrome_url_data_manager_backend.cc
+++ b/chrome/browser/webui/chrome_url_data_manager_backend.cc
@@ -178,8 +178,11 @@ void ChromeURLDataManagerBackend::AddDataSource(
ChromeURLDataManager::DataSource* source) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DataSourceMap::iterator i = data_sources_.find(source->source_name());
- if (i != data_sources_.end())
+ if (i != data_sources_.end()) {
+ if (!source->ShouldReplaceExistingSource())
+ return;
i->second->backend_ = NULL;
+ }
data_sources_[source->source_name()] = source;
source->backend_ = this;
}
diff --git a/chrome/browser/webui/new_tab_ui.cc b/chrome/browser/webui/new_tab_ui.cc
index 99a5e83..26acf50 100644
--- a/chrome/browser/webui/new_tab_ui.cc
+++ b/chrome/browser/webui/new_tab_ui.cc
@@ -598,3 +598,7 @@ void NewTabUI::NewTabHTMLSource::StartDataRequest(const std::string& path,
std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const {
return "text/html";
}
+
+bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const {
+ return false;
+}
diff --git a/chrome/browser/webui/new_tab_ui.h b/chrome/browser/webui/new_tab_ui.h
index a627a00..777643b 100644
--- a/chrome/browser/webui/new_tab_ui.h
+++ b/chrome/browser/webui/new_tab_ui.h
@@ -71,6 +71,8 @@ class NewTabUI : public WebUI,
virtual std::string GetMimeType(const std::string&) const;
+ virtual bool ShouldReplaceExistingSource() const;
+
// Setters and getters for first_run.
static void set_first_run(bool first_run) { first_run_ = first_run; }
static bool first_run() { return first_run_; }
diff --git a/chrome/browser/webui/web_ui_favicon_source.cc b/chrome/browser/webui/web_ui_favicon_source.cc
index e7f0d06..51e6d87 100644
--- a/chrome/browser/webui/web_ui_favicon_source.cc
+++ b/chrome/browser/webui/web_ui_favicon_source.cc
@@ -54,6 +54,12 @@ std::string WebUIFavIconSource::GetMimeType(const std::string&) const {
return "image/png";
}
+bool WebUIFavIconSource::ShouldReplaceExistingSource() const {
+ // Leave the existing DataSource in place, otherwise we'll drop any pending
+ // requests on the floor.
+ return false;
+}
+
void WebUIFavIconSource::OnFavIconDataAvailable(
FaviconService::Handle request_handle,
bool know_favicon,
diff --git a/chrome/browser/webui/web_ui_favicon_source.h b/chrome/browser/webui/web_ui_favicon_source.h
index 5a538fa..80f909a 100644
--- a/chrome/browser/webui/web_ui_favicon_source.h
+++ b/chrome/browser/webui/web_ui_favicon_source.h
@@ -30,6 +30,9 @@ class WebUIFavIconSource : public ChromeURLDataManager::DataSource {
virtual std::string GetMimeType(const std::string&) const;
+ virtual bool ShouldReplaceExistingSource() const;
+
+ private:
// Called when favicon data is available from the history backend.
void OnFavIconDataAvailable(FaviconService::Handle request_handle,
bool know_favicon,
@@ -37,7 +40,6 @@ class WebUIFavIconSource : public ChromeURLDataManager::DataSource {
bool expired,
GURL url);
- private:
// Sends the default favicon.
void SendDefaultResponse(int request_id);
diff --git a/chrome/browser/webui/web_ui_theme_source.cc b/chrome/browser/webui/web_ui_theme_source.cc
index 5a65bdd..1bdbfbe 100644
--- a/chrome/browser/webui/web_ui_theme_source.cc
+++ b/chrome/browser/webui/web_ui_theme_source.cc
@@ -94,6 +94,10 @@ MessageLoop* WebUIThemeSource::MessageLoopForRequestPath(
return DataSource::MessageLoopForRequestPath(path);
}
+bool WebUIThemeSource::ShouldReplaceExistingSource() const {
+ return false;
+}
+
////////////////////////////////////////////////////////////////////////////////
// WebUIThemeSource, private:
diff --git a/chrome/browser/webui/web_ui_theme_source.h b/chrome/browser/webui/web_ui_theme_source.h
index 3b1bb82..2f1febf 100644
--- a/chrome/browser/webui/web_ui_theme_source.h
+++ b/chrome/browser/webui/web_ui_theme_source.h
@@ -27,6 +27,8 @@ class WebUIThemeSource : public ChromeURLDataManager::DataSource {
// Used to tell ChromeURLDataManager which thread to handle the request on.
virtual MessageLoop* MessageLoopForRequestPath(const std::string& path) const;
+ virtual bool ShouldReplaceExistingSource() const;
+
protected:
virtual ~WebUIThemeSource();