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 "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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 } | 299 } |
300 | 300 |
301 // The resource ID for the root directory for Drive API is defined in the spec: | 301 // The resource ID for the root directory for Drive API is defined in the spec: |
302 // https://developers.google.com/drive/folder | 302 // https://developers.google.com/drive/folder |
303 const char kDriveApiRootDirectoryResourceId[] = "root"; | 303 const char kDriveApiRootDirectoryResourceId[] = "root"; |
304 | 304 |
305 } // namespace | 305 } // namespace |
306 | 306 |
307 DriveAPIService::DriveAPIService( | 307 DriveAPIService::DriveAPIService( |
308 OAuth2TokenService* oauth2_token_service, | 308 OAuth2TokenService* oauth2_token_service, |
309 const std::string& account_id, | |
309 net::URLRequestContextGetter* url_request_context_getter, | 310 net::URLRequestContextGetter* url_request_context_getter, |
310 base::TaskRunner* blocking_task_runner, | 311 base::TaskRunner* blocking_task_runner, |
311 const GURL& base_url, | 312 const GURL& base_url, |
312 const GURL& base_download_url, | 313 const GURL& base_download_url, |
313 const GURL& wapi_base_url, | 314 const GURL& wapi_base_url, |
314 const std::string& custom_user_agent) | 315 const std::string& custom_user_agent) |
315 : oauth2_token_service_(oauth2_token_service), | 316 : oauth2_token_service_(oauth2_token_service), |
317 account_id_(account_id), | |
316 url_request_context_getter_(url_request_context_getter), | 318 url_request_context_getter_(url_request_context_getter), |
317 blocking_task_runner_(blocking_task_runner), | 319 blocking_task_runner_(blocking_task_runner), |
318 url_generator_(base_url, base_download_url), | 320 url_generator_(base_url, base_download_url), |
319 wapi_url_generator_(wapi_base_url, base_download_url), | 321 wapi_url_generator_(wapi_base_url, base_download_url), |
320 custom_user_agent_(custom_user_agent) { | 322 custom_user_agent_(custom_user_agent) { |
321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 323 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
322 } | 324 } |
323 | 325 |
324 DriveAPIService::~DriveAPIService() { | 326 DriveAPIService::~DriveAPIService() { |
325 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 327 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
326 if (sender_.get()) | 328 if (sender_.get()) |
327 sender_->auth_service()->RemoveObserver(this); | 329 sender_->auth_service()->RemoveObserver(this); |
328 } | 330 } |
329 | 331 |
330 void DriveAPIService::Initialize() { | 332 void DriveAPIService::Initialize() { |
331 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 333 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
332 | 334 |
333 std::vector<std::string> scopes; | 335 std::vector<std::string> scopes; |
334 scopes.push_back(kDriveScope); | 336 scopes.push_back(kDriveScope); |
335 scopes.push_back(kDriveAppsReadonlyScope); | 337 scopes.push_back(kDriveAppsReadonlyScope); |
336 | 338 |
337 // GData WAPI token. These are for GetShareUrl(). | 339 // GData WAPI token. These are for GetShareUrl(). |
338 scopes.push_back(util::kDocsListScope); | 340 scopes.push_back(util::kDocsListScope); |
339 scopes.push_back(util::kDriveAppsScope); | 341 scopes.push_back(util::kDriveAppsScope); |
340 | 342 |
341 sender_.reset(new RequestSender( | 343 sender_.reset(new RequestSender( |
342 new google_apis::AuthService( | 344 new google_apis::AuthService(oauth2_token_service_, account_id_, |
Andrew T Wilson (Slow)
2013/08/30 10:47:00
I don't think this is wrapped correctly
fgorski
2013/08/30 20:10:16
Done.
| |
343 oauth2_token_service_, url_request_context_getter_, scopes), | 345 url_request_context_getter_, scopes), |
344 url_request_context_getter_, | 346 url_request_context_getter_, |
345 blocking_task_runner_.get(), | 347 blocking_task_runner_.get(), |
346 custom_user_agent_)); | 348 custom_user_agent_)); |
347 sender_->auth_service()->AddObserver(this); | 349 sender_->auth_service()->AddObserver(this); |
348 } | 350 } |
349 | 351 |
350 void DriveAPIService::AddObserver(DriveServiceObserver* observer) { | 352 void DriveAPIService::AddObserver(DriveServiceObserver* observer) { |
351 observers_.AddObserver(observer); | 353 observers_.AddObserver(observer); |
352 } | 354 } |
353 | 355 |
354 void DriveAPIService::RemoveObserver(DriveServiceObserver* observer) { | 356 void DriveAPIService::RemoveObserver(DriveServiceObserver* observer) { |
355 observers_.RemoveObserver(observer); | 357 observers_.RemoveObserver(observer); |
356 } | 358 } |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 if (CanSendRequest()) { | 871 if (CanSendRequest()) { |
870 FOR_EACH_OBSERVER( | 872 FOR_EACH_OBSERVER( |
871 DriveServiceObserver, observers_, OnReadyToSendRequests()); | 873 DriveServiceObserver, observers_, OnReadyToSendRequests()); |
872 } else if (!HasRefreshToken()) { | 874 } else if (!HasRefreshToken()) { |
873 FOR_EACH_OBSERVER( | 875 FOR_EACH_OBSERVER( |
874 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); | 876 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); |
875 } | 877 } |
876 } | 878 } |
877 | 879 |
878 } // namespace drive | 880 } // namespace drive |
OLD | NEW |