| 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" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 | 13 |
| 14 const char kSerialConnectionNotFoundError[] = "Serial connection not found"; | 14 const char kSerialConnectionNotFoundError[] = "Serial connection not found"; |
| 15 | 15 |
| 16 SerialConnection::SerialConnection(const std::string& port, | 16 SerialConnection::SerialConnection(const std::string& port, |
| 17 int bitrate, | 17 int bitrate, |
| 18 APIResourceEventNotifier* event_notifier) | 18 ApiResourceEventNotifier* event_notifier) |
| 19 : APIResource(APIResource::SerialConnectionResource, event_notifier), | 19 : ApiResource(event_notifier), |
| 20 port_(port), | 20 port_(port), |
| 21 bitrate_(bitrate), | 21 bitrate_(bitrate), |
| 22 file_(base::kInvalidPlatformFileValue) { | 22 file_(base::kInvalidPlatformFileValue) { |
| 23 CHECK(bitrate >= 0); | 23 CHECK(bitrate >= 0); |
| 24 } | 24 } |
| 25 | 25 |
| 26 SerialConnection::~SerialConnection() { | 26 SerialConnection::~SerialConnection() { |
| 27 Close(); | 27 Close(); |
| 28 } | 28 } |
| 29 | 29 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 DCHECK(byte_count >= 0); | 66 DCHECK(byte_count >= 0); |
| 67 return base::WritePlatformFileAtCurrentPos(file_, | 67 return base::WritePlatformFileAtCurrentPos(file_, |
| 68 io_buffer->data(), byte_count); | 68 io_buffer->data(), byte_count); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void SerialConnection::Flush() { | 71 void SerialConnection::Flush() { |
| 72 base::FlushPlatformFile(file_); | 72 base::FlushPlatformFile(file_); |
| 73 } | 73 } |
| 74 | 74 |
| 75 } // namespace extensions | 75 } // namespace extensions |
| OLD | NEW |