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

Side by Side Diff: chrome/browser/media_gallery/media_device_notifications_chromeos.cc

Issue 10829384: SystemMonitor: Pull device type into the device id (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comment Created 8 years, 4 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 (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 // chromeos::MediaDeviceNotifications implementation. 5 // chromeos::MediaDeviceNotifications implementation.
6 6
7 #include "chrome/browser/media_gallery/media_device_notifications_chromeos.h" 7 #include "chrome/browser/media_gallery/media_device_notifications_chromeos.h"
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/media_gallery/media_device_notifications_utils.h" 15 #include "chrome/browser/media_gallery/media_device_notifications_utils.h"
16 #include "chrome/browser/media_gallery/media_storage_util.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 18
18 namespace chromeos { 19 namespace chromeos {
19 20
20 namespace { 21 namespace {
21 22
22 bool GetDeviceInfo(const std::string& source_path, std::string* device_id, 23 bool GetDeviceInfo(const std::string& source_path, std::string* unique_id,
23 string16* device_label) { 24 string16* device_label) {
24 // Get the media device uuid and label if exists. 25 // Get the media device uuid and label if exists.
25 const disks::DiskMountManager::Disk* disk = 26 const disks::DiskMountManager::Disk* disk =
26 disks::DiskMountManager::GetInstance()->FindDiskBySourcePath(source_path); 27 disks::DiskMountManager::GetInstance()->FindDiskBySourcePath(source_path);
27 if (!disk) 28 if (!disk)
28 return false; 29 return false;
29 30
30 *device_id = disk->fs_uuid(); 31 *unique_id = disk->fs_uuid();
31 32
32 // TODO(kmadhusu): If device label is empty, extract vendor and model details 33 // TODO(kmadhusu): If device label is empty, extract vendor and model details
33 // and use them as device_label. 34 // and use them as device_label.
34 *device_label = UTF8ToUTF16(disk->device_label().empty() ? 35 *device_label = UTF8ToUTF16(disk->device_label().empty() ?
35 FilePath(source_path).BaseName().value() : 36 FilePath(source_path).BaseName().value() :
36 disk->device_label()); 37 disk->device_label());
37 return true; 38 return true;
38 } 39 }
39 40
40 } // namespace 41 } // namespace
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 void MediaDeviceNotifications::AddMountedPathOnUIThread( 133 void MediaDeviceNotifications::AddMountedPathOnUIThread(
133 const disks::DiskMountManager::MountPointInfo& mount_info) { 134 const disks::DiskMountManager::MountPointInfo& mount_info) {
134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
135 136
136 if (ContainsKey(mount_map_, mount_info.mount_path)) { 137 if (ContainsKey(mount_map_, mount_info.mount_path)) {
137 NOTREACHED(); 138 NOTREACHED();
138 return; 139 return;
139 } 140 }
140 141
141 // Get the media device uuid and label if exists. 142 // Get the media device uuid and label if exists.
142 std::string device_id; 143 std::string unique_id;
143 string16 device_label; 144 string16 device_label;
144 if (!GetDeviceInfo(mount_info.source_path, &device_id, &device_label)) 145 if (!GetDeviceInfo(mount_info.source_path, &unique_id, &device_label))
145 return; 146 return;
146 147
147 // Keep track of device uuid, to see how often we receive empty uuid values. 148 // Keep track of device uuid, to see how often we receive empty uuid values.
148 UMA_HISTOGRAM_BOOLEAN("MediaDeviceNotification.device_uuid_available", 149 UMA_HISTOGRAM_BOOLEAN("MediaDeviceNotification.device_uuid_available",
149 !device_id.empty()); 150 !unique_id.empty());
150 if (device_id.empty()) 151 if (unique_id.empty())
151 return; 152 return;
152 153
154 std::string device_id = chrome::MediaStorageUtil::MakeDeviceId(
155 chrome::MediaStorageUtil::USB_MASS_STORAGE_WITH_DCIM, unique_id);
153 mount_map_.insert(std::make_pair(mount_info.mount_path, device_id)); 156 mount_map_.insert(std::make_pair(mount_info.mount_path, device_id));
154 base::SystemMonitor::Get()->ProcessMediaDeviceAttached( 157 base::SystemMonitor::Get()->ProcessMediaDeviceAttached(device_id,
155 device_id, 158 device_label,
156 device_label, 159 mount_info.mount_path);
157 base::SystemMonitor::TYPE_PATH,
158 mount_info.mount_path);
159 } 160 }
160 161
161 } // namespace chrome 162 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698