diff options
author | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-21 02:56:43 +0000 |
---|---|---|
committer | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-21 02:56:43 +0000 |
commit | 65f0d75865cade8b2b59c5eef9986f3f45119384 (patch) | |
tree | 8b6b48a3f55cbd1b894f069f9d93b2a1d85b8a10 /device/hid/hid_connection_linux.cc | |
parent | ea3ab1b97ba817fcec92769a25fd9bb1c9ec7f81 (diff) | |
download | chromium_src-65f0d75865cade8b2b59c5eef9986f3f45119384.zip chromium_src-65f0d75865cade8b2b59c5eef9986f3f45119384.tar.gz chromium_src-65f0d75865cade8b2b59c5eef9986f3f45119384.tar.bz2 |
Remove PlatformFile from device/hid
BUG=322664
R=rockot@chromium.org
Review URL: https://codereview.chromium.org/173003002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device/hid/hid_connection_linux.cc')
-rw-r--r-- | device/hid/hid_connection_linux.cc | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/device/hid/hid_connection_linux.cc b/device/hid/hid_connection_linux.cc index 0722fab..1491ba6 100644 --- a/device/hid/hid_connection_linux.cc +++ b/device/hid/hid_connection_linux.cc @@ -37,33 +37,26 @@ HidConnectionLinux::HidConnectionLinux(HidDeviceInfo device_info, return; } - base::PlatformFileError error; - - int flags = base::PLATFORM_FILE_OPEN | - base::PLATFORM_FILE_READ | - base::PLATFORM_FILE_WRITE | - base::PLATFORM_FILE_EXCLUSIVE_READ | - base::PLATFORM_FILE_EXCLUSIVE_WRITE; - - base::PlatformFile device_file = base::CreatePlatformFile( - base::FilePath(dev_node), - flags, - NULL, - &error); - if (error || device_file <= 0) { - LOG(ERROR) << error; - if (device_file) - base::ClosePlatformFile(device_file); + int flags = base::File::FLAG_OPEN | + base::File::FLAG_READ | + base::File::FLAG_WRITE | + base::File::FLAG_EXCLUSIVE_READ | + base::File::FLAG_EXCLUSIVE_WRITE; + + base::File device_file(base::FilePath(dev_node), flags); + if (!device_file.IsValid()) { + LOG(ERROR) << device_file.error_details(); return; } - if (fcntl(device_file, F_SETFL, fcntl(device_file, F_GETFL) | O_NONBLOCK)) { + if (fcntl(device_file.GetPlatformFile(), F_SETFL, + fcntl(device_file.GetPlatformFile(), F_GETFL) | O_NONBLOCK)) { PLOG(ERROR) << "Failed to set non-blocking flag to device file."; return; } - device_file_ = device_file; + device_file_ = device_file.Pass(); if (!base::MessageLoopForIO::current()->WatchFileDescriptor( - device_file_, + device_file_.GetPlatformFile(), true, base::MessageLoopForIO::WATCH_READ_WRITE, &device_file_watcher_, @@ -82,11 +75,11 @@ HidConnectionLinux::~HidConnectionLinux() { void HidConnectionLinux::OnFileCanReadWithoutBlocking(int fd) { DCHECK(thread_checker_.CalledOnValidThread()); - DCHECK_EQ(fd, device_file_); + DCHECK_EQ(fd, device_file_.GetPlatformFile()); DCHECK(initialized_); uint8 buffer[1024] = {0}; - int bytes = read(device_file_, buffer, 1024); + int bytes = read(device_file_.GetPlatformFile(), buffer, 1024); if (bytes < 0) { if (errno == EAGAIN) { return; @@ -110,7 +103,7 @@ void HidConnectionLinux::Disconnect() { initialized_ = false; device_file_watcher_.StopWatchingFileDescriptor(); - close(device_file_); + device_file_.Close(); while (!read_queue_.empty()) { PendingRequest callback = read_queue_.front(); read_queue_.pop(); @@ -145,7 +138,7 @@ void HidConnectionLinux::Write(scoped_refptr<net::IOBuffer> buffer, callback.Run(false, 0); return; } else { - int bytes = write(device_file_, buffer->data(), size); + int bytes = write(device_file_.GetPlatformFile(), buffer->data(), size); if (bytes < 0) { Disconnect(); callback.Run(false, 0); |