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 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/process.h" | 14 #include "base/process.h" |
15 #include "chrome/browser/extensions/api/messaging/native_process_launcher.h" | 15 #include "chrome/browser/extensions/api/messaging/native_process_launcher.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
17 | 17 |
| 18 namespace base { |
| 19 class ListValue; |
| 20 } |
| 21 |
18 namespace net { | 22 namespace net { |
19 | |
20 class DrainableIOBuffer; | 23 class DrainableIOBuffer; |
21 class FileStream; | 24 class FileStream; |
22 class IOBuffer; | 25 class IOBuffer; |
23 class IOBufferWithSize; | 26 class IOBufferWithSize; |
24 | |
25 } // namespace net | 27 } // namespace net |
26 | 28 |
27 namespace extensions { | 29 namespace extensions { |
28 | 30 |
29 // Manages the native side of a connection between an extension and a native | 31 // Manages the native side of a connection between an extension and a native |
30 // process. | 32 // process. |
31 // | 33 // |
32 // This class must only be created, called, and deleted on the IO thread. | 34 // 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 | 35 // Public methods typically accept callbacks which will be invoked on the UI |
34 // thread. | 36 // thread. |
35 class NativeMessageProcessHost | 37 class NativeMessageProcessHost |
36 #if defined(OS_POSIX) | 38 #if defined(OS_POSIX) |
37 : public base::MessageLoopForIO::Watcher | 39 : public base::MessageLoopForIO::Watcher |
38 #endif // !defined(OS_POSIX) | 40 #endif // !defined(OS_POSIX) |
39 { | 41 { |
40 public: | 42 public: |
41 // Interface for the object that receives messages from the native process. | 43 // Interface for the object that receives messages from the native process. |
42 class Client { | 44 class Client { |
43 public: | 45 public: |
44 virtual ~Client() {} | 46 virtual ~Client() {} |
45 // Called on the UI thread. | 47 // Called on the UI thread. |
46 virtual void PostMessageFromNativeProcess(int port_id, | 48 virtual void PostMessageFromNativeProcess( |
47 const std::string& message) = 0; | 49 int port_id, |
| 50 scoped_ptr<base::ListValue> message) = 0; |
48 virtual void CloseChannel(int port_id, | 51 virtual void CloseChannel(int port_id, |
49 const std::string& error_message) = 0; | 52 const std::string& error_message) = 0; |
50 }; | 53 }; |
51 | 54 |
52 virtual ~NativeMessageProcessHost(); | 55 virtual ~NativeMessageProcessHost(); |
53 | 56 |
54 static scoped_ptr<NativeMessageProcessHost> Create( | 57 static scoped_ptr<NativeMessageProcessHost> Create( |
55 base::WeakPtr<Client> weak_client_ui, | 58 base::WeakPtr<Client> weak_client_ui, |
56 const std::string& source_extension_id, | 59 const std::string& source_extension_id, |
57 const std::string& native_host_name, | 60 const std::string& native_host_name, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 163 |
161 // Set to true when a write is pending. | 164 // Set to true when a write is pending. |
162 bool write_pending_; | 165 bool write_pending_; |
163 | 166 |
164 DISALLOW_COPY_AND_ASSIGN(NativeMessageProcessHost); | 167 DISALLOW_COPY_AND_ASSIGN(NativeMessageProcessHost); |
165 }; | 168 }; |
166 | 169 |
167 } // namespace extensions | 170 } // namespace extensions |
168 | 171 |
169 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H
_ | 172 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PROCESS_HOST_H
_ |
OLD | NEW |