Chromium Code Reviews| Index: chrome/browser/history/web_history_service.cc |
| diff --git a/chrome/browser/history/web_history_service.cc b/chrome/browser/history/web_history_service.cc |
| index 59912417f6c6d80adc52c12c87b29228d5328bb1..c81fce47c846429ff3806d6e18640de2644bf6ae 100644 |
| --- a/chrome/browser/history/web_history_service.cc |
| +++ b/chrome/browser/history/web_history_service.cc |
| @@ -53,6 +53,8 @@ class RequestImpl : public WebHistoryService::Request, |
| // Returns the contents of the response body received from the server. |
| const std::string& response_body() { return response_body_; } |
| + virtual bool is_pending() OVERRIDE { return is_pending_; } |
| + |
| private: |
| friend class history::WebHistoryService; |
| @@ -65,7 +67,8 @@ class RequestImpl : public WebHistoryService::Request, |
| url_(GURL(url)), |
| response_code_(0), |
| auth_retry_count_(0), |
| - callback_(callback) { |
| + callback_(callback), |
| + is_pending_(false) { |
| } |
| // Tells the request to do its thang. |
| @@ -76,6 +79,7 @@ class RequestImpl : public WebHistoryService::Request, |
| OAuth2TokenService* token_service = |
| OAuth2TokenServiceFactory::GetForProfile(profile_); |
| token_request_ = token_service->StartRequest(oauth_scopes, this); |
| + is_pending_ = true; |
| } |
| // content::URLFetcherDelegate interface. |
| @@ -98,6 +102,7 @@ class RequestImpl : public WebHistoryService::Request, |
| url_fetcher_->GetResponseAsString(&response_body_); |
| url_fetcher_.reset(); |
| callback_.Run(this, true); |
| + is_pending_ = false; |
| } |
| // OAuth2TokenService::Consumer interface. |
| @@ -120,6 +125,7 @@ class RequestImpl : public WebHistoryService::Request, |
| token_request_.reset(); |
| LOG(WARNING) << "Failed to get OAuth token: " << error.ToString(); |
| callback_.Run(this, false); |
| + is_pending_ = false; |
|
James Hawkins
2013/04/17 16:59:25
This seems fragile. Can we not use callback_ some
|
| } |
| // Helper for creating a new URLFetcher for the API request. |
| @@ -173,6 +179,9 @@ class RequestImpl : public WebHistoryService::Request, |
| // The callback to execute when the query is complete. |
| CompletionCallback callback_; |
| + |
| + // True if the request was started and has not yet completed, otherwise false. |
| + bool is_pending_; |
| }; |
| // Extracts a JSON-encoded HTTP response into a DictionaryValue. |