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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 if (state_ != INITIALIZED) { | 384 if (state_ != INITIALIZED) { |
385 callback.Run(false); | 385 callback.Run(false); |
386 return; | 386 return; |
387 } | 387 } |
388 | 388 |
389 RemoveDriveMountPoint(); | 389 RemoveDriveMountPoint(); |
390 | 390 |
391 state_ = REMOUNTING; | 391 state_ = REMOUNTING; |
392 // Reloads the Drive app registry. | 392 // Reloads the Drive app registry. |
393 drive_app_registry_->Update(); | 393 drive_app_registry_->Update(); |
394 // Reloading the file system clears resource metadata and cache. | 394 // Resetting the file system clears resource metadata and cache. |
395 file_system_->Reload(base::Bind( | 395 file_system_->Reset(base::Bind( |
396 &DriveIntegrationService::AddBackDriveMountPoint, | 396 &DriveIntegrationService::AddBackDriveMountPoint, |
397 weak_ptr_factory_.GetWeakPtr(), | 397 weak_ptr_factory_.GetWeakPtr(), |
398 callback)); | 398 callback)); |
399 } | 399 } |
400 | 400 |
401 void DriveIntegrationService::AddBackDriveMountPoint( | 401 void DriveIntegrationService::AddBackDriveMountPoint( |
402 const base::Callback<void(bool)>& callback, | 402 const base::Callback<void(bool)>& callback, |
403 FileError error) { | 403 FileError error) { |
404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
405 DCHECK(!callback.is_null()); | 405 DCHECK(!callback.is_null()); |
406 | 406 |
407 state_ = error == FILE_ERROR_OK ? INITIALIZED : NOT_INITIALIZED; | 407 state_ = error == FILE_ERROR_OK ? INITIALIZED : NOT_INITIALIZED; |
408 | 408 |
409 if (error != FILE_ERROR_OK || !enabled_) { | 409 if (error != FILE_ERROR_OK || !enabled_) { |
410 // Failed to reload, or Drive was disabled during the reloading. | 410 // Failed to reset, or Drive was disabled during the reset. |
411 callback.Run(false); | 411 callback.Run(false); |
412 return; | 412 return; |
413 } | 413 } |
414 | 414 |
415 AddDriveMountPoint(); | 415 AddDriveMountPoint(); |
416 callback.Run(true); | 416 callback.Run(true); |
417 } | 417 } |
418 | 418 |
419 void DriveIntegrationService::AddDriveMountPoint() { | 419 void DriveIntegrationService::AddDriveMountPoint() { |
420 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 420 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 service = new DriveIntegrationService(profile, preference_watcher, | 608 service = new DriveIntegrationService(profile, preference_watcher, |
609 NULL, base::FilePath(), NULL); | 609 NULL, base::FilePath(), NULL); |
610 } else { | 610 } else { |
611 service = factory_for_test_.Run(profile); | 611 service = factory_for_test_.Run(profile); |
612 } | 612 } |
613 | 613 |
614 return service; | 614 return service; |
615 } | 615 } |
616 | 616 |
617 } // namespace drive | 617 } // namespace drive |
OLD | NEW |