blob: c2a248fd3aab372c2f1103ad7864eccf6cc48818 [file] [log] [blame]
hashimoto8079ea62015-12-16 05:40:391// 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
hashimoto32e9f8bb2015-12-18 08:06:125#ifndef CHROMEOS_BINDER_TRANSACTION_DATA_FROM_DRIVER_H_
6#define CHROMEOS_BINDER_TRANSACTION_DATA_FROM_DRIVER_H_
hashimoto8079ea62015-12-16 05:40:397
avi6e1a22d2015-12-21 03:43:208#include <stddef.h>
9#include <stdint.h>
hashimoto87353a3e2016-01-06 06:43:0210#include <sys/types.h>
11
12#include <linux/android/binder.h>
hashimoto8079ea62015-12-16 05:40:3913
14#include "base/callback.h"
15#include "base/macros.h"
16#include "base/memory/ref_counted.h"
17#include "chromeos/binder/transaction_data.h"
hashimoto32e9f8bb2015-12-18 08:06:1218#include "chromeos/chromeos_export.h"
hashimoto8079ea62015-12-16 05:40:3919
20namespace base {
21class SingleThreadTaskRunner;
22}
23
24namespace binder {
25
hashimoto8079ea62015-12-16 05:40:3926// TransactionData passed by the driver, whose data needs to be freed with
27// BC_FREE_BUFFER command.
hashimoto32e9f8bb2015-12-18 08:06:1228class CHROMEOS_EXPORT TransactionDataFromDriver : public TransactionData {
hashimoto8079ea62015-12-16 05:40:3929 public:
30 typedef base::Callback<void(const void* ptr)> BufferDeleter;
31 explicit TransactionDataFromDriver(const BufferDeleter& buffer_deleter);
32 ~TransactionDataFromDriver() override;
33
34 const binder_transaction_data& data() const { return data_; }
35 binder_transaction_data* mutable_data() { return &data_; }
36
37 // TransactionData override:
38 uintptr_t GetCookie() const override;
avi6e1a22d2015-12-21 03:43:2039 uint32_t GetCode() const override;
hashimoto8079ea62015-12-16 05:40:3940 pid_t GetSenderPID() const override;
41 uid_t GetSenderEUID() const override;
42 bool IsOneWay() const override;
43 bool HasStatus() const override;
44 Status GetStatus() const override;
45 const void* GetData() const override;
46 size_t GetDataSize() const override;
47 const uintptr_t* GetObjectOffsets() const override;
48 size_t GetNumObjectOffsets() const override;
49
50 private:
51 scoped_refptr<base::SingleThreadTaskRunner> delete_task_runner_;
52 BufferDeleter buffer_deleter_;
53 binder_transaction_data data_;
54
55 DISALLOW_COPY_AND_ASSIGN(TransactionDataFromDriver);
56};
57
58} // namespace binder
59
hashimoto32e9f8bb2015-12-18 08:06:1260#endif // CHROMEOS_BINDER_TRANSACTION_DATA_FROM_DRIVER_H_