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 #include "components/drive/service/drive_api_service.h" | 5 #include "components/drive/service/drive_api_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 batch_request_->Commit(); | 247 batch_request_->Commit(); |
248 batch_request_.reset(); | 248 batch_request_.reset(); |
249 } | 249 } |
250 | 250 |
251 DriveAPIService::DriveAPIService( | 251 DriveAPIService::DriveAPIService( |
252 OAuth2TokenService* oauth2_token_service, | 252 OAuth2TokenService* oauth2_token_service, |
253 net::URLRequestContextGetter* url_request_context_getter, | 253 net::URLRequestContextGetter* url_request_context_getter, |
254 base::SequencedTaskRunner* blocking_task_runner, | 254 base::SequencedTaskRunner* blocking_task_runner, |
255 const GURL& base_url, | 255 const GURL& base_url, |
256 const GURL& base_thumbnail_url, | 256 const GURL& base_thumbnail_url, |
257 const std::string& custom_user_agent) | 257 const std::string& custom_user_agent, |
| 258 const net::NetworkTrafficAnnotationTag& traffic_annotation) |
258 : oauth2_token_service_(oauth2_token_service), | 259 : oauth2_token_service_(oauth2_token_service), |
259 url_request_context_getter_(url_request_context_getter), | 260 url_request_context_getter_(url_request_context_getter), |
260 blocking_task_runner_(blocking_task_runner), | 261 blocking_task_runner_(blocking_task_runner), |
261 url_generator_(base_url, base_thumbnail_url, | 262 url_generator_(base_url, |
| 263 base_thumbnail_url, |
262 google_apis::GetTeamDrivesIntegrationSwitch()), | 264 google_apis::GetTeamDrivesIntegrationSwitch()), |
263 custom_user_agent_(custom_user_agent) { | 265 custom_user_agent_(custom_user_agent), |
264 } | 266 traffic_annotation_(traffic_annotation) {} |
265 | 267 |
266 DriveAPIService::~DriveAPIService() { | 268 DriveAPIService::~DriveAPIService() { |
267 DCHECK(thread_checker_.CalledOnValidThread()); | 269 DCHECK(thread_checker_.CalledOnValidThread()); |
268 if (sender_.get()) | 270 if (sender_.get()) |
269 sender_->auth_service()->RemoveObserver(this); | 271 sender_->auth_service()->RemoveObserver(this); |
270 } | 272 } |
271 | 273 |
272 void DriveAPIService::Initialize(const std::string& account_id) { | 274 void DriveAPIService::Initialize(const std::string& account_id) { |
273 DCHECK(thread_checker_.CalledOnValidThread()); | 275 DCHECK(thread_checker_.CalledOnValidThread()); |
274 | 276 |
275 std::vector<std::string> scopes; | 277 std::vector<std::string> scopes; |
276 scopes.push_back(kDriveScope); | 278 scopes.push_back(kDriveScope); |
277 scopes.push_back(kDriveAppsReadonlyScope); | 279 scopes.push_back(kDriveAppsReadonlyScope); |
278 scopes.push_back(kDriveAppsScope); | 280 scopes.push_back(kDriveAppsScope); |
279 | 281 |
280 // Note: The following scope is used to support GetShareUrl on Drive API v2. | 282 // Note: The following scope is used to support GetShareUrl on Drive API v2. |
281 // Unfortunately, there is no support on Drive API v2, so we need to fall back | 283 // Unfortunately, there is no support on Drive API v2, so we need to fall back |
282 // to GData WAPI for the GetShareUrl. | 284 // to GData WAPI for the GetShareUrl. |
283 scopes.push_back(kDocsListScope); | 285 scopes.push_back(kDocsListScope); |
284 | 286 |
285 sender_.reset(new RequestSender( | 287 sender_.reset(new RequestSender( |
286 new google_apis::AuthService(oauth2_token_service_, | 288 new google_apis::AuthService(oauth2_token_service_, account_id, |
287 account_id, | 289 url_request_context_getter_.get(), scopes), |
288 url_request_context_getter_.get(), | 290 url_request_context_getter_.get(), blocking_task_runner_.get(), |
289 scopes), | 291 custom_user_agent_, traffic_annotation_)); |
290 url_request_context_getter_.get(), | |
291 blocking_task_runner_.get(), | |
292 custom_user_agent_)); | |
293 sender_->auth_service()->AddObserver(this); | 292 sender_->auth_service()->AddObserver(this); |
294 | 293 |
295 files_list_request_runner_.reset( | 294 files_list_request_runner_.reset( |
296 new FilesListRequestRunner(sender_.get(), url_generator_)); | 295 new FilesListRequestRunner(sender_.get(), url_generator_)); |
297 } | 296 } |
298 | 297 |
299 void DriveAPIService::AddObserver(DriveServiceObserver* observer) { | 298 void DriveAPIService::AddObserver(DriveServiceObserver* observer) { |
300 observers_.AddObserver(observer); | 299 observers_.AddObserver(observer); |
301 } | 300 } |
302 | 301 |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 // RequestSender before the request is committed because the request has a | 877 // RequestSender before the request is committed because the request has a |
879 // reference to RequestSender and we should ensure to delete the request when | 878 // reference to RequestSender and we should ensure to delete the request when |
880 // the sender is deleted. Resolve the circulating dependency and fix it. | 879 // the sender is deleted. Resolve the circulating dependency and fix it. |
881 const google_apis::CancelCallback callback = | 880 const google_apis::CancelCallback callback = |
882 sender_->StartRequestWithAuthRetry(std::move(request)); | 881 sender_->StartRequestWithAuthRetry(std::move(request)); |
883 return base::MakeUnique<BatchRequestConfigurator>( | 882 return base::MakeUnique<BatchRequestConfigurator>( |
884 weak_ref, sender_->blocking_task_runner(), url_generator_, callback); | 883 weak_ref, sender_->blocking_task_runner(), url_generator_, callback); |
885 } | 884 } |
886 | 885 |
887 } // namespace drive | 886 } // namespace drive |
OLD | NEW |