| 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_STREAM_H_ | 5 #ifndef CHROMEOS_BINDER_COMMAND_STREAM_H_ |
| 6 #define CHROMEOS_BINDER_COMMAND_STREAM_H_ | 6 #define CHROMEOS_BINDER_COMMAND_STREAM_H_ |
| 7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 8 #include <vector> | 11 #include <vector> |
| 9 | 12 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 14 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 15 #include "chromeos/chromeos_export.h" | 17 #include "chromeos/chromeos_export.h" |
| 16 | 18 |
| 17 namespace binder { | 19 namespace binder { |
| 18 | 20 |
| 19 class BufferReader; | 21 class BufferReader; |
| 20 class Driver; | 22 class Driver; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // success. | 54 // success. |
| 53 bool Fetch(); | 55 bool Fetch(); |
| 54 | 56 |
| 55 // Returns true if any incoming commands are in the buffer. | 57 // Returns true if any incoming commands are in the buffer. |
| 56 bool CanProcessIncomingCommand(); | 58 bool CanProcessIncomingCommand(); |
| 57 | 59 |
| 58 // Processes an incoming command in the buffer, and returns true on success. | 60 // Processes an incoming command in the buffer, and returns true on success. |
| 59 bool ProcessIncomingCommand(); | 61 bool ProcessIncomingCommand(); |
| 60 | 62 |
| 61 // Appends a command to the outgoing command buffer. | 63 // Appends a command to the outgoing command buffer. |
| 62 void AppendOutgoingCommand(uint32 command, const void* data, size_t size); | 64 void AppendOutgoingCommand(uint32_t command, const void* data, size_t size); |
| 63 | 65 |
| 64 // Writes buffered outgoing commands to the driver, and returns true on | 66 // Writes buffered outgoing commands to the driver, and returns true on |
| 65 // success. | 67 // success. |
| 66 bool Flush(); | 68 bool Flush(); |
| 67 | 69 |
| 68 private: | 70 private: |
| 69 // Calls the appropriate delegate method to handle the incoming command. | 71 // Calls the appropriate delegate method to handle the incoming command. |
| 70 bool OnIncomingCommand(uint32 command, BufferReader* reader); | 72 bool OnIncomingCommand(uint32_t command, BufferReader* reader); |
| 71 | 73 |
| 72 // Frees the buffer used by the driver to pass transaction data payload. | 74 // Frees the buffer used by the driver to pass transaction data payload. |
| 73 void FreeTransactionBuffer(const void* ptr); | 75 void FreeTransactionBuffer(const void* ptr); |
| 74 | 76 |
| 75 base::ThreadChecker thread_checker_; | 77 base::ThreadChecker thread_checker_; |
| 76 | 78 |
| 77 Driver* driver_; | 79 Driver* driver_; |
| 78 IncomingCommandHandler* incoming_command_handler_; | 80 IncomingCommandHandler* incoming_command_handler_; |
| 79 | 81 |
| 80 std::vector<char> outgoing_data_; // Buffer for outgoing commands. | 82 std::vector<char> outgoing_data_; // Buffer for outgoing commands. |
| 81 std::vector<char> incoming_data_; // Buffer for incoming commands. | 83 std::vector<char> incoming_data_; // Buffer for incoming commands. |
| 82 scoped_ptr<BufferReader> incoming_data_reader_; | 84 scoped_ptr<BufferReader> incoming_data_reader_; |
| 83 | 85 |
| 84 base::WeakPtrFactory<CommandStream> weak_ptr_factory_; | 86 base::WeakPtrFactory<CommandStream> weak_ptr_factory_; |
| 85 | 87 |
| 86 DISALLOW_COPY_AND_ASSIGN(CommandStream); | 88 DISALLOW_COPY_AND_ASSIGN(CommandStream); |
| 87 }; | 89 }; |
| 88 | 90 |
| 89 } // namespace binder | 91 } // namespace binder |
| 90 | 92 |
| 91 #endif // CHROMEOS_BINDER_COMMAND_STREAM_H_ | 93 #endif // CHROMEOS_BINDER_COMMAND_STREAM_H_ |
| OLD | NEW |