| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_REQUEST_SENDER_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_REQUEST_SENDER_H_ |
| 6 #define CHROME_BROWSER_GOOGLE_APIS_REQUEST_SENDER_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_REQUEST_SENDER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // |custom_user_agent| will be used for the User-Agent header in HTTP | 39 // |custom_user_agent| will be used for the User-Agent header in HTTP |
| 40 // requests issued through the request sender if the value is not empty. | 40 // requests issued through the request sender if the value is not empty. |
| 41 RequestSender(Profile* profile, | 41 RequestSender(Profile* profile, |
| 42 net::URLRequestContextGetter* url_request_context_getter, | 42 net::URLRequestContextGetter* url_request_context_getter, |
| 43 const std::vector<std::string>& scopes, | 43 const std::vector<std::string>& scopes, |
| 44 const std::string& custom_user_agent); | 44 const std::string& custom_user_agent); |
| 45 virtual ~RequestSender(); | 45 virtual ~RequestSender(); |
| 46 | 46 |
| 47 AuthService* auth_service() { return auth_service_.get(); } | 47 AuthService* auth_service() { return auth_service_.get(); } |
| 48 | 48 |
| 49 net::URLRequestContextGetter* url_request_context_getter() const { |
| 50 return url_request_context_getter_; |
| 51 } |
| 52 |
| 49 // Prepares the object for use. | 53 // Prepares the object for use. |
| 50 virtual void Initialize(); | 54 virtual void Initialize(); |
| 51 | 55 |
| 52 // Starts a request implementing the AuthenticatedRequestInterface | 56 // Starts a request implementing the AuthenticatedRequestInterface |
| 53 // interface, and makes the request retry upon authentication failures by | 57 // interface, and makes the request retry upon authentication failures by |
| 54 // calling back to RetryRequest. The |request| object is owned by this | 58 // calling back to RetryRequest. The |request| object is owned by this |
| 55 // RequestSender. It will be deleted in RequestSender's destructor or | 59 // RequestSender. It will be deleted in RequestSender's destructor or |
| 56 // in RequestFinished(). | 60 // in RequestFinished(). |
| 57 // | 61 // |
| 58 // Returns a closure to cancel the request. The closure cancels the request | 62 // Returns a closure to cancel the request. The closure cancels the request |
| (...skipping 14 matching lines...) Expand all Loading... |
| 73 // Clears any authentication token and retries the request, which forces | 77 // Clears any authentication token and retries the request, which forces |
| 74 // an authentication token refresh. | 78 // an authentication token refresh. |
| 75 void RetryRequest(AuthenticatedRequestInterface* request); | 79 void RetryRequest(AuthenticatedRequestInterface* request); |
| 76 | 80 |
| 77 // Cancels the request. Used for implementing the returned closure of | 81 // Cancels the request. Used for implementing the returned closure of |
| 78 // StartRequestWithRetry. | 82 // StartRequestWithRetry. |
| 79 void CancelRequest( | 83 void CancelRequest( |
| 80 const base::WeakPtr<AuthenticatedRequestInterface>& request); | 84 const base::WeakPtr<AuthenticatedRequestInterface>& request); |
| 81 | 85 |
| 82 Profile* profile_; // Not owned. | 86 Profile* profile_; // Not owned. |
| 87 net::URLRequestContextGetter* url_request_context_getter_; // Not owned. |
| 83 | 88 |
| 84 scoped_ptr<AuthService> auth_service_; | 89 scoped_ptr<AuthService> auth_service_; |
| 85 std::set<AuthenticatedRequestInterface*> in_flight_requests_; | 90 std::set<AuthenticatedRequestInterface*> in_flight_requests_; |
| 86 const std::string custom_user_agent_; | 91 const std::string custom_user_agent_; |
| 87 | 92 |
| 88 base::ThreadChecker thread_checker_; | 93 base::ThreadChecker thread_checker_; |
| 89 | 94 |
| 90 // Note: This should remain the last member so it'll be destroyed and | 95 // Note: This should remain the last member so it'll be destroyed and |
| 91 // invalidate its weak pointers before any other members are destroyed. | 96 // invalidate its weak pointers before any other members are destroyed. |
| 92 base::WeakPtrFactory<RequestSender> weak_ptr_factory_; | 97 base::WeakPtrFactory<RequestSender> weak_ptr_factory_; |
| 93 | 98 |
| 94 DISALLOW_COPY_AND_ASSIGN(RequestSender); | 99 DISALLOW_COPY_AND_ASSIGN(RequestSender); |
| 95 }; | 100 }; |
| 96 | 101 |
| 97 } // namespace google_apis | 102 } // namespace google_apis |
| 98 | 103 |
| 99 #endif // CHROME_BROWSER_GOOGLE_APIS_REQUEST_SENDER_H_ | 104 #endif // CHROME_BROWSER_GOOGLE_APIS_REQUEST_SENDER_H_ |
| OLD | NEW |