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

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: Addressing CR comments. Created 7 years, 4 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 267 }
268 268
269 // The resource ID for the root directory for Drive API is defined in the spec: 269 // The resource ID for the root directory for Drive API is defined in the spec:
270 // https://developers.google.com/drive/folder 270 // https://developers.google.com/drive/folder
271 const char kDriveApiRootDirectoryResourceId[] = "root"; 271 const char kDriveApiRootDirectoryResourceId[] = "root";
272 272
273 } // namespace 273 } // namespace
274 274
275 DriveAPIService::DriveAPIService( 275 DriveAPIService::DriveAPIService(
276 OAuth2TokenService* oauth2_token_service, 276 OAuth2TokenService* oauth2_token_service,
277 const std::string& account_id,
277 net::URLRequestContextGetter* url_request_context_getter, 278 net::URLRequestContextGetter* url_request_context_getter,
278 base::TaskRunner* blocking_task_runner, 279 base::TaskRunner* blocking_task_runner,
279 const GURL& base_url, 280 const GURL& base_url,
280 const GURL& base_download_url, 281 const GURL& base_download_url,
281 const GURL& wapi_base_url, 282 const GURL& wapi_base_url,
282 const std::string& custom_user_agent) 283 const std::string& custom_user_agent)
283 : oauth2_token_service_(oauth2_token_service), 284 : oauth2_token_service_(oauth2_token_service),
285 account_id_(account_id),
284 url_request_context_getter_(url_request_context_getter), 286 url_request_context_getter_(url_request_context_getter),
285 blocking_task_runner_(blocking_task_runner), 287 blocking_task_runner_(blocking_task_runner),
286 url_generator_(base_url, base_download_url), 288 url_generator_(base_url, base_download_url),
287 wapi_url_generator_(wapi_base_url, base_download_url), 289 wapi_url_generator_(wapi_base_url, base_download_url),
288 custom_user_agent_(custom_user_agent) { 290 custom_user_agent_(custom_user_agent) {
289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
290 } 292 }
291 293
292 DriveAPIService::~DriveAPIService() { 294 DriveAPIService::~DriveAPIService() {
293 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
294 if (sender_.get()) 296 if (sender_.get())
295 sender_->auth_service()->RemoveObserver(this); 297 sender_->auth_service()->RemoveObserver(this);
296 } 298 }
297 299
298 void DriveAPIService::Initialize() { 300 void DriveAPIService::Initialize() {
299 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
300 302
301 std::vector<std::string> scopes; 303 std::vector<std::string> scopes;
302 scopes.push_back(kDriveScope); 304 scopes.push_back(kDriveScope);
303 scopes.push_back(kDriveAppsReadonlyScope); 305 scopes.push_back(kDriveAppsReadonlyScope);
304 306
305 // GData WAPI token. These are for GetShareUrl(). 307 // GData WAPI token. These are for GetShareUrl().
306 scopes.push_back(util::kDocsListScope); 308 scopes.push_back(util::kDocsListScope);
307 scopes.push_back(util::kDriveAppsScope); 309 scopes.push_back(util::kDriveAppsScope);
308 310
309 sender_.reset(new RequestSender( 311 sender_.reset(new RequestSender(
310 new google_apis::AuthService( 312 new google_apis::AuthService(oauth2_token_service_, account_id_,
311 oauth2_token_service_, url_request_context_getter_, scopes), 313 url_request_context_getter_, scopes),
312 url_request_context_getter_, 314 url_request_context_getter_,
313 blocking_task_runner_.get(), 315 blocking_task_runner_.get(),
314 custom_user_agent_)); 316 custom_user_agent_));
315 sender_->auth_service()->AddObserver(this); 317 sender_->auth_service()->AddObserver(this);
316 } 318 }
317 319
318 void DriveAPIService::AddObserver(DriveServiceObserver* observer) { 320 void DriveAPIService::AddObserver(DriveServiceObserver* observer) {
319 observers_.AddObserver(observer); 321 observers_.AddObserver(observer);
320 } 322 }
321 323
322 void DriveAPIService::RemoveObserver(DriveServiceObserver* observer) { 324 void DriveAPIService::RemoveObserver(DriveServiceObserver* observer) {
323 observers_.RemoveObserver(observer); 325 observers_.RemoveObserver(observer);
324 } 326 }
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 if (CanSendRequest()) { 828 if (CanSendRequest()) {
827 FOR_EACH_OBSERVER( 829 FOR_EACH_OBSERVER(
828 DriveServiceObserver, observers_, OnReadyToSendRequests()); 830 DriveServiceObserver, observers_, OnReadyToSendRequests());
829 } else if (!HasRefreshToken()) { 831 } else if (!HasRefreshToken()) {
830 FOR_EACH_OBSERVER( 832 FOR_EACH_OBSERVER(
831 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); 833 DriveServiceObserver, observers_, OnRefreshTokenInvalid());
832 } 834 }
833 } 835 }
834 836
835 } // namespace drive 837 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698