OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 |
| 10 namespace base { |
| 11 class DictionaryValue; |
| 12 class Value; |
| 13 } // namespace base |
| 14 |
| 15 namespace extensions { |
| 16 |
| 17 // Defines an interface to read messages and send responses between the native |
| 18 // process and chrome. |
| 19 class NativeMessagingChannel { |
| 20 public: |
| 21 // Used to send a message to the other endpoint. |
| 22 typedef base::Callback<void(scoped_ptr<base::DictionaryValue> message)> |
| 23 SendMessageCallback; |
| 24 |
| 25 virtual ~NativeMessagingChannel() {} |
| 26 |
| 27 // Starts reading and processing messages. |
| 28 // |received_message| is called whenever a message is received from the other |
| 29 // endpoint. |
| 30 // |quit_closure| is called by the channel to shut down the native process |
| 31 // whenever it encounter failures in sending or receiving a message. |
| 32 virtual void Start(const SendMessageCallback& received_message, |
| 33 const base::Closure& quit_closure) = 0; |
| 34 |
| 35 // Sends a message to the other endpoint. |
| 36 virtual void SendMessage(scoped_ptr<base::DictionaryValue> message) = 0; |
| 37 }; |
| 38 |
| 39 } // namespace extensions |
| 40 |
| 41 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ |
OLD | NEW |