| 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 const std::string& owner_extension_id, |
| 18 ApiResourceEventNotifier* event_notifier) | 19 ApiResourceEventNotifier* event_notifier) |
| 19 : ApiResource(event_notifier), | 20 : ApiResource(owner_extension_id, event_notifier), |
| 20 port_(port), | 21 port_(port), |
| 21 bitrate_(bitrate), | 22 bitrate_(bitrate), |
| 22 file_(base::kInvalidPlatformFileValue) { | 23 file_(base::kInvalidPlatformFileValue) { |
| 23 CHECK(bitrate >= 0); | 24 CHECK(bitrate >= 0); |
| 24 } | 25 } |
| 25 | 26 |
| 26 SerialConnection::~SerialConnection() { | 27 SerialConnection::~SerialConnection() { |
| 27 Close(); | 28 Close(); |
| 28 } | 29 } |
| 29 | 30 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 DCHECK(byte_count >= 0); | 68 DCHECK(byte_count >= 0); |
| 68 return base::WritePlatformFileAtCurrentPos(file_, | 69 return base::WritePlatformFileAtCurrentPos(file_, |
| 69 io_buffer->data(), byte_count); | 70 io_buffer->data(), byte_count); |
| 70 } | 71 } |
| 71 | 72 |
| 72 void SerialConnection::Flush() { | 73 void SerialConnection::Flush() { |
| 73 base::FlushPlatformFile(file_); | 74 base::FlushPlatformFile(file_); |
| 74 } | 75 } |
| 75 | 76 |
| 76 } // namespace extensions | 77 } // namespace extensions |
| OLD | NEW |