blob: 21bb0cbc79dd72a97937d318eab5cc9a43d11e51 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_CONNECTION_H_
#define CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_CONNECTION_H_
#pragma once
#include <set>
#include <string>
#include "base/memory/ref_counted.h"
#include "base/platform_file.h"
#include "chrome/browser/extensions/api/api_resource.h"
#include "net/base/io_buffer.h"
namespace extensions {
extern const char kSerialConnectionNotFoundError[];
class APIResourceEventNotifier;
// Encapsulates an open serial port. Platform-specific implementations are in
// _win and _posix versions of the the .cc file.
class SerialConnection : public APIResource {
public:
SerialConnection(const std::string& port,
APIResourceEventNotifier* event_notifier);
virtual ~SerialConnection();
bool Open();
void Close();
void Flush();
int Read(uint8* byte);
int Write(scoped_refptr<net::IOBuffer> io_buffer, int byte_count);
protected:
// Do platform-specific work after a successful Open().
bool PostOpen();
private:
std::string port_;
base::PlatformFile file_;
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_CONNECTION_H_
|