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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 const google_apis::GetResourceListCallback& callback) OVERRIDE; | 191 const google_apis::GetResourceListCallback& callback) OVERRIDE; |
190 virtual google_apis::CancelCallback GetRemainingResourceList( | 192 virtual google_apis::CancelCallback GetRemainingResourceList( |
191 const GURL& next_url, | 193 const GURL& next_url, |
192 const google_apis::GetResourceListCallback& callback) OVERRIDE; | 194 const google_apis::GetResourceListCallback& callback) OVERRIDE; |
193 | 195 |
194 private: | 196 private: |
195 // AuthServiceObserver override. | 197 // AuthServiceObserver override. |
196 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE; | 198 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE; |
197 | 199 |
198 OAuth2TokenService* oauth2_token_service_; | 200 OAuth2TokenService* oauth2_token_service_; |
| 201 std::string account_id_; |
199 net::URLRequestContextGetter* url_request_context_getter_; | 202 net::URLRequestContextGetter* url_request_context_getter_; |
200 scoped_refptr<base::TaskRunner> blocking_task_runner_; | 203 scoped_refptr<base::TaskRunner> blocking_task_runner_; |
201 scoped_ptr<google_apis::RequestSender> sender_; | 204 scoped_ptr<google_apis::RequestSender> sender_; |
202 ObserverList<DriveServiceObserver> observers_; | 205 ObserverList<DriveServiceObserver> observers_; |
203 google_apis::DriveApiUrlGenerator url_generator_; | 206 google_apis::DriveApiUrlGenerator url_generator_; |
204 google_apis::GDataWapiUrlGenerator wapi_url_generator_; | 207 google_apis::GDataWapiUrlGenerator wapi_url_generator_; |
205 const std::string custom_user_agent_; | 208 const std::string custom_user_agent_; |
206 | 209 |
207 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); | 210 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); |
208 }; | 211 }; |
209 | 212 |
210 } // namespace drive | 213 } // namespace drive |
211 | 214 |
212 #endif // CHROME_BROWSER_DRIVE_DRIVE_API_SERVICE_H_ | 215 #endif // CHROME_BROWSER_DRIVE_DRIVE_API_SERVICE_H_ |
OLD | NEW |