Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: chrome/browser/drive/drive_api_service.cc

Issue 23382008: Making OAuth2TokenService multi-login aware, updating callers, minor fixes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing Android compilation issue Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/drive/drive_api_service.h" 5 #include "chrome/browser/drive/drive_api_service.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 } 305 }
306 306
307 // The resource ID for the root directory for Drive API is defined in the spec: 307 // The resource ID for the root directory for Drive API is defined in the spec:
308 // https://developers.google.com/drive/folder 308 // https://developers.google.com/drive/folder
309 const char kDriveApiRootDirectoryResourceId[] = "root"; 309 const char kDriveApiRootDirectoryResourceId[] = "root";
310 310
311 } // namespace 311 } // namespace
312 312
313 DriveAPIService::DriveAPIService( 313 DriveAPIService::DriveAPIService(
314 OAuth2TokenService* oauth2_token_service, 314 OAuth2TokenService* oauth2_token_service,
315 const std::string& account_id,
315 net::URLRequestContextGetter* url_request_context_getter, 316 net::URLRequestContextGetter* url_request_context_getter,
316 base::TaskRunner* blocking_task_runner, 317 base::TaskRunner* blocking_task_runner,
317 const GURL& base_url, 318 const GURL& base_url,
318 const GURL& base_download_url, 319 const GURL& base_download_url,
319 const GURL& wapi_base_url, 320 const GURL& wapi_base_url,
320 const std::string& custom_user_agent) 321 const std::string& custom_user_agent)
321 : oauth2_token_service_(oauth2_token_service), 322 : oauth2_token_service_(oauth2_token_service),
323 account_id_(account_id),
322 url_request_context_getter_(url_request_context_getter), 324 url_request_context_getter_(url_request_context_getter),
323 blocking_task_runner_(blocking_task_runner), 325 blocking_task_runner_(blocking_task_runner),
324 url_generator_(base_url, base_download_url), 326 url_generator_(base_url, base_download_url),
325 wapi_url_generator_(wapi_base_url, base_download_url), 327 wapi_url_generator_(wapi_base_url, base_download_url),
326 custom_user_agent_(custom_user_agent) { 328 custom_user_agent_(custom_user_agent) {
327 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
328 } 330 }
329 331
330 DriveAPIService::~DriveAPIService() { 332 DriveAPIService::~DriveAPIService() {
331 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 333 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
332 if (sender_.get()) 334 if (sender_.get())
333 sender_->auth_service()->RemoveObserver(this); 335 sender_->auth_service()->RemoveObserver(this);
334 } 336 }
335 337
336 void DriveAPIService::Initialize() { 338 void DriveAPIService::Initialize() {
337 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 339 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
338 340
339 std::vector<std::string> scopes; 341 std::vector<std::string> scopes;
340 scopes.push_back(kDriveScope); 342 scopes.push_back(kDriveScope);
341 scopes.push_back(kDriveAppsReadonlyScope); 343 scopes.push_back(kDriveAppsReadonlyScope);
342 344
343 // GData WAPI token. These are for GetShareUrl(). 345 // GData WAPI token. These are for GetShareUrl().
344 scopes.push_back(util::kDocsListScope); 346 scopes.push_back(util::kDocsListScope);
345 scopes.push_back(util::kDriveAppsScope); 347 scopes.push_back(util::kDriveAppsScope);
346 348
347 sender_.reset(new RequestSender( 349 sender_.reset(new RequestSender(
348 new google_apis::AuthService( 350 new google_apis::AuthService(oauth2_token_service_,
349 oauth2_token_service_, url_request_context_getter_, scopes), 351 account_id_,
350 url_request_context_getter_, 352 url_request_context_getter_,
351 blocking_task_runner_.get(), 353 scopes),
352 custom_user_agent_)); 354 url_request_context_getter_,
355 blocking_task_runner_.get(),
356 custom_user_agent_));
353 sender_->auth_service()->AddObserver(this); 357 sender_->auth_service()->AddObserver(this);
354 } 358 }
355 359
356 void DriveAPIService::AddObserver(DriveServiceObserver* observer) { 360 void DriveAPIService::AddObserver(DriveServiceObserver* observer) {
357 observers_.AddObserver(observer); 361 observers_.AddObserver(observer);
358 } 362 }
359 363
360 void DriveAPIService::RemoveObserver(DriveServiceObserver* observer) { 364 void DriveAPIService::RemoveObserver(DriveServiceObserver* observer) {
361 observers_.RemoveObserver(observer); 365 observers_.RemoveObserver(observer);
362 } 366 }
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 if (CanSendRequest()) { 912 if (CanSendRequest()) {
909 FOR_EACH_OBSERVER( 913 FOR_EACH_OBSERVER(
910 DriveServiceObserver, observers_, OnReadyToSendRequests()); 914 DriveServiceObserver, observers_, OnReadyToSendRequests());
911 } else if (!HasRefreshToken()) { 915 } else if (!HasRefreshToken()) {
912 FOR_EACH_OBSERVER( 916 FOR_EACH_OBSERVER(
913 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); 917 DriveServiceObserver, observers_, OnRefreshTokenInvalid());
914 } 918 }
915 } 919 }
916 920
917 } // namespace drive 921 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698