| 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/chromeos/drive/drive_integration_service.h" | 5 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/prefs/pref_change_registrar.h" | 9 #include "base/prefs/pref_change_registrar.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 enabled_(false), | 180 enabled_(false), |
| 181 cache_root_directory_(!test_cache_root.empty() ? | 181 cache_root_directory_(!test_cache_root.empty() ? |
| 182 test_cache_root : util::GetCacheRootPath(profile)), | 182 test_cache_root : util::GetCacheRootPath(profile)), |
| 183 weak_ptr_factory_(this) { | 183 weak_ptr_factory_(this) { |
| 184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 185 | 185 |
| 186 base::SequencedWorkerPool* blocking_pool = BrowserThread::GetBlockingPool(); | 186 base::SequencedWorkerPool* blocking_pool = BrowserThread::GetBlockingPool(); |
| 187 blocking_task_runner_ = blocking_pool->GetSequencedTaskRunner( | 187 blocking_task_runner_ = blocking_pool->GetSequencedTaskRunner( |
| 188 blocking_pool->GetSequenceToken()); | 188 blocking_pool->GetSequenceToken()); |
| 189 | 189 |
| 190 OAuth2TokenService* oauth_service = | 190 ProfileOAuth2TokenService* oauth_service = |
| 191 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 191 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 192 | 192 |
| 193 if (test_drive_service) { | 193 if (test_drive_service) { |
| 194 drive_service_.reset(test_drive_service); | 194 drive_service_.reset(test_drive_service); |
| 195 } else if (util::IsDriveV2ApiEnabled()) { | 195 } else if (util::IsDriveV2ApiEnabled()) { |
| 196 drive_service_.reset(new DriveAPIService( | 196 drive_service_.reset(new DriveAPIService( |
| 197 oauth_service, | 197 oauth_service, |
| 198 oauth_service->GetPrimaryAccountId(), |
| 198 g_browser_process->system_request_context(), | 199 g_browser_process->system_request_context(), |
| 199 blocking_task_runner_.get(), | 200 blocking_task_runner_.get(), |
| 200 GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction), | 201 GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction), |
| 201 GURL(google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction), | 202 GURL(google_apis::DriveApiUrlGenerator::kBaseDownloadUrlForProduction), |
| 202 GURL(google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction), | 203 GURL(google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction), |
| 203 GetDriveUserAgent())); | 204 GetDriveUserAgent())); |
| 204 } else { | 205 } else { |
| 205 drive_service_.reset(new GDataWapiService( | 206 drive_service_.reset(new GDataWapiService( |
| 206 oauth_service, | 207 oauth_service, |
| 208 oauth_service->GetPrimaryAccountId(), |
| 207 g_browser_process->system_request_context(), | 209 g_browser_process->system_request_context(), |
| 208 blocking_task_runner_.get(), | 210 blocking_task_runner_.get(), |
| 209 GURL(google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction), | 211 GURL(google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction), |
| 210 GURL(google_apis::GDataWapiUrlGenerator::kBaseDownloadUrlForProduction), | 212 GURL(google_apis::GDataWapiUrlGenerator::kBaseDownloadUrlForProduction), |
| 211 GetDriveUserAgent())); | 213 GetDriveUserAgent())); |
| 212 } | 214 } |
| 213 scheduler_.reset(new JobScheduler( | 215 scheduler_.reset(new JobScheduler( |
| 214 profile_->GetPrefs(), | 216 profile_->GetPrefs(), |
| 215 drive_service_.get(), | 217 drive_service_.get(), |
| 216 blocking_task_runner_.get())); | 218 blocking_task_runner_.get())); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 NULL, base::FilePath(), NULL); | 566 NULL, base::FilePath(), NULL); |
| 565 } else { | 567 } else { |
| 566 service = factory_for_test_.Run(profile); | 568 service = factory_for_test_.Run(profile); |
| 567 } | 569 } |
| 568 | 570 |
| 569 service->SetEnabled(drive::util::IsDriveEnabledForProfile(profile)); | 571 service->SetEnabled(drive::util::IsDriveEnabledForProfile(profile)); |
| 570 return service; | 572 return service; |
| 571 } | 573 } |
| 572 | 574 |
| 573 } // namespace drive | 575 } // namespace drive |
| OLD | NEW |