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

Side by Side Diff: chrome/browser/usb/usb_device.cc

Issue 22492003: Fixes leaking transfer objects due to improper USB handle closure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor fix 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
« no previous file with comments | « chrome/browser/extensions/api/usb/usb_api.cc ('k') | chrome/browser/usb/usb_device_handle.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/usb/usb_device.h" 5 #include "chrome/browser/usb/usb_device.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/usb/usb_context.h" 10 #include "chrome/browser/usb/usb_context.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 STLClearObject(&handles_); 44 STLClearObject(&handles_);
45 libusb_unref_device(platform_device_); 45 libusb_unref_device(platform_device_);
46 } 46 }
47 47
48 scoped_refptr<UsbDeviceHandle> UsbDevice::Open() { 48 scoped_refptr<UsbDeviceHandle> UsbDevice::Open() {
49 DCHECK(thread_checker_.CalledOnValidThread()); 49 DCHECK(thread_checker_.CalledOnValidThread());
50 PlatformUsbDeviceHandle handle; 50 PlatformUsbDeviceHandle handle;
51 int rv = libusb_open(platform_device_, &handle); 51 int rv = libusb_open(platform_device_, &handle);
52 if (LIBUSB_SUCCESS == rv) { 52 if (LIBUSB_SUCCESS == rv) {
53 scoped_refptr<UsbDeviceHandle> device_handle = 53 scoped_refptr<UsbDeviceHandle> device_handle =
54 new UsbDeviceHandle(this, handle); 54 new UsbDeviceHandle(context_, this, handle);
55 handles_.push_back(device_handle); 55 handles_.push_back(device_handle);
56 return device_handle; 56 return device_handle;
57 } 57 }
58 return NULL; 58 return NULL;
59 } 59 }
60 60
61 bool UsbDevice::Close(scoped_refptr<UsbDeviceHandle> handle) { 61 bool UsbDevice::Close(scoped_refptr<UsbDeviceHandle> handle) {
62 DCHECK(thread_checker_.CalledOnValidThread()); 62 DCHECK(thread_checker_.CalledOnValidThread());
63 63
64 for (HandlesVector::iterator it = handles_.begin(); 64 for (HandlesVector::iterator it = handles_.begin();
(...skipping 24 matching lines...) Expand all
89 DCHECK(thread_checker_.CalledOnValidThread()); 89 DCHECK(thread_checker_.CalledOnValidThread());
90 HandlesVector handles; 90 HandlesVector handles;
91 swap(handles, handles_); 91 swap(handles, handles_);
92 for (std::vector<scoped_refptr<UsbDeviceHandle> >::iterator it = 92 for (std::vector<scoped_refptr<UsbDeviceHandle> >::iterator it =
93 handles.begin(); 93 handles.begin();
94 it != handles.end(); 94 it != handles.end();
95 ++it) { 95 ++it) {
96 (*it)->InternalClose(); 96 (*it)->InternalClose();
97 } 97 }
98 } 98 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/usb/usb_api.cc ('k') | chrome/browser/usb/usb_device_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698