summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/serial/serial_api.h
blob: df4c3e0256f9f7f90c5803f8cc984745d17605d8 (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
50
51
52
53
// 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_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_
#pragma once

#include <string>

#include "chrome/browser/extensions/extension_function.h"

namespace extensions {

extern const char kConnectionIdKey[];

class SerialOpenFunction : public AsyncExtensionFunction {
 public:
  SerialOpenFunction();
  virtual ~SerialOpenFunction();

  virtual bool RunImpl() OVERRIDE;

 protected:
  void WorkOnIOThread();
  void RespondOnUIThread();

 private:
  std::string port_;

  DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.open")
};

class SerialCloseFunction : public AsyncExtensionFunction {
 public:
  SerialCloseFunction();
  virtual ~SerialCloseFunction();

  virtual bool RunImpl() OVERRIDE;

 protected:
  void WorkOnIOThread();
  void RespondOnUIThread();

 private:
  int connection_id_;

  DECLARE_EXTENSION_FUNCTION_NAME("experimental.serial.close")
};

}  // namespace extensions

#endif  // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_API_H_