Chromium Code Reviews| Index: extensions/browser/api/messaging/native_messaging_channel.h |
| diff --git a/extensions/browser/api/messaging/native_messaging_channel.h b/extensions/browser/api/messaging/native_messaging_channel.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8e0df3511e47ac1feab3a378b3ee2fdb34b48af9 |
| --- /dev/null |
| +++ b/extensions/browser/api/messaging/native_messaging_channel.h |
| @@ -0,0 +1,45 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ |
| +#define EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ |
| + |
| +#include "base/callback.h" |
| + |
| +namespace base { |
| +class Value; |
| +} // namespace base |
| + |
| +namespace extensions { |
| + |
| +// Defines an interface to read messages and send responses between a native |
|
Sergey Ulanov
2014/09/18 18:08:35
nit: "Defines an " is redundant. Just "Interface .
kelvinp
2014/09/18 19:03:50
Done.
|
| +// component and chrome. |
| +class NativeMessagingChannel { |
| + public: |
| + // Callback interface for the channel. EventHandler must be valid as long as |
| + // NativeMessagingChannel is valid. |
|
Sergey Ulanov
2014/09/18 18:08:35
"valid" is ambiguous. Suggest rewording second sen
kelvinp
2014/09/18 19:03:50
Done.
|
| + class EventHandler { |
| + public: |
| + // Invoked when a message is received from the other endpoint. |
| + virtual void OnMessage(scoped_ptr<base::Value> message) = 0; |
| + |
| + // Invoked when there is an error in sending or receiving a message. |
|
Sergey Ulanov
2014/09/18 18:08:35
Suggest "Called when the channel is disconnected."
kelvinp
2014/09/18 19:03:50
Done.
|
| + // The event handler should shut down the channel on this event. |
|
Sergey Ulanov
2014/09/18 18:08:35
It's not clear what this means. Does it mean that
kelvinp
2014/09/18 19:03:50
Done.
|
| + virtual void OnDisconnect() = 0; |
| + |
| + virtual ~EventHandler() {} |
| + }; |
| + |
| + virtual ~NativeMessagingChannel() {} |
| + |
| + // Starts reading and processing messages. |
| + virtual void Start(EventHandler* event_handler) = 0; |
| + |
| + // Sends a message to the other endpoint. |
| + virtual void SendMessage(scoped_ptr<base::Value> message) = 0; |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ |