First cut at minibind classes.
[minibind.git] / jni / minibind / command.h
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MINIBIND_COMMAND_H_
6 #define MINIBIND_COMAMND_H_
7
8 #include <stdint.h>
9 #include <sys/types.h>
10
11 #include <linux/binder.h>
12
13 #include "common.h"
14
15 namespace minibind {
16
17 class Parcel;
18
19 class Command {
20 public:
21 virtual size_t GetSize() const = 0;
22 virtual binder_uintptr_t GetData() const = 0;
23
24 protected:
25 ~Command() {}
26 };
27
28 class TransactionCommand : public Command {
29 public:
30 enum Type {
31 TWO_WAY,
32 REPLY_ASYNC,
33 };
34
35 TransactionCommand(Type type);
36 ~TransactionCommand();
37
38 void SetHandle(uint32_t handle);
39 void SetCode(uint32_t code);
40 void SetParcel(const Parcel& parcel);
41
42 // Command:
43 size_t GetSize() const override;
44 binder_uintptr_t GetData() const override;
45
46 private:
47 const binder_driver_command_protocol command_;
48 struct binder_transaction_data transaction_;
49
50 DISALLOW_COPY_AND_ASSIGN(TransactionCommand);
51 };
52
53 } // namespace minibind
54
55 #endif // MINIBIND_COMAMND_H_