diff options
author | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 10:27:36 +0000 |
---|---|---|
committer | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 10:27:36 +0000 |
commit | 8e7e7838f96d9e60a9f51ab448ceb58727ef0cfb (patch) | |
tree | e430daa7aac940c0d221912e32d8a5df9129851b /chrome/browser/cancelable_request.h | |
parent | 795d701b3266d3156f33ca6ce7836ace6d128b59 (diff) | |
download | chromium_src-8e7e7838f96d9e60a9f51ab448ceb58727ef0cfb.zip chromium_src-8e7e7838f96d9e60a9f51ab448ceb58727ef0cfb.tar.gz chromium_src-8e7e7838f96d9e60a9f51ab448ceb58727ef0cfb.tar.bz2 |
Improve example code for cancelable request -- pass consumer base class pointer in StartRequest as it is more general
Make a small optimization: passing an iterator in CancelRequestLocked rather than Handle can avoid a call to map::find()
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/650143
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39708 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cancelable_request.h')
-rw-r--r-- | chrome/browser/cancelable_request.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/chrome/browser/cancelable_request.h b/chrome/browser/cancelable_request.h index 2dc4b9b..28bc8ed 100644 --- a/chrome/browser/cancelable_request.h +++ b/chrome/browser/cancelable_request.h @@ -41,7 +41,7 @@ // typedef Callback1<int>::Type RequestCallbackType; // // Handle StartRequest(int some_input1, int some_input2, -// CancelableRequestConsumer* consumer, +// CancelableRequestConsumerBase* consumer, // RequestCallbackType* callback) { // scoped_refptr<CancelableRequest<RequestCallbackType> > request( // new CancelableRequest<RequestCallbackType>(callback)); @@ -137,14 +137,14 @@ class CancelableRequestProvider { void RequestCompleted(Handle handle); private: + typedef std::map<Handle, scoped_refptr<CancelableRequestBase> > + CancelableRequestMap; + // Only call this when you already have acquired pending_request_lock_. - void CancelRequestLocked(Handle handle); + void CancelRequestLocked(const CancelableRequestMap::iterator& item); friend class CancelableRequestBase; - typedef std::map<Handle, scoped_refptr<CancelableRequestBase> > - CancelableRequestMap; - Lock pending_request_lock_; // Lists all outstanding requests. Protected by the |lock_|. |