Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: device/serial/buffer.cc

Issue 1471043004: Convert various vector_as_array calls to vector::data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/numerics/safe_conversions.h" 5 #include "base/numerics/safe_conversions.h"
6 #include "base/stl_util.h"
7 #include "device/serial/buffer.h" 6 #include "device/serial/buffer.h"
8 #include "net/base/io_buffer.h" 7 #include "net/base/io_buffer.h"
9 8
10 namespace device { 9 namespace device {
11 10
12 ReadOnlyBuffer::~ReadOnlyBuffer() { 11 ReadOnlyBuffer::~ReadOnlyBuffer() {
13 } 12 }
14 13
15 WritableBuffer::~WritableBuffer() { 14 WritableBuffer::~WritableBuffer() {
16 } 15 }
17 16
18 SendBuffer::SendBuffer( 17 SendBuffer::SendBuffer(
19 const std::vector<char>& data, 18 const std::vector<char>& data,
20 const base::Callback<void(int, device::serial::SendError)>& callback) 19 const base::Callback<void(int, device::serial::SendError)>& callback)
21 : data_(data), callback_(callback) {} 20 : data_(data), callback_(callback) {}
22 21
23 SendBuffer::~SendBuffer() {} 22 SendBuffer::~SendBuffer() {}
24 23
25 const char* SendBuffer::GetData() { 24 const char* SendBuffer::GetData() {
26 return vector_as_array(&data_); 25 return data_.data();
27 } 26 }
28 27
29 uint32_t SendBuffer::GetSize() { 28 uint32_t SendBuffer::GetSize() {
30 return base::checked_cast<uint32_t>(data_.size()); 29 return base::checked_cast<uint32_t>(data_.size());
31 } 30 }
32 31
33 void SendBuffer::Done(uint32_t bytes_read) { 32 void SendBuffer::Done(uint32_t bytes_read) {
34 callback_.Run(bytes_read, device::serial::SEND_ERROR_NONE); 33 callback_.Run(bytes_read, device::serial::SEND_ERROR_NONE);
35 } 34 }
36 35
(...skipping 20 matching lines...) Expand all
57 void ReceiveBuffer::Done(uint32_t bytes_written) { 56 void ReceiveBuffer::Done(uint32_t bytes_written) {
58 callback_.Run(bytes_written, device::serial::RECEIVE_ERROR_NONE); 57 callback_.Run(bytes_written, device::serial::RECEIVE_ERROR_NONE);
59 } 58 }
60 59
61 void ReceiveBuffer::DoneWithError(uint32_t bytes_written, int32_t error) { 60 void ReceiveBuffer::DoneWithError(uint32_t bytes_written, int32_t error) {
62 callback_.Run(bytes_written, 61 callback_.Run(bytes_written,
63 static_cast<device::serial::ReceiveError>(error)); 62 static_cast<device::serial::ReceiveError>(error));
64 } 63 }
65 64
66 } // namespace device 65 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698