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

Side by Side Diff: chrome/browser/chromeos/disks/disk_mount_manager.cc

Issue 8497007: Switch from MountLibrary to CrosDisksLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NEW! Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/disks/disk_mount_manager.h" 5 #include "chrome/browser/chromeos/disks/disk_mount_manager.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include <sys/statvfs.h> 10 #include <sys/statvfs.h>
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 if (iter == disks_.end()) { 321 if (iter == disks_.end()) {
322 // disk might have been removed by now. 322 // disk might have been removed by now.
323 return; 323 return;
324 } 324 }
325 Disk* disk = iter->second; 325 Disk* disk = iter->second;
326 DCHECK(disk); 326 DCHECK(disk);
327 disk->clear_mount_path(); 327 disk->clear_mount_path();
328 // Check if there is a formatting scheduled. 328 // Check if there is a formatting scheduled.
329 PathMap::iterator it = formatting_pending_.find(disk->device_path()); 329 PathMap::iterator it = formatting_pending_.find(disk->device_path());
330 if (it != formatting_pending_.end()) { 330 if (it != formatting_pending_.end()) {
331 const std::string& file_path = it->second; 331 const std::string file_path = it->second;
hashimoto 2011/11/15 12:39:25 Using const std::string& is wrong because |it| is
satorux1 2011/11/15 21:20:24 oops. that was tricky! please add a comment just i
hashimoto 2011/11/16 04:28:15 Done.
332 formatting_pending_.erase(it); 332 formatting_pending_.erase(it);
333 FormatUnmountedDevice(file_path); 333 FormatUnmountedDevice(file_path);
334 } 334 }
335 } 335 }
336 336
337 // Callback for FormatDevice. 337 // Callback for FormatDevice.
338 void OnFormatDevice(const std::string& device_path, bool success) { 338 void OnFormatDevice(const std::string& device_path, bool success) {
339 if (success) { 339 if (success) {
340 NotifyDeviceStatusUpdate(MOUNT_FORMATTING_STARTED, device_path); 340 NotifyDeviceStatusUpdate(MOUNT_FORMATTING_STARTED, device_path);
341 } else { 341 } else {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 else if (type_str == "network") 625 else if (type_str == "network")
626 return MOUNT_TYPE_NETWORK_STORAGE; 626 return MOUNT_TYPE_NETWORK_STORAGE;
627 else if (type_str == "file") 627 else if (type_str == "file")
628 return MOUNT_TYPE_ARCHIVE; 628 return MOUNT_TYPE_ARCHIVE;
629 else 629 else
630 return MOUNT_TYPE_INVALID; 630 return MOUNT_TYPE_INVALID;
631 } 631 }
632 632
633 // static 633 // static
634 void DiskMountManager::Initialize() { 634 void DiskMountManager::Initialize() {
635 VLOG(1) << "DiskMountManager::Initialize"; 635 if (g_disk_mount_manager) {
636 DCHECK(!g_disk_mount_manager); 636 LOG(WARNING) << "DiskMountManager was already initialized";
637 return;
638 }
637 g_disk_mount_manager = new DiskMountManagerImpl(); 639 g_disk_mount_manager = new DiskMountManagerImpl();
638 DCHECK(g_disk_mount_manager); 640 VLOG(1) << "DiskMountManager initialized";
641 }
642
643 // static
644 void DiskMountManager::InitializeForTesting(
645 DiskMountManager* disk_mount_manager) {
satorux1 2011/11/15 21:20:24 you can move the parameter to the previous line.
hashimoto 2011/11/16 04:28:15 Done. But the line is too long to make the left br
646 if (g_disk_mount_manager) {
647 LOG(WARNING) << "DiskMountManager was already initialized";
648 return;
649 }
650 g_disk_mount_manager = disk_mount_manager;
651 VLOG(1) << "DiskMountManager initialized";
639 } 652 }
640 653
641 // static 654 // static
642 void DiskMountManager::Shutdown() { 655 void DiskMountManager::Shutdown() {
643 VLOG(1) << "DiskMountManager::Shutdown"; 656 if (!g_disk_mount_manager) {
644 if (g_disk_mount_manager) { 657 LOG(WARNING) << "DiskMountManager::Shutdown() called with NULL manager";
645 delete g_disk_mount_manager; 658 return;
646 g_disk_mount_manager = NULL;
647 } 659 }
660 delete g_disk_mount_manager;
661 g_disk_mount_manager = NULL;
662 VLOG(1) << "DiskMountManager Shutdown completed";
648 } 663 }
649 664
650 // static 665 // static
651 DiskMountManager* DiskMountManager::GetInstance() { 666 DiskMountManager* DiskMountManager::GetInstance() {
652 return g_disk_mount_manager; 667 return g_disk_mount_manager;
653 } 668 }
654 669
655 } // namespace disks 670 } // namespace disks
656 } // namespace chromeos 671 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698