OLD | NEW |
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 #include "chrome/browser/extensions/api/serial/serial_connection.h" | 5 #include "chrome/browser/extensions/api/serial/serial_connection.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 return PostOpen(); | 47 return PostOpen(); |
48 } | 48 } |
49 | 49 |
50 void SerialConnection::Close() { | 50 void SerialConnection::Close() { |
51 if (file_ != base::kInvalidPlatformFileValue) { | 51 if (file_ != base::kInvalidPlatformFileValue) { |
52 base::ClosePlatformFile(file_); | 52 base::ClosePlatformFile(file_); |
53 file_ = base::kInvalidPlatformFileValue; | 53 file_ = base::kInvalidPlatformFileValue; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 int SerialConnection::Read(uint8* byte) { | 57 int SerialConnection::Read(scoped_refptr<net::IOBufferWithSize> io_buffer) { |
58 DCHECK(byte); | 58 DCHECK(io_buffer->data()); |
59 return base::ReadPlatformFileAtCurrentPos(file_, | 59 return base::ReadPlatformFileAtCurrentPos(file_, |
60 reinterpret_cast<char*>(byte), 1); | 60 io_buffer->data(), |
| 61 io_buffer->size()); |
61 } | 62 } |
62 | 63 |
63 int SerialConnection::Write(scoped_refptr<net::IOBuffer> io_buffer, | 64 int SerialConnection::Write(scoped_refptr<net::IOBuffer> io_buffer, |
64 int byte_count) { | 65 int byte_count) { |
65 DCHECK(io_buffer->data()); | 66 DCHECK(io_buffer->data()); |
66 DCHECK(byte_count >= 0); | 67 DCHECK(byte_count >= 0); |
67 return base::WritePlatformFileAtCurrentPos(file_, | 68 return base::WritePlatformFileAtCurrentPos(file_, |
68 io_buffer->data(), byte_count); | 69 io_buffer->data(), byte_count); |
69 } | 70 } |
70 | 71 |
71 void SerialConnection::Flush() { | 72 void SerialConnection::Flush() { |
72 base::FlushPlatformFile(file_); | 73 base::FlushPlatformFile(file_); |
73 } | 74 } |
74 | 75 |
75 } // namespace extensions | 76 } // namespace extensions |
OLD | NEW |