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 TOOLS_BATTOR_AGENT_BATTOR_CONNECTION_IMPL_H_ | 5 #ifndef TOOLS_BATTOR_AGENT_BATTOR_CONNECTION_IMPL_H_ |
6 #define TOOLS_BATTOR_AGENT_BATTOR_CONNECTION_IMPL_H_ | 6 #define TOOLS_BATTOR_AGENT_BATTOR_CONNECTION_IMPL_H_ |
7 | 7 |
8 #include <fstream> | 8 #include <fstream> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 namespace battor { | 28 namespace battor { |
29 | 29 |
30 // A BattOrConnectionImpl is a concrete implementation of a BattOrConnection. | 30 // A BattOrConnectionImpl is a concrete implementation of a BattOrConnection. |
31 class BattOrConnectionImpl | 31 class BattOrConnectionImpl |
32 : public BattOrConnection, | 32 : public BattOrConnection, |
33 public base::SupportsWeakPtr<BattOrConnectionImpl> { | 33 public base::SupportsWeakPtr<BattOrConnectionImpl> { |
34 public: | 34 public: |
35 BattOrConnectionImpl( | 35 BattOrConnectionImpl( |
36 const std::string& path, | 36 const std::string& path, |
37 BattOrConnection::Listener* listener, | 37 BattOrConnection::Listener* listener, |
38 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, | |
39 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner); | 38 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner); |
40 ~BattOrConnectionImpl() override; | 39 ~BattOrConnectionImpl() override; |
41 | 40 |
42 void Open() override; | 41 void Open() override; |
43 void Close() override; | 42 void Close() override; |
44 void SendBytes(BattOrMessageType type, | 43 void SendBytes(BattOrMessageType type, |
45 const void* buffer, | 44 const void* buffer, |
46 size_t bytes_to_send) override; | 45 size_t bytes_to_send) override; |
47 void ReadMessage(BattOrMessageType type) override; | 46 void ReadMessage(BattOrMessageType type) override; |
48 void CancelReadMessage() override; | 47 void CancelReadMessage() override; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 std::vector<char> already_read_buffer_; | 97 std::vector<char> already_read_buffer_; |
99 // The bytes that were read in the pending read. | 98 // The bytes that were read in the pending read. |
100 scoped_refptr<net::IOBuffer> pending_read_buffer_; | 99 scoped_refptr<net::IOBuffer> pending_read_buffer_; |
101 // The type of message we're looking for in the pending read. | 100 // The type of message we're looking for in the pending read. |
102 BattOrMessageType pending_read_message_type_; | 101 BattOrMessageType pending_read_message_type_; |
103 | 102 |
104 // The total number of bytes that we're expecting to send. | 103 // The total number of bytes that we're expecting to send. |
105 size_t pending_write_length_; | 104 size_t pending_write_length_; |
106 | 105 |
107 // Threads needed for serial communication. | 106 // Threads needed for serial communication. |
108 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_; | |
109 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner_; | 107 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner_; |
110 | 108 |
111 std::fstream serial_log_; | 109 std::fstream serial_log_; |
112 | 110 |
113 DISALLOW_COPY_AND_ASSIGN(BattOrConnectionImpl); | 111 DISALLOW_COPY_AND_ASSIGN(BattOrConnectionImpl); |
114 }; | 112 }; |
115 | 113 |
116 } // namespace battor | 114 } // namespace battor |
117 | 115 |
118 #endif // TOOLS_BATTOR_AGENT_BATTOR_CONNECTION_IMPL_H_ | 116 #endif // TOOLS_BATTOR_AGENT_BATTOR_CONNECTION_IMPL_H_ |
OLD | NEW |