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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 util::Log(logging::LOG_INFO, "Drive mount point is removed"); | 414 util::Log(logging::LOG_INFO, "Drive mount point is removed"); |
415 } | 415 } |
416 | 416 |
417 void DriveIntegrationService::Initialize() { | 417 void DriveIntegrationService::Initialize() { |
418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
419 DCHECK_EQ(NOT_INITIALIZED, state_); | 419 DCHECK_EQ(NOT_INITIALIZED, state_); |
420 DCHECK(enabled_); | 420 DCHECK(enabled_); |
421 | 421 |
422 state_ = INITIALIZING; | 422 state_ = INITIALIZING; |
423 drive_service_->Initialize(); | 423 drive_service_->Initialize(); |
424 file_system_->Initialize(); | |
425 | 424 |
426 base::PostTaskAndReplyWithResult( | 425 base::PostTaskAndReplyWithResult( |
427 blocking_task_runner_.get(), | 426 blocking_task_runner_.get(), |
428 FROM_HERE, | 427 FROM_HERE, |
429 base::Bind(&InitializeMetadata, | 428 base::Bind(&InitializeMetadata, |
430 cache_root_directory_, | 429 cache_root_directory_, |
431 metadata_storage_.get(), | 430 metadata_storage_.get(), |
432 cache_.get(), | 431 cache_.get(), |
433 resource_metadata_.get()), | 432 resource_metadata_.get()), |
434 base::Bind(&DriveIntegrationService::InitializeAfterMetadataInitialized, | 433 base::Bind(&DriveIntegrationService::InitializeAfterMetadataInitialized, |
(...skipping 11 matching lines...) Expand all Loading... |
446 // Change the download directory to the default value if the download | 445 // Change the download directory to the default value if the download |
447 // destination is set to under Drive mount point. | 446 // destination is set to under Drive mount point. |
448 PrefService* pref_service = profile_->GetPrefs(); | 447 PrefService* pref_service = profile_->GetPrefs(); |
449 if (util::IsUnderDriveMountPoint( | 448 if (util::IsUnderDriveMountPoint( |
450 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory))) { | 449 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory))) { |
451 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, | 450 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, |
452 DownloadPrefs::GetDefaultDownloadDirectory()); | 451 DownloadPrefs::GetDefaultDownloadDirectory()); |
453 } | 452 } |
454 | 453 |
455 // Back to NOT_INITIALIZED state. Then, re-running Initialize() should | 454 // Back to NOT_INITIALIZED state. Then, re-running Initialize() should |
456 // work if the error is recovarable manually (such as out of disk space). | 455 // work if the error is recoverable manually (such as out of disk space). |
457 state_ = NOT_INITIALIZED; | 456 state_ = NOT_INITIALIZED; |
458 return; | 457 return; |
459 } | 458 } |
460 | 459 |
461 content::DownloadManager* download_manager = | 460 content::DownloadManager* download_manager = |
462 g_browser_process->download_status_updater() ? | 461 g_browser_process->download_status_updater() ? |
463 BrowserContext::GetDownloadManager(profile_) : NULL; | 462 BrowserContext::GetDownloadManager(profile_) : NULL; |
464 download_handler_->Initialize( | 463 download_handler_->Initialize( |
465 download_manager, | 464 download_manager, |
466 cache_root_directory_.Append(kTemporaryFileDirectory)); | 465 cache_root_directory_.Append(kTemporaryFileDirectory)); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 NULL, base::FilePath(), NULL); | 558 NULL, base::FilePath(), NULL); |
560 } else { | 559 } else { |
561 service = factory_for_test_.Run(profile); | 560 service = factory_for_test_.Run(profile); |
562 } | 561 } |
563 | 562 |
564 service->SetEnabled(drive::util::IsDriveEnabledForProfile(profile)); | 563 service->SetEnabled(drive::util::IsDriveEnabledForProfile(profile)); |
565 return service; | 564 return service; |
566 } | 565 } |
567 | 566 |
568 } // namespace drive | 567 } // namespace drive |
OLD | NEW |