| 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_api.h" | 5 #include "chrome/browser/extensions/api/serial/serial_api.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/extensions/api/api_resource_controller.h" | 8 #include "chrome/browser/extensions/api/api_resource_controller.h" |
| 9 #include "chrome/browser/extensions/api/serial/serial_connection.h" | 9 #include "chrome/browser/extensions/api/serial/serial_connection.h" |
| 10 #include "chrome/browser/extensions/api/serial/serial_port_enumerator.h" | 10 #include "chrome/browser/extensions/api/serial/serial_port_enumerator.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 208 |
| 209 SerialWriteFunction::~SerialWriteFunction() { | 209 SerialWriteFunction::~SerialWriteFunction() { |
| 210 } | 210 } |
| 211 | 211 |
| 212 bool SerialWriteFunction::Prepare() { | 212 bool SerialWriteFunction::Prepare() { |
| 213 set_work_thread_id(BrowserThread::FILE); | 213 set_work_thread_id(BrowserThread::FILE); |
| 214 | 214 |
| 215 params_ = api::experimental_serial::Write::Params::Create(*args_); | 215 params_ = api::experimental_serial::Write::Params::Create(*args_); |
| 216 EXTENSION_FUNCTION_VALIDATE(params_.get()); | 216 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| 217 | 217 |
| 218 io_buffer_size_ = params_->data->GetSize(); | 218 io_buffer_size_ = params_->data.size(); |
| 219 io_buffer_ = new net::WrappedIOBuffer(params_->data->GetBuffer()); | 219 io_buffer_ = new net::WrappedIOBuffer(params_->data.data()); |
| 220 | 220 |
| 221 return true; | 221 return true; |
| 222 } | 222 } |
| 223 | 223 |
| 224 void SerialWriteFunction::Work() { | 224 void SerialWriteFunction::Work() { |
| 225 int bytes_written = -1; | 225 int bytes_written = -1; |
| 226 SerialConnection* serial_connection = | 226 SerialConnection* serial_connection = |
| 227 controller()->GetSerialConnection(params_->connection_id); | 227 controller()->GetSerialConnection(params_->connection_id); |
| 228 if (serial_connection) | 228 if (serial_connection) |
| 229 bytes_written = serial_connection->Write(io_buffer_, io_buffer_size_); | 229 bytes_written = serial_connection->Write(io_buffer_, io_buffer_size_); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 263 } |
| 264 | 264 |
| 265 result_.reset(Value::CreateBooleanValue(flush_result)); | 265 result_.reset(Value::CreateBooleanValue(flush_result)); |
| 266 } | 266 } |
| 267 | 267 |
| 268 bool SerialFlushFunction::Respond() { | 268 bool SerialFlushFunction::Respond() { |
| 269 return true; | 269 return true; |
| 270 } | 270 } |
| 271 | 271 |
| 272 } // namespace extensions | 272 } // namespace extensions |
| OLD | NEW |