OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 namespace extensions { | 27 namespace extensions { |
28 | 28 |
29 // Manages the native side of a connection between an extension and a native | 29 // Manages the native side of a connection between an extension and a native |
30 // process. | 30 // process. |
31 // | 31 // |
32 // This class must only be created, called, and deleted on the IO thread. | 32 // This class must only be created, called, and deleted on the IO thread. |
33 // Public methods typically accept callbacks which will be invoked on the UI | 33 // Public methods typically accept callbacks which will be invoked on the UI |
34 // thread. | 34 // thread. |
35 class NativeMessageProcessHost | 35 class NativeMessageProcessHost |
36 #if defined(OS_POSIX) | 36 #if defined(OS_POSIX) |
37 : public MessageLoopForIO::Watcher | 37 : public base::MessageLoopForIO::Watcher |
38 #endif // !defined(OS_POSIX) | 38 #endif // !defined(OS_POSIX) |
39 { | 39 { |
40 public: | 40 public: |
41 // Interface for the object that receives messages from the native process. | 41 // Interface for the object that receives messages from the native process. |
42 class Client { | 42 class Client { |
43 public: | 43 public: |
44 virtual ~Client() {} | 44 virtual ~Client() {} |
45 // Called on the UI thread. | 45 // Called on the UI thread. |
46 virtual void PostMessageFromNativeProcess(int port_id, | 46 virtual void PostMessageFromNativeProcess(int port_id, |
47 const std::string& message) = 0; | 47 const std::string& message) = 0; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 // Set to true after the native messaging connection has been stopped, e.g. | 128 // Set to true after the native messaging connection has been stopped, e.g. |
129 // due to an error. | 129 // due to an error. |
130 bool closed_; | 130 bool closed_; |
131 | 131 |
132 // Input stream handle and reader. | 132 // Input stream handle and reader. |
133 base::PlatformFile read_file_; | 133 base::PlatformFile read_file_; |
134 scoped_ptr<net::FileStream> read_stream_; | 134 scoped_ptr<net::FileStream> read_stream_; |
135 | 135 |
136 #if defined(OS_POSIX) | 136 #if defined(OS_POSIX) |
137 MessageLoopForIO::FileDescriptorWatcher read_watcher_; | 137 base::MessageLoopForIO::FileDescriptorWatcher read_watcher_; |
138 #endif // !defined(OS_POSIX) | 138 #endif // !defined(OS_POSIX) |
139 | 139 |
140 // Write stream. | 140 // Write stream. |
141 scoped_ptr<net::FileStream> write_stream_; | 141 scoped_ptr<net::FileStream> write_stream_; |
142 | 142 |
143 // Read buffer passed to FileStream::Read(). | 143 // Read buffer passed to FileStream::Read(). |
144 scoped_refptr<net::IOBuffer> read_buffer_; | 144 scoped_refptr<net::IOBuffer> read_buffer_; |
145 | 145 |
146 // Set to true when a read is pending. | 146 // Set to true when a read is pending. |
147 bool read_pending_; | 147 bool read_pending_; |
(...skipping 12 matching lines...) Expand all Loading... |
160 | 160 |
161 // Set to true when a write is pending. | 161 // Set to true when a write is pending. |
162 bool write_pending_; | 162 bool write_pending_; |
163 | 163 |
164 DISALLOW_COPY_AND_ASSIGN(NativeMessageProcessHost); | 164 DISALLOW_COPY_AND_ASSIGN(NativeMessageProcessHost); |
165 }; | 165 }; |
166 | 166 |
167 } // namespace extensions | 167 } // namespace extensions |
168 | 168 |
169 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H
_ | 169 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H
_ |
OLD | NEW |