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

Side by Side Diff: device/hid/hid_connection_win.cc

Issue 240263003: HID : read-only device access fallback when read/write fails (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove vertical whitespace Created 6 years, 8 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
« no previous file with comments | « device/hid/hid_connection_linux.cc ('k') | device/hid/hid_service_win.cc » ('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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 "device/hid/hid_connection_win.h" 5 #include "device/hid/hid_connection_win.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
Ken Rockot(use gerrit already) 2014/04/23 23:24:28 Looks like you forgot to include base/files/file.h
jracle (use Gerrit) 2014/04/24 08:30:48 Oops wtf
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
12 #include "base/win/object_watcher.h" 12 #include "base/win/object_watcher.h"
13 #include "base/win/scoped_handle.h" 13 #include "base/win/scoped_handle.h"
14 #include "device/hid/hid_service.h" 14 #include "device/hid/hid_service.h"
15 #include "device/hid/hid_service_win.h" 15 #include "device/hid/hid_service_win.h"
16 16
17 #define INITGUID 17 #define INITGUID
18 18
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 HidConnectionWin::HidConnectionWin(const HidDeviceInfo& device_info) 103 HidConnectionWin::HidConnectionWin(const HidDeviceInfo& device_info)
104 : HidConnection(device_info) { 104 : HidConnection(device_info) {
105 DCHECK(thread_checker_.CalledOnValidThread()); 105 DCHECK(thread_checker_.CalledOnValidThread());
106 file_.Set(CreateFileA(device_info.device_id.c_str(), 106 file_.Set(CreateFileA(device_info.device_id.c_str(),
107 GENERIC_WRITE | GENERIC_READ, 107 GENERIC_WRITE | GENERIC_READ,
108 FILE_SHARE_READ | FILE_SHARE_WRITE, 108 FILE_SHARE_READ | FILE_SHARE_WRITE,
109 NULL, 109 NULL,
110 OPEN_EXISTING, 110 OPEN_EXISTING,
111 FILE_FLAG_OVERLAPPED, 111 FILE_FLAG_OVERLAPPED,
112 NULL)); 112 NULL));
113
114 if (!file_.IsValid() &&
115 file_.error_details() == base::File::FILE_ERROR_ACCESS_DENIED) {
116 file_.Set(CreateFileA(device_info.device_id.c_str(),
117 GENERIC_READ,
118 FILE_SHARE_READ,
119 NULL,
120 OPEN_EXISTING,
121 FILE_FLAG_OVERLAPPED,
122 NULL));
123 }
113 } 124 }
114 125
115 bool HidConnectionWin::available() const { 126 bool HidConnectionWin::available() const {
116 return file_.IsValid(); 127 return file_.IsValid();
117 } 128 }
118 129
119 HidConnectionWin::~HidConnectionWin() { 130 HidConnectionWin::~HidConnectionWin() {
120 DCHECK(thread_checker_.CalledOnValidThread()); 131 DCHECK(thread_checker_.CalledOnValidThread());
121 CancelIo(file_.Get()); 132 CancelIo(file_.Get());
122 } 133 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 290 }
280 } 291 }
281 292
282 void HidConnectionWin::OnTransferCanceled( 293 void HidConnectionWin::OnTransferCanceled(
283 scoped_refptr<PendingHidTransfer> transfer) { 294 scoped_refptr<PendingHidTransfer> transfer) {
284 transfers_.erase(transfer); 295 transfers_.erase(transfer);
285 transfer->callback_.Run(false, 0); 296 transfer->callback_.Run(false, 0);
286 } 297 }
287 298
288 } // namespace device 299 } // namespace device
OLDNEW
« no previous file with comments | « device/hid/hid_connection_linux.cc ('k') | device/hid/hid_service_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698