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