| 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_DRIVE_DRIVE_API_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_DRIVE_DRIVE_API_SERVICE_H_ |
| 6 #define CHROME_BROWSER_DRIVE_DRIVE_API_SERVICE_H_ | 6 #define CHROME_BROWSER_DRIVE_DRIVE_API_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 namespace drive { | 35 namespace drive { |
| 36 | 36 |
| 37 // This class provides Drive request calls using Drive V2 API. | 37 // This class provides Drive request calls using Drive V2 API. |
| 38 // Details of API call are abstracted in each request class and this class | 38 // Details of API call are abstracted in each request class and this class |
| 39 // works as a thin wrapper for the API. | 39 // works as a thin wrapper for the API. |
| 40 class DriveAPIService : public DriveServiceInterface, | 40 class DriveAPIService : public DriveServiceInterface, |
| 41 public google_apis::AuthServiceObserver { | 41 public google_apis::AuthServiceObserver { |
| 42 public: | 42 public: |
| 43 // |oauth2_token_service| is used for obtaining OAuth2 access tokens. | 43 // |oauth2_token_service| is used for obtaining OAuth2 access tokens. |
| 44 // |account_id| identifies account used to obtain OAuth2 access tokens. |
| 44 // |url_request_context_getter| is used to initialize URLFetcher. | 45 // |url_request_context_getter| is used to initialize URLFetcher. |
| 45 // |blocking_task_runner| is used to run blocking tasks (like parsing JSON). | 46 // |blocking_task_runner| is used to run blocking tasks (like parsing JSON). |
| 46 // |base_url| is used to generate URLs for communication with the drive API. | 47 // |base_url| is used to generate URLs for communication with the drive API. |
| 47 // |base_download_url| is used to generate URLs for downloading file from the | 48 // |base_download_url| is used to generate URLs for downloading file from the |
| 48 // drive API. | 49 // drive API. |
| 49 // |wapi_base_url| is used to generate URLs for shared_url. Unfortunately, | 50 // |wapi_base_url| is used to generate URLs for shared_url. Unfortunately, |
| 50 // the share_url is not yet supported on Drive API v2, so as a fallback, | 51 // the share_url is not yet supported on Drive API v2, so as a fallback, |
| 51 // we use GData WAPI. | 52 // we use GData WAPI. |
| 52 // |custom_user_agent| will be used for the User-Agent header in HTTP | 53 // |custom_user_agent| will be used for the User-Agent header in HTTP |
| 53 // requests issues through the service if the value is not empty. | 54 // requests issues through the service if the value is not empty. |
| 54 DriveAPIService( | 55 DriveAPIService( |
| 55 OAuth2TokenService* oauth2_token_service, | 56 OAuth2TokenService* oauth2_token_service, |
| 57 const std::string& account_id, |
| 56 net::URLRequestContextGetter* url_request_context_getter, | 58 net::URLRequestContextGetter* url_request_context_getter, |
| 57 base::TaskRunner* blocking_task_runner, | 59 base::TaskRunner* blocking_task_runner, |
| 58 const GURL& base_url, | 60 const GURL& base_url, |
| 59 const GURL& base_download_url, | 61 const GURL& base_download_url, |
| 60 const GURL& wapi_base_url, | 62 const GURL& wapi_base_url, |
| 61 const std::string& custom_user_agent); | 63 const std::string& custom_user_agent); |
| 62 virtual ~DriveAPIService(); | 64 virtual ~DriveAPIService(); |
| 63 | 65 |
| 64 // DriveServiceInterface Overrides | 66 // DriveServiceInterface Overrides |
| 65 virtual void Initialize() OVERRIDE; | 67 virtual void Initialize() OVERRIDE; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 const google_apis::GetResourceListCallback& callback) OVERRIDE; | 188 const google_apis::GetResourceListCallback& callback) OVERRIDE; |
| 187 virtual google_apis::CancelCallback GetRemainingResourceList( | 189 virtual google_apis::CancelCallback GetRemainingResourceList( |
| 188 const GURL& next_link, | 190 const GURL& next_link, |
| 189 const google_apis::GetResourceListCallback& callback) OVERRIDE; | 191 const google_apis::GetResourceListCallback& callback) OVERRIDE; |
| 190 | 192 |
| 191 private: | 193 private: |
| 192 // AuthServiceObserver override. | 194 // AuthServiceObserver override. |
| 193 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE; | 195 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE; |
| 194 | 196 |
| 195 OAuth2TokenService* oauth2_token_service_; | 197 OAuth2TokenService* oauth2_token_service_; |
| 198 std::string account_id_; |
| 196 net::URLRequestContextGetter* url_request_context_getter_; | 199 net::URLRequestContextGetter* url_request_context_getter_; |
| 197 scoped_refptr<base::TaskRunner> blocking_task_runner_; | 200 scoped_refptr<base::TaskRunner> blocking_task_runner_; |
| 198 scoped_ptr<google_apis::RequestSender> sender_; | 201 scoped_ptr<google_apis::RequestSender> sender_; |
| 199 ObserverList<DriveServiceObserver> observers_; | 202 ObserverList<DriveServiceObserver> observers_; |
| 200 google_apis::DriveApiUrlGenerator url_generator_; | 203 google_apis::DriveApiUrlGenerator url_generator_; |
| 201 google_apis::GDataWapiUrlGenerator wapi_url_generator_; | 204 google_apis::GDataWapiUrlGenerator wapi_url_generator_; |
| 202 const std::string custom_user_agent_; | 205 const std::string custom_user_agent_; |
| 203 | 206 |
| 204 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); | 207 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); |
| 205 }; | 208 }; |
| 206 | 209 |
| 207 } // namespace drive | 210 } // namespace drive |
| 208 | 211 |
| 209 #endif // CHROME_BROWSER_DRIVE_DRIVE_API_SERVICE_H_ | 212 #endif // CHROME_BROWSER_DRIVE_DRIVE_API_SERVICE_H_ |
| OLD | NEW |