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

Unified Diff: chrome/browser/ui/webui/chrome_url_data_manager_backend.cc

Issue 11885021: Don't derive from ChromeURLDataManager::DataSource, and instead have these classes implement a dele… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: nits Created 7 years, 11 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
Index: chrome/browser/ui/webui/chrome_url_data_manager_backend.cc
===================================================================
--- chrome/browser/ui/webui/chrome_url_data_manager_backend.cc (revision 176443)
+++ chrome/browser/ui/webui/chrome_url_data_manager_backend.cc (working copy)
@@ -390,11 +390,11 @@
// After that, notifies |job| that mime type is available. This method
// should be called on the UI thread, but notification is performed on
// the IO thread.
-void GetMimeTypeOnUI(ChromeURLDataManager::DataSource* source,
+void GetMimeTypeOnUI(URLDataSource* source,
const std::string& path,
const base::WeakPtr<URLRequestChromeJob>& job) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- std::string mime_type = source->GetMimeType(path);
+ std::string mime_type = source->delegate()->GetMimeType(path);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&URLRequestChromeJob::MimeTypeAvailable, job, mime_type));
@@ -439,7 +439,11 @@
ChromeURLDataManagerBackend::ChromeURLDataManagerBackend()
: next_request_id_(0) {
- AddDataSource(new SharedResourcesDataSource());
+ content::URLDataSourceDelegate* shared_source =
+ new SharedResourcesDataSource();
+ shared_source->url_data_source_ =
+ new URLDataSource(shared_source->GetSource(), shared_source);
+ AddDataSource(shared_source->url_data_source_);
}
ChromeURLDataManagerBackend::~ChromeURLDataManagerBackend() {
@@ -459,11 +463,11 @@
}
void ChromeURLDataManagerBackend::AddDataSource(
- ChromeURLDataManager::DataSource* source) {
+ URLDataSource* source) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DataSourceMap::iterator i = data_sources_.find(source->source_name());
if (i != data_sources_.end()) {
- if (!source->ShouldReplaceExistingSource())
+ if (!source->delegate()->ShouldReplaceExistingSource())
return;
i->second->backend_ = NULL;
}
@@ -493,26 +497,28 @@
if (i == data_sources_.end())
return false;
- ChromeURLDataManager::DataSource* source = i->second;
+ URLDataSource* source = i->second;
// Save this request so we know where to send the data.
RequestID request_id = next_request_id_++;
pending_requests_.insert(std::make_pair(request_id, job));
- job->set_allow_caching(source->AllowCaching());
+ job->set_allow_caching(source->delegate()->AllowCaching());
const ChromeURLRequestContext* context =
static_cast<const ChromeURLRequestContext*>(job->request()->context());
// Forward along the request to the data source.
- MessageLoop* target_message_loop = source->MessageLoopForRequestPath(path);
+ MessageLoop* target_message_loop =
+ source->delegate()->MessageLoopForRequestPath(path);
if (!target_message_loop) {
- job->MimeTypeAvailable(source->GetMimeType(path));
+ job->MimeTypeAvailable(source->delegate()->GetMimeType(path));
// The DataSource is agnostic to which thread StartDataRequest is called
// on for this path. Call directly into it from this thread, the IO
// thread.
- source->StartDataRequest(path, context->is_incognito(), request_id);
+ source->delegate()->StartDataRequest(
+ path, context->is_incognito(), request_id);
} else {
// URLRequestChromeJob should receive mime type before data. This
// is guaranteed because request for mime type is placed in the
@@ -521,19 +527,28 @@
target_message_loop->PostTask(
FROM_HERE,
base::Bind(&GetMimeTypeOnUI,
- scoped_refptr<ChromeURLDataManager::DataSource>(source),
+ scoped_refptr<URLDataSource>(source),
path, job->AsWeakPtr()));
// The DataSource wants StartDataRequest to be called on a specific thread,
// usually the UI thread, for this path.
target_message_loop->PostTask(
FROM_HERE,
- base::Bind(&ChromeURLDataManager::DataSource::StartDataRequest, source,
- path, context->is_incognito(), request_id));
+ base::Bind(&ChromeURLDataManagerBackend::CallStartRequest,
+ make_scoped_refptr(source), path, context->is_incognito(),
+ request_id));
}
return true;
}
+void ChromeURLDataManagerBackend::CallStartRequest(
+ scoped_refptr<URLDataSource> source,
+ const std::string& path,
+ bool is_incognito,
+ int request_id) {
+ source->delegate()->StartDataRequest(path, is_incognito, request_id);
+}
+
void ChromeURLDataManagerBackend::RemoveRequest(URLRequestChromeJob* job) {
// Remove the request from our list of pending requests.
// If/when the source sends the data that was requested, the data will just

Powered by Google App Engine
This is Rietveld 408576698