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

Side by Side Diff: extensions/browser/api/serial/serial_connection.cc

Issue 664933004: Standardize usage of virtual/override/final in extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months 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 "extensions/browser/api/serial/serial_connection.h" 5 #include "extensions/browser/api/serial/serial_connection.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 return device::serial::STOP_BITS_NONE; 133 return device::serial::STOP_BITS_NONE;
134 } 134 }
135 135
136 class SendBuffer : public device::ReadOnlyBuffer { 136 class SendBuffer : public device::ReadOnlyBuffer {
137 public: 137 public:
138 SendBuffer( 138 SendBuffer(
139 const std::string& data, 139 const std::string& data,
140 const base::Callback<void(int, device::serial::SendError)>& callback) 140 const base::Callback<void(int, device::serial::SendError)>& callback)
141 : data_(data), callback_(callback) {} 141 : data_(data), callback_(callback) {}
142 virtual ~SendBuffer() {} 142 ~SendBuffer() override {}
143 virtual const char* GetData() override { return data_.c_str(); } 143 const char* GetData() override { return data_.c_str(); }
144 virtual uint32_t GetSize() override { 144 uint32_t GetSize() override { return static_cast<uint32_t>(data_.size()); }
145 return static_cast<uint32_t>(data_.size()); 145 void Done(uint32_t bytes_read) override {
146 }
147 virtual void Done(uint32_t bytes_read) override {
148 callback_.Run(bytes_read, device::serial::SEND_ERROR_NONE); 146 callback_.Run(bytes_read, device::serial::SEND_ERROR_NONE);
149 } 147 }
150 virtual void DoneWithError(uint32_t bytes_read, int32_t error) override { 148 void DoneWithError(uint32_t bytes_read, int32_t error) override {
151 callback_.Run(bytes_read, static_cast<device::serial::SendError>(error)); 149 callback_.Run(bytes_read, static_cast<device::serial::SendError>(error));
152 } 150 }
153 151
154 private: 152 private:
155 const std::string data_; 153 const std::string data_;
156 const base::Callback<void(int, device::serial::SendError)> callback_; 154 const base::Callback<void(int, device::serial::SendError)> callback_;
157 }; 155 };
158 156
159 class ReceiveBuffer : public device::WritableBuffer { 157 class ReceiveBuffer : public device::WritableBuffer {
160 public: 158 public:
161 ReceiveBuffer( 159 ReceiveBuffer(
162 scoped_refptr<net::IOBuffer> buffer, 160 scoped_refptr<net::IOBuffer> buffer,
163 uint32_t size, 161 uint32_t size,
164 const base::Callback<void(int, device::serial::ReceiveError)>& callback) 162 const base::Callback<void(int, device::serial::ReceiveError)>& callback)
165 : buffer_(buffer), size_(size), callback_(callback) {} 163 : buffer_(buffer), size_(size), callback_(callback) {}
166 virtual ~ReceiveBuffer() {} 164 ~ReceiveBuffer() override {}
167 virtual char* GetData() override { return buffer_->data(); } 165 char* GetData() override { return buffer_->data(); }
168 virtual uint32_t GetSize() override { return size_; } 166 uint32_t GetSize() override { return size_; }
169 virtual void Done(uint32_t bytes_written) override { 167 void Done(uint32_t bytes_written) override {
170 callback_.Run(bytes_written, device::serial::RECEIVE_ERROR_NONE); 168 callback_.Run(bytes_written, device::serial::RECEIVE_ERROR_NONE);
171 } 169 }
172 virtual void DoneWithError(uint32_t bytes_written, int32_t error) override { 170 void DoneWithError(uint32_t bytes_written, int32_t error) override {
173 callback_.Run(bytes_written, 171 callback_.Run(bytes_written,
174 static_cast<device::serial::ReceiveError>(error)); 172 static_cast<device::serial::ReceiveError>(error));
175 } 173 }
176 174
177 private: 175 private:
178 scoped_refptr<net::IOBuffer> buffer_; 176 scoped_refptr<net::IOBuffer> buffer_;
179 const uint32_t size_; 177 const uint32_t size_;
180 const base::Callback<void(int, device::serial::ReceiveError)> callback_; 178 const base::Callback<void(int, device::serial::ReceiveError)> callback_;
181 }; 179 };
182 180
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 output->parity_bit = extensions::ConvertParityBitToMojo(input.parity_bit); 428 output->parity_bit = extensions::ConvertParityBitToMojo(input.parity_bit);
431 output->stop_bits = extensions::ConvertStopBitsToMojo(input.stop_bits); 429 output->stop_bits = extensions::ConvertStopBitsToMojo(input.stop_bits);
432 if (input.cts_flow_control.get()) { 430 if (input.cts_flow_control.get()) {
433 output->has_cts_flow_control = true; 431 output->has_cts_flow_control = true;
434 output->cts_flow_control = *input.cts_flow_control; 432 output->cts_flow_control = *input.cts_flow_control;
435 } 433 }
436 return output.Pass(); 434 return output.Pass();
437 } 435 }
438 436
439 } // namespace mojo 437 } // namespace mojo
OLDNEW
« no previous file with comments | « extensions/browser/api/serial/serial_connection.h ('k') | extensions/browser/api/serial/serial_event_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698