Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ | |
| 6 #define EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 | |
| 10 namespace base { | |
| 11 class Value; | |
| 12 } // namespace base | |
| 13 | |
| 14 namespace extensions { | |
| 15 | |
| 16 // An interface to read messages and send responses between a native | |
|
Sergey Ulanov
2014/09/19 21:22:48
s/read messages and send responses/receive and sen
| |
| 17 // component and chrome. | |
| 18 class NativeMessagingChannel { | |
| 19 public: | |
| 20 // Callback interface for the channel. EventHandler must outlive | |
| 21 // NativeMessagingChannel | |
|
Sergey Ulanov
2014/09/19 21:22:48
add . at the end.
| |
| 22 class EventHandler { | |
| 23 public: | |
| 24 // Called when a message is received from the other endpoint. | |
| 25 virtual void OnMessage(scoped_ptr<base::Value> message) = 0; | |
| 26 | |
| 27 // Called when the channel is disconnected. | |
| 28 // EventHandler is guaranteed not to be called after OnDisconnect().. | |
|
Sergey Ulanov
2014/09/19 21:22:48
remove extra dot at the end.
| |
| 29 virtual void OnDisconnect() = 0; | |
| 30 | |
| 31 virtual ~EventHandler() {} | |
| 32 }; | |
| 33 | |
| 34 virtual ~NativeMessagingChannel() {} | |
| 35 | |
| 36 // Starts reading and processing messages. | |
| 37 virtual void Start(EventHandler* event_handler) = 0; | |
| 38 | |
| 39 // Sends a message to the other endpoint. | |
| 40 virtual void SendMessage(scoped_ptr<base::Value> message) = 0; | |
| 41 }; | |
| 42 | |
| 43 } // namespace extensions | |
| 44 | |
| 45 #endif // EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ | |
| OLD | NEW |