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

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

Issue 10830003: Extract and dispatch device uuid in media device attached notification message. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactor 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"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 BrowserThread::PostTask( 66 BrowserThread::PostTask(
67 BrowserThread::FILE, FROM_HERE, 67 BrowserThread::FILE, FROM_HERE,
68 base::Bind(&MediaDeviceNotifications::CheckMountedPathOnFileThread, 68 base::Bind(&MediaDeviceNotifications::CheckMountedPathOnFileThread,
69 this, mount_info)); 69 this, mount_info));
70 break; 70 break;
71 } 71 }
72 case disks::DiskMountManager::UNMOUNTING: { 72 case disks::DiskMountManager::UNMOUNTING: {
73 MountMap::iterator it = mount_map_.find(mount_info.mount_path); 73 MountMap::iterator it = mount_map_.find(mount_info.mount_path);
74 if (it == mount_map_.end()) 74 if (it == mount_map_.end())
75 return; 75 return;
76
77 LOG(ERROR) << "UNMOUNTING DEVICE ID: " << it->second << "\n";
76 base::SystemMonitor::Get()->ProcessMediaDeviceDetached(it->second); 78 base::SystemMonitor::Get()->ProcessMediaDeviceDetached(it->second);
77 mount_map_.erase(it); 79 mount_map_.erase(it);
78 break; 80 break;
79 } 81 }
80 } 82 }
81 } 83 }
82 84
83 void MediaDeviceNotifications::CheckMountedPathOnFileThread( 85 void MediaDeviceNotifications::CheckMountedPathOnFileThread(
84 const disks::DiskMountManager::MountPointInfo& mount_info) { 86 const disks::DiskMountManager::MountPointInfo& mount_info) {
85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
86 88
87 if (!chrome::IsMediaDevice(mount_info.mount_path)) 89 if (!chrome::IsMediaDevice(mount_info.mount_path))
88 return; 90 return;
89 91
90 BrowserThread::PostTask( 92 BrowserThread::PostTask(
91 BrowserThread::UI, FROM_HERE, 93 BrowserThread::UI, FROM_HERE,
92 base::Bind(&MediaDeviceNotifications::AddMountedPathOnUIThread, 94 base::Bind(&MediaDeviceNotifications::AddMountedPathOnUIThread,
93 this, mount_info)); 95 this, mount_info));
94 } 96 }
95 97
96 void MediaDeviceNotifications::AddMountedPathOnUIThread( 98 void MediaDeviceNotifications::AddMountedPathOnUIThread(
97 const disks::DiskMountManager::MountPointInfo& mount_info) { 99 const disks::DiskMountManager::MountPointInfo& mount_info) {
98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
99 101
100 if (ContainsKey(mount_map_, mount_info.mount_path)) { 102 if (ContainsKey(mount_map_, mount_info.mount_path)) {
101 NOTREACHED(); 103 NOTREACHED();
102 return; 104 return;
103 } 105 }
104 const std::string device_id_str = base::IntToString(current_device_id_++); 106
107 // Get the media device uuid if exists.
108 const disks::DiskMountManager::DiskMap& disks =
109 disks::DiskMountManager::GetInstance()->disks();
110 disks::DiskMountManager::DiskMap::const_iterator iter =
111 disks.find(mount_info.source_path);
112 std::string device_id_str;
113 if (iter != disks.end()) {
Lei Zhang 2012/07/26 02:17:32 nit: would you mind using |it| instead of |iter| t
Lei Zhang 2012/07/26 02:17:32 If I understand the disk manager code correctly, I
kmadhusu 2012/07/26 17:01:23 Done.
kmadhusu 2012/07/26 17:01:23 I was not able to use CHECK_NE. Why do you think i
114 const disks::DiskMountManager::Disk& disk = *iter->second;
115 device_id_str = disk.fs_uuid();
116 }
117 // TODO(kmadhusu, thestig): Set the unique id for mtp devices.
118 if (device_id_str.empty())
119 device_id_str = base::IntToString(current_device_id_++);
Lei Zhang 2012/07/26 02:17:32 You should get rid of |current_device_id_|. Trying
kmadhusu 2012/07/26 17:01:23 Done.
120
121 LOG(ERROR) << "MOUNTING DEVICE ID: " << device_id_str << "\n";
122
105 mount_map_.insert(std::make_pair(mount_info.mount_path, device_id_str)); 123 mount_map_.insert(std::make_pair(mount_info.mount_path, device_id_str));
106 base::SystemMonitor::Get()->ProcessMediaDeviceAttached( 124 base::SystemMonitor::Get()->ProcessMediaDeviceAttached(
107 device_id_str, 125 device_id_str,
108 UTF8ToUTF16(FilePath(mount_info.source_path).BaseName().value()), 126 UTF8ToUTF16(FilePath(mount_info.source_path).BaseName().value()),
109 base::SystemMonitor::TYPE_PATH, 127 base::SystemMonitor::TYPE_PATH,
110 mount_info.mount_path); 128 mount_info.mount_path);
111 } 129 }
112 130
113 } // namespace chrome 131 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_private_apitest.cc ('k') | chromeos/dbus/cros_disks_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698