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

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

Issue 23383009: [StorageMonitor] Handle EjectDevice call for MTP devices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 // 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/storage_monitor/portable_device_watcher_win.h" 9 #include "chrome/browser/storage_monitor/portable_device_watcher_win.h"
10 10
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 } 548 }
549 549
550 void PortableDeviceWatcherWin::SetNotifications( 550 void PortableDeviceWatcherWin::SetNotifications(
551 StorageMonitor::Receiver* notifications) { 551 StorageMonitor::Receiver* notifications) {
552 storage_notifications_ = notifications; 552 storage_notifications_ = notifications;
553 } 553 }
554 554
555 void PortableDeviceWatcherWin::EjectDevice( 555 void PortableDeviceWatcherWin::EjectDevice(
556 const std::string& device_id, 556 const std::string& device_id,
557 base::Callback<void(StorageMonitor::EjectStatus)> callback) { 557 base::Callback<void(StorageMonitor::EjectStatus)> callback) {
558 callback.Run(chrome::StorageMonitor::EJECT_FAILURE); 558 // MTP devices on windows don't have a detach API needed -- signal
Lei Zhang 2013/08/21 21:37:53 nit: Windows
Greg Billock 2013/08/23 20:17:14 Done.
559 // the object as if the device is gone and tell the caller it is OK
560 // to remove.
561 string16 device_location; // the device_map_ key
562 string16 storage_object_id;
563 if (!GetMTPStorageInfoFromDeviceId(device_id,
564 &device_location, &storage_object_id)) {
565 callback.Run(chrome::StorageMonitor::EJECT_NO_SUCH_DEVICE);
566 return;
567 }
568 HandleDeviceDetachEvent(device_location);
569
570 callback.Run(chrome::StorageMonitor::EJECT_OK);
559 } 571 }
560 572
561 void PortableDeviceWatcherWin::EnumerateAttachedDevices() { 573 void PortableDeviceWatcherWin::EnumerateAttachedDevices() {
562 DCHECK(media_task_runner_.get()); 574 DCHECK(media_task_runner_.get());
563 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 575 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
564 Devices* devices = new Devices; 576 Devices* devices = new Devices;
565 base::PostTaskAndReplyWithResult( 577 base::PostTaskAndReplyWithResult(
566 media_task_runner_, 578 media_task_runner_,
567 FROM_HERE, 579 FROM_HERE,
568 base::Bind(&EnumerateAttachedDevicesOnBlockingThread, devices), 580 base::Bind(&EnumerateAttachedDevicesOnBlockingThread, devices),
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 if (storage_notifications_) { 662 if (storage_notifications_) {
651 storage_notifications_->ProcessDetach( 663 storage_notifications_->ProcessDetach(
652 storage_map_iter->second.device_id()); 664 storage_map_iter->second.device_id());
653 } 665 }
654 storage_map_.erase(storage_map_iter); 666 storage_map_.erase(storage_map_iter);
655 } 667 }
656 device_map_.erase(device_iter); 668 device_map_.erase(device_iter);
657 } 669 }
658 670
659 } // namespace chrome 671 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698