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 COMPONENTS_DRIVE_SERVICE_DRIVE_API_SERVICE_H_ | 5 #ifndef COMPONENTS_DRIVE_SERVICE_DRIVE_API_SERVICE_H_ |
6 #define COMPONENTS_DRIVE_SERVICE_DRIVE_API_SERVICE_H_ | 6 #define COMPONENTS_DRIVE_SERVICE_DRIVE_API_SERVICE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
18 #include "components/drive/service/drive_service_interface.h" | 18 #include "components/drive/service/drive_service_interface.h" |
19 #include "google_apis/drive/auth_service_interface.h" | 19 #include "google_apis/drive/auth_service_interface.h" |
20 #include "google_apis/drive/auth_service_observer.h" | 20 #include "google_apis/drive/auth_service_observer.h" |
21 #include "google_apis/drive/drive_api_url_generator.h" | 21 #include "google_apis/drive/drive_api_url_generator.h" |
| 22 #include "net/traffic_annotation/network_traffic_annotation.h" |
22 | 23 |
23 class GURL; | 24 class GURL; |
24 class OAuth2TokenService; | 25 class OAuth2TokenService; |
25 | 26 |
26 namespace base { | 27 namespace base { |
27 class FilePath; | 28 class FilePath; |
28 class SequencedTaskRunner; | 29 class SequencedTaskRunner; |
29 } | 30 } |
30 | 31 |
31 namespace google_apis { | 32 namespace google_apis { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 public google_apis::AuthServiceObserver { | 92 public google_apis::AuthServiceObserver { |
92 public: | 93 public: |
93 // |oauth2_token_service| is used for obtaining OAuth2 access tokens. | 94 // |oauth2_token_service| is used for obtaining OAuth2 access tokens. |
94 // |url_request_context_getter| is used to initialize URLFetcher. | 95 // |url_request_context_getter| is used to initialize URLFetcher. |
95 // |blocking_task_runner| is used to run blocking tasks (like parsing JSON). | 96 // |blocking_task_runner| is used to run blocking tasks (like parsing JSON). |
96 // |base_url| is used to generate URLs for communication with the drive API. | 97 // |base_url| is used to generate URLs for communication with the drive API. |
97 // |base_thumbnail_url| is used to generate URLs for downloading thumbnail | 98 // |base_thumbnail_url| is used to generate URLs for downloading thumbnail |
98 // from image server. | 99 // from image server. |
99 // |custom_user_agent| will be used for the User-Agent header in HTTP | 100 // |custom_user_agent| will be used for the User-Agent header in HTTP |
100 // requests issues through the service if the value is not empty. | 101 // requests issues through the service if the value is not empty. |
101 DriveAPIService( | 102 // |traffic_annotation| will be used to annotate the network request that will |
102 OAuth2TokenService* oauth2_token_service, | 103 // be created to perform this service. |
103 net::URLRequestContextGetter* url_request_context_getter, | 104 DriveAPIService(OAuth2TokenService* oauth2_token_service, |
104 base::SequencedTaskRunner* blocking_task_runner, | 105 net::URLRequestContextGetter* url_request_context_getter, |
105 const GURL& base_url, | 106 base::SequencedTaskRunner* blocking_task_runner, |
106 const GURL& base_thumbnail_url, | 107 const GURL& base_url, |
107 const std::string& custom_user_agent); | 108 const GURL& base_thumbnail_url, |
| 109 const std::string& custom_user_agent, |
| 110 const net::NetworkTrafficAnnotationTag& traffic_annotation); |
108 ~DriveAPIService() override; | 111 ~DriveAPIService() override; |
109 | 112 |
110 // DriveServiceInterface Overrides | 113 // DriveServiceInterface Overrides |
111 void Initialize(const std::string& account_id) override; | 114 void Initialize(const std::string& account_id) override; |
112 void AddObserver(DriveServiceObserver* observer) override; | 115 void AddObserver(DriveServiceObserver* observer) override; |
113 void RemoveObserver(DriveServiceObserver* observer) override; | 116 void RemoveObserver(DriveServiceObserver* observer) override; |
114 bool CanSendRequest() const override; | 117 bool CanSendRequest() const override; |
115 bool HasAccessToken() const override; | 118 bool HasAccessToken() const override; |
116 void RequestAccessToken( | 119 void RequestAccessToken( |
117 const google_apis::AuthStatusCallback& callback) override; | 120 const google_apis::AuthStatusCallback& callback) override; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 261 |
259 OAuth2TokenService* oauth2_token_service_; | 262 OAuth2TokenService* oauth2_token_service_; |
260 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 263 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
261 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 264 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
262 std::unique_ptr<google_apis::RequestSender> sender_; | 265 std::unique_ptr<google_apis::RequestSender> sender_; |
263 std::unique_ptr<google_apis::FilesListRequestRunner> | 266 std::unique_ptr<google_apis::FilesListRequestRunner> |
264 files_list_request_runner_; | 267 files_list_request_runner_; |
265 base::ObserverList<DriveServiceObserver> observers_; | 268 base::ObserverList<DriveServiceObserver> observers_; |
266 google_apis::DriveApiUrlGenerator url_generator_; | 269 google_apis::DriveApiUrlGenerator url_generator_; |
267 const std::string custom_user_agent_; | 270 const std::string custom_user_agent_; |
| 271 const net::NetworkTrafficAnnotationTag traffic_annotation_; |
268 | 272 |
269 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); | 273 DISALLOW_COPY_AND_ASSIGN(DriveAPIService); |
270 }; | 274 }; |
271 | 275 |
272 } // namespace drive | 276 } // namespace drive |
273 | 277 |
274 #endif // COMPONENTS_DRIVE_SERVICE_DRIVE_API_SERVICE_H_ | 278 #endif // COMPONENTS_DRIVE_SERVICE_DRIVE_API_SERVICE_H_ |
OLD | NEW |