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_PORT_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PORT_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PORT_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PORT_H_ |
7 | 7 |
8 #include "base/threading/thread_checker.h" | |
8 #include "chrome/browser/extensions/api/messaging/message_service.h" | 9 #include "chrome/browser/extensions/api/messaging/message_service.h" |
9 | 10 |
10 namespace extensions { | 11 namespace extensions { |
11 class NativeMessageProcessHost; | 12 class NativeMessageProcessHost; |
12 | 13 |
13 // A port that manages communication with a native application. | 14 // A port that manages communication with a native application. |
14 class NativeMessagePort : public MessageService::MessagePort { | 15 // All methods must be called on the UI Thread of the browser process. |
16 class NativeMessagePort : public MessageService::MessagePort, | |
17 public NativeMessageHost::Client { | |
15 public: | 18 public: |
16 // Takes ownership of |native_process|. | 19 NativeMessagePort(base::WeakPtr<MessageService> message_service, |
17 explicit NativeMessagePort(NativeMessageProcessHost* native_process); | 20 int port_id, |
21 scoped_ptr<NativeMessageHost> native_message_host); | |
18 virtual ~NativeMessagePort(); | 22 virtual ~NativeMessagePort(); |
23 | |
24 // MessageService::MessagePort implementation. | |
19 virtual void DispatchOnMessage(const Message& message, | 25 virtual void DispatchOnMessage(const Message& message, |
20 int target_port_id) OVERRIDE; | 26 int target_port_id) OVERRIDE; |
21 | 27 |
28 // NativeMessageHost::Client implementation. | |
Sergey Ulanov
2014/10/01 23:23:59
This class doesn't really need to implement Native
kelvinp
2014/10/02 03:12:17
Done.
| |
29 virtual void PostMessageFromNativeHost(const std::string& message) OVERRIDE; | |
30 virtual void CloseChannel(const std::string& error_message) OVERRIDE; | |
31 | |
22 private: | 32 private: |
23 NativeMessageProcessHost* native_process_; | 33 class Core; |
34 | |
35 base::ThreadChecker thread_checker_; | |
36 base::WeakPtr<MessageService> weak_message_service_; | |
37 int port_id_; | |
38 scoped_ptr<Core> core_; | |
39 | |
40 base::WeakPtrFactory<NativeMessagePort> weak_factory_; | |
24 }; | 41 }; |
25 | 42 |
26 } // namespace extensions | 43 } // namespace extensions |
27 | 44 |
28 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PORT_H_ | 45 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGE_PORT_H_ |
OLD | NEW |