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

Unified Diff: content/public/browser/url_data_source.h

Issue 11881055: Simplify WebUI data sources. Currently WebUI data sources implement a URLDataSourceDelegate interfa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix issue in about_ui exposed by cros tests 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
« no previous file with comments | « content/content_browser.gypi ('k') | content/public/browser/url_data_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/browser/url_data_source.h
===================================================================
--- content/public/browser/url_data_source.h (revision 176717)
+++ content/public/browser/url_data_source.h (working copy)
@@ -8,33 +8,42 @@
#include <string>
#include "content/common/content_export.h"
+#include "base/callback.h"
tfarina 2013/01/16 03:01:51 sort
-class ChromeURLDataManager;
-class ChromeURLDataManagerBackend;
-class ChromeWebUIDataSource;
class MessageLoop;
-class URLDataSource;
+namespace base {
+class RefCountedMemory;
+}
+
namespace content {
-// An interface implemented by a creator of URLDataSource to customize its
-// behavior.
-class CONTENT_EXPORT URLDataSourceDelegate {
+// A URLDataSource is an object that can answer requests for data
+// asynchronously. An implementation of URLDataSource should handle calls to
+// StartDataRequest() by starting its (implementation-specific) asynchronous
+// request for the data, then running the callback given in that method to
+// notify.
+class CONTENT_EXPORT URLDataSource {
public:
- URLDataSourceDelegate();
- virtual ~URLDataSourceDelegate();
+ // Used by StartDataRequest. The string parameter is the path of the request.
+ // If the callee doesn't want to handle the data, false is returned. Otherwise
+ // true is returned and the GotDataCallback parameter is called either then or
+ // asynchronously with the response.
+ typedef base::Callback<void(base::RefCountedMemory*)> GotDataCallback;
+ virtual ~URLDataSource() {}
+
// The name of this source.
// E.g., for favicons, this could be "favicon", which results in paths for
// specific resources like "favicon/34" getting sent to this source.
virtual std::string GetSource() = 0;
// Called by URLDataSource to request data at |path|. The delegate should
- // call URLDataSource::SendResponse() when the data is available or if the
- // request could not be satisfied.
+ // run |callback| when the data is available or if the request could not be
+ // satisfied.
virtual void StartDataRequest(const std::string& path,
bool is_incognito,
- int request_id) = 0;
+ const GotDataCallback& callback) = 0;
// Return the mimetype that should be sent with this response, or empty
// string to specify no mime type.
@@ -60,19 +69,6 @@
// Returns true if responses from this URLDataSource can be cached.
virtual bool AllowCaching() const;
-
- void set_url_data_source_for_testing(URLDataSource* url_data_source) {
- url_data_source_ = url_data_source;
- }
-
- protected:
- URLDataSource* url_data_source() { return url_data_source_; }
-
- private:
- friend class ::ChromeURLDataManager;
- friend class ::ChromeURLDataManagerBackend;
- friend class ::ChromeWebUIDataSource;
- URLDataSource* url_data_source_;
};
} // namespace content
« no previous file with comments | « content/content_browser.gypi ('k') | content/public/browser/url_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698