OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMEOS_BINDER_COMMAND_BROKER_H_ | 5 #ifndef CHROMEOS_BINDER_COMMAND_BROKER_H_ |
6 #define CHROMEOS_BINDER_COMMAND_BROKER_H_ | 6 #define CHROMEOS_BINDER_COMMAND_BROKER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 14 matching lines...) Expand all Loading... |
25 // Issues appropriate outgoing commands to perform required tasks, and | 25 // Issues appropriate outgoing commands to perform required tasks, and |
26 // dispatches incoming commands to appropriate objects. | 26 // dispatches incoming commands to appropriate objects. |
27 // Usually this class lives as long as the corresponding thread. | 27 // Usually this class lives as long as the corresponding thread. |
28 // TODO(hashimoto): Add code to handle incoming commands (e.g. transactions). | 28 // TODO(hashimoto): Add code to handle incoming commands (e.g. transactions). |
29 class CHROMEOS_EXPORT CommandBroker | 29 class CHROMEOS_EXPORT CommandBroker |
30 : public CommandStream::IncomingCommandHandler { | 30 : public CommandStream::IncomingCommandHandler { |
31 public: | 31 public: |
32 explicit CommandBroker(Driver* driver); | 32 explicit CommandBroker(Driver* driver); |
33 ~CommandBroker() override; | 33 ~CommandBroker() override; |
34 | 34 |
| 35 // Tells the driver that the current thread entered command handling loop. |
| 36 // Returns true on success. |
| 37 bool EnterLooper(); |
| 38 |
| 39 // Tells the driver that the current thread exited command handling loop. |
| 40 // Returns true on success. |
| 41 bool ExitLooper(); |
| 42 |
| 43 // Fetches incoming commands and handles them. |
| 44 // Returns true on success. |
| 45 bool PollCommands(); |
| 46 |
35 // Performs transaction with the remote object specified by the handle. | 47 // Performs transaction with the remote object specified by the handle. |
36 // Returns true on success. If not one-way transaction, this method blocks | 48 // Returns true on success. If not one-way transaction, this method blocks |
37 // until the target object sends a reply. | 49 // until the target object sends a reply. |
38 bool Transact(int32_t handle, | 50 bool Transact(int32_t handle, |
39 const TransactionData& request, | 51 const TransactionData& request, |
40 scoped_ptr<TransactionData>* reply); | 52 scoped_ptr<TransactionData>* reply); |
41 | 53 |
42 // Increments the ref-count of a remote object specified by |handle|. | 54 // Increments the ref-count of a remote object specified by |handle|. |
43 void AddReference(int32_t handle); | 55 void AddReference(int32_t handle); |
44 | 56 |
45 // Decrements the ref-count of a remote object specified by |handle|. | 57 // Decrements the ref-count of a remote object specified by |handle|. |
46 void ReleaseReference(int32_t handle); | 58 void ReleaseReference(int32_t handle); |
47 | 59 |
48 // Returns a closure which decrements the ref-count of a remote object. | 60 // Returns a closure which decrements the ref-count of a remote object. |
49 // It's safe to run the returned closure even after the destruction of this | 61 // It's safe to run the returned closure even after the destruction of this |
50 // object. | 62 // object. |
51 base::Closure GetReleaseReferenceClosure(int32_t handle); | 63 base::Closure GetReleaseReferenceClosure(int32_t handle); |
52 | 64 |
53 // CommandStream::IncomingCommandHandler override: | 65 // CommandStream::IncomingCommandHandler override: |
| 66 bool OnTransaction(const TransactionData& data) override; |
54 void OnReply(scoped_ptr<TransactionData> data) override; | 67 void OnReply(scoped_ptr<TransactionData> data) override; |
55 void OnDeadReply() override; | 68 void OnDeadReply() override; |
56 void OnTransactionComplete() override; | 69 void OnTransactionComplete() override; |
57 void OnIncrementWeakReference(void* ptr, void* cookie) override; | 70 void OnIncrementWeakReference(void* ptr, void* cookie) override; |
58 void OnIncrementStrongReference(void* ptr, void* cookie) override; | 71 void OnIncrementStrongReference(void* ptr, void* cookie) override; |
59 void OnDecrementStrongReference(void* ptr, void* cookie) override; | 72 void OnDecrementStrongReference(void* ptr, void* cookie) override; |
60 void OnDecrementWeakReference(void* ptr, void* cookie) override; | 73 void OnDecrementWeakReference(void* ptr, void* cookie) override; |
61 void OnFailedReply() override; | 74 void OnFailedReply() override; |
62 | 75 |
63 private: | 76 private: |
(...skipping 15 matching lines...) Expand all Loading... |
79 scoped_ptr<TransactionData> response_data_; | 92 scoped_ptr<TransactionData> response_data_; |
80 | 93 |
81 base::WeakPtrFactory<CommandBroker> weak_ptr_factory_; | 94 base::WeakPtrFactory<CommandBroker> weak_ptr_factory_; |
82 | 95 |
83 DISALLOW_COPY_AND_ASSIGN(CommandBroker); | 96 DISALLOW_COPY_AND_ASSIGN(CommandBroker); |
84 }; | 97 }; |
85 | 98 |
86 } // namespace binder | 99 } // namespace binder |
87 | 100 |
88 #endif // CHROMEOS_BINDER_COMMAND_BROKER_H_ | 101 #endif // CHROMEOS_BINDER_COMMAND_BROKER_H_ |
OLD | NEW |