| Index: chrome/browser/webdata/web_data_request_manager.h
|
| diff --git a/chrome/browser/webdata/web_data_request_manager.h b/chrome/browser/webdata/web_data_request_manager.h
|
| index eab0c9bd1b7578cc6a215910d463fd1df0eff056..1e1db64a0d6395550ba6e96e7df7fb39e649eb3b 100644
|
| --- a/chrome/browser/webdata/web_data_request_manager.h
|
| +++ b/chrome/browser/webdata/web_data_request_manager.h
|
| @@ -31,8 +31,7 @@ class WebDataRequestManager;
|
| //////////////////////////////////////////////////////////////////////////////
|
| class WebDataRequest {
|
| public:
|
| - WebDataRequest(WebDataService* service,
|
| - WebDataServiceConsumer* consumer,
|
| + WebDataRequest(WebDataServiceConsumer* consumer,
|
| WebDataRequestManager* manager);
|
|
|
| virtual ~WebDataRequest();
|
| @@ -42,6 +41,9 @@ class WebDataRequest {
|
| // Retrieves the |consumer_| set in the constructor.
|
| WebDataServiceConsumer* GetConsumer() const;
|
|
|
| + // Retrieves the original message loop the of the request.
|
| + MessageLoop* GetMessageLoop() const;
|
| +
|
| // Returns |true| if the request was cancelled via the |Cancel()| method.
|
| bool IsCancelled() const;
|
|
|
| @@ -49,18 +51,20 @@ class WebDataRequest {
|
| // our consumer_ reference is invalid.
|
| void Cancel();
|
|
|
| - // Invoked by the service when this request has been completed.
|
| - // This will notify the service in whatever thread was used to create this
|
| - // request.
|
| - void RequestComplete();
|
| + // Invoked when the request has been completed.
|
| + void OnComplete();
|
|
|
| // The result is owned by the request.
|
| void SetResult(scoped_ptr<WDTypedResult> r);
|
| - const WDTypedResult* GetResult() const;
|
| +
|
| + // Transfers ownership pof result to caller. Should only be called once per
|
| + // result.
|
| + scoped_ptr<WDTypedResult> GetResult();
|
|
|
| private:
|
| - // Used to notify service of request completion.
|
| - scoped_refptr<WebDataService> service_;
|
| + // Used to notify manager if request is cancelled. Uses a raw ptr instead of
|
| + // a ref_ptr so that it can be set to NULL when a request is cancelled.
|
| + WebDataRequestManager* manager_;
|
|
|
| // Tracks loop that the request originated on.
|
| MessageLoop* message_loop_;
|
| @@ -89,17 +93,16 @@ class WebDataRequest {
|
| //
|
| // Note: This is an internal interface, not to be used outside of webdata/
|
| //////////////////////////////////////////////////////////////////////////////
|
| -class WebDataRequestManager {
|
| +class WebDataRequestManager
|
| + : public base::RefCountedThreadSafe<WebDataRequestManager> {
|
| public:
|
| WebDataRequestManager();
|
|
|
| - ~WebDataRequestManager();
|
| -
|
| // Cancel any pending request.
|
| void CancelRequest(WebDataServiceBase::Handle h);
|
|
|
| - // Invoked by request implementations when a request has been processed.
|
| - void RequestCompleted(WebDataServiceBase::Handle h);
|
| + // Invoked by the WebDataService when |request| has been completed.
|
| + void RequestCompleted(scoped_ptr<WebDataRequest> request);
|
|
|
| // Register the request as a pending request.
|
| void RegisterRequest(WebDataRequest* request);
|
| @@ -108,6 +111,14 @@ class WebDataRequestManager {
|
| int GetNextRequestHandle();
|
|
|
| private:
|
| + friend class base::RefCountedThreadSafe<WebDataRequestManager>;
|
| +
|
| + ~WebDataRequestManager();
|
| +
|
| + // This will notify the consumer in whatever thread was used to create this
|
| + // request.
|
| + void RequestCompletedOnThread(scoped_ptr<WebDataRequest> request);
|
| +
|
| // A lock to protect pending requests and next request handle.
|
| base::Lock pending_lock_;
|
|
|
|
|