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" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
14 #include "chrome/browser/drive/drive_service_interface.h" | 14 #include "chrome/browser/drive/drive_service_interface.h" |
15 #include "google_apis/drive/auth_service_interface.h" | 15 #include "google_apis/drive/auth_service_interface.h" |
16 #include "google_apis/drive/auth_service_observer.h" | 16 #include "google_apis/drive/auth_service_observer.h" |
17 #include "google_apis/drive/drive_api_url_generator.h" | 17 #include "google_apis/drive/drive_api_url_generator.h" |
18 #include "google_apis/drive/gdata_wapi_url_generator.h" | |
19 | 18 |
20 class GURL; | 19 class GURL; |
21 class OAuth2TokenService; | 20 class OAuth2TokenService; |
22 | 21 |
23 namespace base { | 22 namespace base { |
24 class FilePath; | 23 class FilePath; |
25 class SequencedTaskRunner; | 24 class SequencedTaskRunner; |
26 } | 25 } |
27 | 26 |
28 namespace google_apis { | 27 namespace google_apis { |
(...skipping 11 matching lines...) Expand all Loading... |
40 // works as a thin wrapper for the API. | 39 // works as a thin wrapper for the API. |
41 class DriveAPIService : public DriveServiceInterface, | 40 class DriveAPIService : public DriveServiceInterface, |
42 public google_apis::AuthServiceObserver { | 41 public google_apis::AuthServiceObserver { |
43 public: | 42 public: |
44 // |oauth2_token_service| is used for obtaining OAuth2 access tokens. | 43 // |oauth2_token_service| is used for obtaining OAuth2 access tokens. |
45 // |url_request_context_getter| is used to initialize URLFetcher. | 44 // |url_request_context_getter| is used to initialize URLFetcher. |
46 // |blocking_task_runner| is used to run blocking tasks (like parsing JSON). | 45 // |blocking_task_runner| is used to run blocking tasks (like parsing JSON). |
47 // |base_url| is used to generate URLs for communication with the drive API. | 46 // |base_url| is used to generate URLs for communication with the drive API. |
48 // |base_download_url| is used to generate URLs for downloading file from the | 47 // |base_download_url| is used to generate URLs for downloading file from the |
49 // drive API. | 48 // drive API. |
50 // |wapi_base_url| is used to generate URLs for shared_url. Unfortunately, | |
51 // the share_url is not yet supported on Drive API v2, so as a fallback, | |
52 // we use GData WAPI. | |
53 // |custom_user_agent| will be used for the User-Agent header in HTTP | 49 // |custom_user_agent| will be used for the User-Agent header in HTTP |
54 // requests issues through the service if the value is not empty. | 50 // requests issues through the service if the value is not empty. |
55 DriveAPIService( | 51 DriveAPIService( |
56 OAuth2TokenService* oauth2_token_service, | 52 OAuth2TokenService* oauth2_token_service, |
57 net::URLRequestContextGetter* url_request_context_getter, | 53 net::URLRequestContextGetter* url_request_context_getter, |
58 base::SequencedTaskRunner* blocking_task_runner, | 54 base::SequencedTaskRunner* blocking_task_runner, |
59 const GURL& base_url, | 55 const GURL& base_url, |
60 const GURL& base_download_url, | 56 const GURL& base_download_url, |
61 const GURL& wapi_base_url, | |
62 const std::string& custom_user_agent); | 57 const std::string& custom_user_agent); |
63 ~DriveAPIService() override; | 58 ~DriveAPIService() override; |
64 | 59 |
65 // DriveServiceInterface Overrides | 60 // DriveServiceInterface Overrides |
66 void Initialize(const std::string& account_id) override; | 61 void Initialize(const std::string& account_id) override; |
67 void AddObserver(DriveServiceObserver* observer) override; | 62 void AddObserver(DriveServiceObserver* observer) override; |
68 void RemoveObserver(DriveServiceObserver* observer) override; | 63 void RemoveObserver(DriveServiceObserver* observer) override; |
69 bool CanSendRequest() const override; | 64 bool CanSendRequest() const override; |
70 bool HasAccessToken() const override; | 65 bool HasAccessToken() const override; |
71 void RequestAccessToken( | 66 void RequestAccessToken( |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 202 |
208 // The class is expected to run on UI thread. | 203 // The class is expected to run on UI thread. |
209 base::ThreadChecker thread_checker_; | 204 base::ThreadChecker thread_checker_; |
210 | 205 |
211 OAuth2TokenService* oauth2_token_service_; | 206 OAuth2TokenService* oauth2_token_service_; |
212 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 207 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
213 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 208 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
214 scoped_ptr<google_apis::RequestSender> sender_; | 209 scoped_ptr<google_apis::RequestSender> sender_; |
215 ObserverList<DriveServiceObserver> observers_; | 210 ObserverList<DriveServiceObserver> observers_; |
216 google_apis::DriveApiUrlGenerator url_generator_; | 211 google_apis::DriveApiUrlGenerator url_generator_; |
217 google_apis::GDataWapiUrlGenerator wapi_url_generator_; | |
218 const std::string custom_user_agent_; | 212 const std::string custom_user_agent_; |
219 | 213 |
220 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); | 214 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); |
221 }; | 215 }; |
222 | 216 |
223 } // namespace drive | 217 } // namespace drive |
224 | 218 |
225 #endif // CHROME_BROWSER_DRIVE_DRIVE_API_SERVICE_H_ | 219 #endif // CHROME_BROWSER_DRIVE_DRIVE_API_SERVICE_H_ |
OLD | NEW |