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

Side by Side Diff: chrome/browser/system_monitor/portable_device_watcher_win.cc

Issue 11297002: [Media Gallery] Added code to support mtp device media file system on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + Fixed win compile error by implementing GetMTPStorageInfoFromDeviceId in TestStorageNotifi… Created 7 years, 11 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 // Any tasks that communicates with the portable device may take >100ms to 5 // Any tasks that communicates with the portable device may take >100ms to
6 // complete. Those tasks should be run on an blocking thread instead of the 6 // complete. Those tasks should be run on an blocking thread instead of the
7 // UI thread. 7 // UI thread.
8 8
9 #include "chrome/browser/system_monitor/portable_device_watcher_win.h" 9 #include "chrome/browser/system_monitor/portable_device_watcher_win.h"
10 10
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 if (!IsPortableDeviceStructure(data)) 509 if (!IsPortableDeviceStructure(data))
510 return; 510 return;
511 511
512 string16 device_id = GetPnpDeviceId(data); 512 string16 device_id = GetPnpDeviceId(data);
513 if (event_type == DBT_DEVICEARRIVAL) 513 if (event_type == DBT_DEVICEARRIVAL)
514 HandleDeviceAttachEvent(device_id); 514 HandleDeviceAttachEvent(device_id);
515 else if (event_type == DBT_DEVICEREMOVECOMPLETE) 515 else if (event_type == DBT_DEVICEREMOVECOMPLETE)
516 HandleDeviceDetachEvent(device_id); 516 HandleDeviceDetachEvent(device_id);
517 } 517 }
518 518
519 bool PortableDeviceWatcherWin::GetMTPStorageInfoFromDeviceId(
520 const std::string& storage_device_id,
521 string16* device_location,
522 string16* storage_object_id) {
523 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
524 DCHECK(device_location);
525 DCHECK(storage_object_id);
526 MTPStorageMap::const_iterator storage_map_iter =
527 storage_map_.find(storage_device_id);
528 if (storage_map_iter == storage_map_.end())
529 return false;
530
531 MTPDeviceMap::const_iterator device_iter =
532 device_map_.find(storage_map_iter->second.location);
533 if (device_iter == device_map_.end())
534 return false;
535 const StorageObjects& storage_objects = device_iter->second;
536 for (StorageObjects::const_iterator storage_object_iter =
537 storage_objects.begin(); storage_object_iter != storage_objects.end();
538 ++storage_object_iter) {
539 if (storage_device_id == storage_object_iter->object_persistent_id) {
540 *device_location = storage_map_iter->second.location;
541 *storage_object_id = storage_object_iter->object_temporary_id;
542 return true;
543 }
544 }
545 return false;
546 }
547
519 void PortableDeviceWatcherWin::EnumerateAttachedDevices() { 548 void PortableDeviceWatcherWin::EnumerateAttachedDevices() {
520 DCHECK(media_task_runner_.get()); 549 DCHECK(media_task_runner_.get());
521 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 550 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
522 Devices* devices = new Devices; 551 Devices* devices = new Devices;
523 base::PostTaskAndReplyWithResult( 552 base::PostTaskAndReplyWithResult(
524 media_task_runner_, 553 media_task_runner_,
525 FROM_HERE, 554 FROM_HERE,
526 base::Bind(&EnumerateAttachedDevicesOnBlockingThread, devices), 555 base::Bind(&EnumerateAttachedDevicesOnBlockingThread, devices),
527 base::Bind(&PortableDeviceWatcherWin::OnDidEnumerateAttachedDevices, 556 base::Bind(&PortableDeviceWatcherWin::OnDidEnumerateAttachedDevices,
528 weak_ptr_factory_.GetWeakPtr(), base::Owned(devices))); 557 weak_ptr_factory_.GetWeakPtr(), base::Owned(devices)));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 MTPStorageMap::iterator storage_map_iter = storage_map_.find(storage_id); 638 MTPStorageMap::iterator storage_map_iter = storage_map_.find(storage_id);
610 DCHECK(storage_map_iter != storage_map_.end()); 639 DCHECK(storage_map_iter != storage_map_.end());
611 system_monitor->ProcessRemovableStorageDetached( 640 system_monitor->ProcessRemovableStorageDetached(
612 storage_map_iter->second.device_id); 641 storage_map_iter->second.device_id);
613 storage_map_.erase(storage_map_iter); 642 storage_map_.erase(storage_map_iter);
614 } 643 }
615 device_map_.erase(device_iter); 644 device_map_.erase(device_iter);
616 } 645 }
617 646
618 } // namespace chrome 647 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698