blob: 23552d825d6b95669b039a0bb691e32b3e74a16f [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>
hashimoto8079ea62015-12-16 05:40:3910
11#include "base/callback.h"
12#include "base/macros.h"
13#include "base/memory/ref_counted.h"
hashimotoc5ffb8b2016-03-09 03:19:3114#include "chromeos/binder/binder_driver_api.h"
hashimoto8079ea62015-12-16 05:40:3915#include "chromeos/binder/transaction_data.h"
hashimoto32e9f8bb2015-12-18 08:06:1216#include "chromeos/chromeos_export.h"
hashimoto8079ea62015-12-16 05:40:3917
18namespace base {
19class SingleThreadTaskRunner;
20}
21
22namespace binder {
23
hashimoto8079ea62015-12-16 05:40:3924// TransactionData passed by the driver, whose data needs to be freed with
25// BC_FREE_BUFFER command.
hashimoto32e9f8bb2015-12-18 08:06:1226class CHROMEOS_EXPORT TransactionDataFromDriver : public TransactionData {
hashimoto8079ea62015-12-16 05:40:3927 public:
28 typedef base::Callback<void(const void* ptr)> BufferDeleter;
29 explicit TransactionDataFromDriver(const BufferDeleter& buffer_deleter);
30 ~TransactionDataFromDriver() override;
31
32 const binder_transaction_data& data() const { return data_; }
33 binder_transaction_data* mutable_data() { return &data_; }
34
35 // TransactionData override:
36 uintptr_t GetCookie() const override;
avi6e1a22d2015-12-21 03:43:2037 uint32_t GetCode() const override;
hashimoto8079ea62015-12-16 05:40:3938 pid_t GetSenderPID() const override;
39 uid_t GetSenderEUID() const override;
40 bool IsOneWay() const override;
41 bool HasStatus() const override;
42 Status GetStatus() const override;
43 const void* GetData() const override;
44 size_t GetDataSize() const override;
hashimotoefaa412a2016-03-09 05:28:3145 const binder_uintptr_t* GetObjectOffsets() const override;
hashimoto8079ea62015-12-16 05:40:3946 size_t GetNumObjectOffsets() const override;
47
48 private:
49 scoped_refptr<base::SingleThreadTaskRunner> delete_task_runner_;
50 BufferDeleter buffer_deleter_;
51 binder_transaction_data data_;
52
53 DISALLOW_COPY_AND_ASSIGN(TransactionDataFromDriver);
54};
55
56} // namespace binder
57
hashimoto32e9f8bb2015-12-18 08:06:1258#endif // CHROMEOS_BINDER_TRANSACTION_DATA_FROM_DRIVER_H_