Chromium Code Reviews| Index: chrome/browser/extensions/api/messaging/native_messaging_channel.h |
| diff --git a/chrome/browser/extensions/api/messaging/native_messaging_channel.h b/chrome/browser/extensions/api/messaging/native_messaging_channel.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c6b560d372e09f44b4563a5075eb987733c2fc39 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/messaging/native_messaging_channel.h |
| @@ -0,0 +1,40 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
|
Sergey Ulanov
2014/09/15 19:53:39
I think it's better to add this file under extensi
kelvinp
2014/09/16 00:32:51
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ |
| + |
| +#include "base/callback.h" |
| + |
| +namespace base { |
| +class DictionaryValue; |
| +} // namespace base |
| + |
| +namespace extensions { |
| + |
| +// Defines an interface to read messages and send responses between a native |
| +// component and chrome. |
| +class NativeMessagingChannel { |
| + public: |
| + // Used to send a message to the other endpoint. |
| + typedef base::Callback<void(scoped_ptr<base::DictionaryValue> message)> |
|
Sergey Ulanov
2014/09/15 19:53:39
this should be base::Value instead of DictionaryVa
kelvinp
2014/09/16 00:32:51
Done.
|
| + SendMessageCallback; |
| + |
| + virtual ~NativeMessagingChannel() {} |
| + |
| + // Starts reading and processing messages. |
| + // |received_message| is called whenever a message is received from the other |
| + // endpoint. |
| + // |quit_closure| is called by the channel to shut down the native component |
| + // whenever it encounter failures in sending or receiving a message. |
| + virtual void Start(const SendMessageCallback& received_message, |
|
Sergey Ulanov
2014/09/15 19:53:39
I suggest you replace these two callbacks with a c
kelvinp
2014/09/16 00:32:51
Done.
|
| + const base::Closure& quit_closure) = 0; |
| + |
| + // Sends a message to the other endpoint. |
| + virtual void SendMessage(scoped_ptr<base::DictionaryValue> message) = 0; |
|
Sergey Ulanov
2014/09/15 19:53:39
base::Value
kelvinp
2014/09/16 00:32:51
Done.
|
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ |