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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 virtual google_apis::CancelCallback AuthorizeApp( | 179 virtual google_apis::CancelCallback AuthorizeApp( |
178 const std::string& resource_id, | 180 const std::string& resource_id, |
179 const std::string& app_id, | 181 const std::string& app_id, |
180 const google_apis::AuthorizeAppCallback& callback) OVERRIDE; | 182 const google_apis::AuthorizeAppCallback& callback) OVERRIDE; |
181 | 183 |
182 private: | 184 private: |
183 // AuthServiceObserver override. | 185 // AuthServiceObserver override. |
184 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE; | 186 virtual void OnOAuth2RefreshTokenChanged() OVERRIDE; |
185 | 187 |
186 OAuth2TokenService* oauth2_token_service_; | 188 OAuth2TokenService* oauth2_token_service_; |
| 189 std::string account_id_; |
187 net::URLRequestContextGetter* url_request_context_getter_; | 190 net::URLRequestContextGetter* url_request_context_getter_; |
188 scoped_refptr<base::TaskRunner> blocking_task_runner_; | 191 scoped_refptr<base::TaskRunner> blocking_task_runner_; |
189 scoped_ptr<google_apis::RequestSender> sender_; | 192 scoped_ptr<google_apis::RequestSender> sender_; |
190 ObserverList<DriveServiceObserver> observers_; | 193 ObserverList<DriveServiceObserver> observers_; |
191 google_apis::DriveApiUrlGenerator url_generator_; | 194 google_apis::DriveApiUrlGenerator url_generator_; |
192 google_apis::GDataWapiUrlGenerator wapi_url_generator_; | 195 google_apis::GDataWapiUrlGenerator wapi_url_generator_; |
193 const std::string custom_user_agent_; | 196 const std::string custom_user_agent_; |
194 | 197 |
195 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); | 198 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); |
196 }; | 199 }; |
197 | 200 |
198 } // namespace drive | 201 } // namespace drive |
199 | 202 |
200 #endif // CHROME_BROWSER_DRIVE_DRIVE_API_SERVICE_H_ | 203 #endif // CHROME_BROWSER_DRIVE_DRIVE_API_SERVICE_H_ |
OLD | NEW |