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

Side by Side Diff: chrome/browser/chromeos/file_manager/volume_manager.cc

Issue 267573005: UMA stats for MTP file system in Chrome OS Files.app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Count for all types of volumes. Created 6 years, 7 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/file_manager/volume_manager.h" 5 #include "chrome/browser/chromeos/file_manager/volume_manager.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/metrics/histogram.h"
14 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 17 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
17 #include "chrome/browser/chromeos/drive/file_errors.h" 18 #include "chrome/browser/chromeos/drive/file_errors.h"
18 #include "chrome/browser/chromeos/drive/file_system_interface.h" 19 #include "chrome/browser/chromeos/drive/file_system_interface.h"
19 #include "chrome/browser/chromeos/drive/file_system_util.h" 20 #include "chrome/browser/chromeos/drive/file_system_util.h"
20 #include "chrome/browser/chromeos/file_manager/mounted_disk_monitor.h" 21 #include "chrome/browser/chromeos/file_manager/mounted_disk_monitor.h"
21 #include "chrome/browser/chromeos/file_manager/path_util.h" 22 #include "chrome/browser/chromeos/file_manager/path_util.h"
22 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" 23 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h"
23 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" 24 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 case VOLUME_TYPE_MOUNTED_ARCHIVE_FILE: 105 case VOLUME_TYPE_MOUNTED_ARCHIVE_FILE:
105 return "archive"; 106 return "archive";
106 case VOLUME_TYPE_CLOUD_DEVICE: 107 case VOLUME_TYPE_CLOUD_DEVICE:
107 return "cloud_device"; 108 return "cloud_device";
108 case VOLUME_TYPE_PROVIDED: 109 case VOLUME_TYPE_PROVIDED:
109 return "provided"; 110 return "provided";
110 case VOLUME_TYPE_MTP: 111 case VOLUME_TYPE_MTP:
111 return "mtp"; 112 return "mtp";
112 case VOLUME_TYPE_TESTING: 113 case VOLUME_TYPE_TESTING:
113 return "testing"; 114 return "testing";
115 case NUM_VOLUME_TYPE:
116 break;
114 } 117 }
115 NOTREACHED(); 118 NOTREACHED();
116 return ""; 119 return "";
117 } 120 }
118 121
119 // Generates a unique volume ID for the given volume info. 122 // Generates a unique volume ID for the given volume info.
120 std::string GenerateVolumeId(const VolumeInfo& volume_info) { 123 std::string GenerateVolumeId(const VolumeInfo& volume_info) {
121 // For the same volume type, base names are unique, as mount points are 124 // For the same volume type, base names are unique, as mount points are
122 // flat for the same volume type. 125 // flat for the same volume type.
123 return (VolumeTypeToString(volume_info.type) + ":" + 126 return (VolumeTypeToString(volume_info.type) + ":" +
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 if (!from_current_profile) 797 if (!from_current_profile)
795 return; 798 return;
796 } 799 }
797 800
798 // Filter out removable disks if forbidden by policy for this profile. 801 // Filter out removable disks if forbidden by policy for this profile.
799 if (volume_info.type == VOLUME_TYPE_REMOVABLE_DISK_PARTITION && 802 if (volume_info.type == VOLUME_TYPE_REMOVABLE_DISK_PARTITION &&
800 profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { 803 profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) {
801 return; 804 return;
802 } 805 }
803 806
804 if (error_code == chromeos::MOUNT_ERROR_NONE || volume_info.mount_condition) 807 if (error_code == chromeos::MOUNT_ERROR_NONE || volume_info.mount_condition) {
805 mounted_volumes_[volume_info.volume_id] = volume_info; 808 mounted_volumes_[volume_info.volume_id] = volume_info;
806 809
810 if (!is_remounting) {
811 UMA_HISTOGRAM_ENUMERATION("FileBrowser.VolumeType",
812 volume_info.type,
813 NUM_VOLUME_TYPE);
814 }
815 }
816
807 FOR_EACH_OBSERVER(VolumeManagerObserver, 817 FOR_EACH_OBSERVER(VolumeManagerObserver,
808 observers_, 818 observers_,
809 OnVolumeMounted(error_code, volume_info, is_remounting)); 819 OnVolumeMounted(error_code, volume_info, is_remounting));
810 } 820 }
811 821
812 void VolumeManager::DoUnmountEvent(chromeos::MountError error_code, 822 void VolumeManager::DoUnmountEvent(chromeos::MountError error_code,
813 const VolumeInfo& volume_info) { 823 const VolumeInfo& volume_info) {
814 if (mounted_volumes_.find(volume_info.volume_id) == mounted_volumes_.end()) 824 if (mounted_volumes_.find(volume_info.volume_id) == mounted_volumes_.end())
815 return; 825 return;
816 if (error_code == chromeos::MOUNT_ERROR_NONE) 826 if (error_code == chromeos::MOUNT_ERROR_NONE)
817 mounted_volumes_.erase(volume_info.volume_id); 827 mounted_volumes_.erase(volume_info.volume_id);
818 828
819 FOR_EACH_OBSERVER(VolumeManagerObserver, 829 FOR_EACH_OBSERVER(VolumeManagerObserver,
820 observers_, 830 observers_,
821 OnVolumeUnmounted(error_code, volume_info)); 831 OnVolumeUnmounted(error_code, volume_info));
822 } 832 }
823 833
824 } // namespace file_manager 834 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698