summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cancelable_request.h
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-25 23:14:46 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-25 23:14:46 +0000
commit42eb6b07c2791d8d13ec48ea3c92725eee4d94a2 (patch)
tree9c72c5052409725827617584d7891f1fcd5b5c9e /chrome/browser/cancelable_request.h
parent60aac62ddf3cc40741a824cae25ab190005513be (diff)
downloadchromium_src-42eb6b07c2791d8d13ec48ea3c92725eee4d94a2.zip
chromium_src-42eb6b07c2791d8d13ec48ea3c92725eee4d94a2.tar.gz
chromium_src-42eb6b07c2791d8d13ec48ea3c92725eee4d94a2.tar.bz2
Port some files in chrome/browser/ - part 1.
Review URL: http://codereview.chromium.org/11402 Patch from Pawel Hajdan Jr. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6007 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cancelable_request.h')
-rw-r--r--chrome/browser/cancelable_request.h28
1 files changed, 21 insertions, 7 deletions
diff --git a/chrome/browser/cancelable_request.h b/chrome/browser/cancelable_request.h
index 8513bcb..30e1a39 100644
--- a/chrome/browser/cancelable_request.h
+++ b/chrome/browser/cancelable_request.h
@@ -186,20 +186,20 @@ class CancelableRequestConsumerBase {
};
// Template for clients to use. It allows them to associate random "client
-// data" with a specific requst. The default value for this type is given in
-// |initial_t|. The type T should be small and easily copyable (like a pointer
+// data" with a specific request. The default value for this type is NULL.
+// The type T should be small and easily copyable (like a pointer
// or an integer).
-template<class T, T initial_t>
-class CancelableRequestConsumerT : public CancelableRequestConsumerBase {
+template<class T>
+class CancelableRequestConsumerTSimple : public CancelableRequestConsumerBase {
public:
- CancelableRequestConsumerT() {
+ CancelableRequestConsumerTSimple() {
}
// Cancel any outstanding requests so that we do not get called back after we
// are destroyed. As these requests are removed, the providers will call us
// back on OnRequestRemoved, which will then update the list. To iterate
// successfully while the list is changing out from under us, we make a copy.
- virtual ~CancelableRequestConsumerT() {
+ virtual ~CancelableRequestConsumerTSimple() {
CancelAllRequests();
}
@@ -273,11 +273,15 @@ class CancelableRequestConsumerT : public CancelableRequestConsumerBase {
};
typedef std::map<PendingRequest, T> PendingRequestList;
+ virtual T get_initial_t() const {
+ return NULL;
+ }
+
virtual void OnRequestAdded(CancelableRequestProvider* provider,
CancelableRequestProvider::Handle handle) {
DCHECK(pending_requests_.find(PendingRequest(provider, handle)) ==
pending_requests_.end());
- pending_requests_[PendingRequest(provider, handle)] = initial_t;
+ pending_requests_[PendingRequest(provider, handle)] = get_initial_t();
}
virtual void OnRequestRemoved(CancelableRequestProvider* provider,
@@ -296,6 +300,16 @@ class CancelableRequestConsumerT : public CancelableRequestConsumerBase {
PendingRequestList pending_requests_;
};
+// See CancelableRequestConsumerTSimple. The default value for T
+// is given in |initial_t|.
+template<class T, T initial_t>
+class CancelableRequestConsumerT : public CancelableRequestConsumerTSimple<T> {
+ protected:
+ virtual T get_initial_t() const {
+ return initial_t;
+ }
+};
+
// Some clients may not want to store data. Rather than do some complicated
// thing with virtual functions to allow some consumers to store extra data and
// some not to, we just define a default one that stores some dummy data.