summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/api
diff options
context:
space:
mode:
authorsammc <sammc@chromium.org>2015-02-04 23:40:34 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-05 07:41:32 +0000
commite75ce35e220e849af5562b927c754bf6269223e1 (patch)
tree920366883008926b6c1842732d7923b684947ba6 /extensions/renderer/api
parent4f0acbe307357802844fbb6e974ce724dea45655 (diff)
downloadchromium_src-e75ce35e220e849af5562b927c754bf6269223e1.zip
chromium_src-e75ce35e220e849af5562b927c754bf6269223e1.tar.gz
chromium_src-e75ce35e220e849af5562b927c754bf6269223e1.tar.bz2
Remove Client= from device/serial/data_stream.mojom.
BUG=451321 Committed: https://crrev.com/bc78a2320b50eba4fe397f1f838a82ad30b16cd6 Cr-Commit-Position: refs/heads/master@{#314231} Review URL: https://codereview.chromium.org/889283002 Cr-Commit-Position: refs/heads/master@{#314773}
Diffstat (limited to 'extensions/renderer/api')
-rw-r--r--extensions/renderer/api/serial/data_receiver_unittest.cc67
-rw-r--r--extensions/renderer/api/serial/data_sender_unittest.cc11
2 files changed, 64 insertions, 14 deletions
diff --git a/extensions/renderer/api/serial/data_receiver_unittest.cc b/extensions/renderer/api/serial/data_receiver_unittest.cc
index f699d02..1be15969 100644
--- a/extensions/renderer/api/serial/data_receiver_unittest.cc
+++ b/extensions/renderer/api/serial/data_receiver_unittest.cc
@@ -7,10 +7,56 @@
#include "device/serial/data_source_sender.h"
#include "device/serial/data_stream.mojom.h"
#include "extensions/renderer/api_test_base.h"
+#include "gin/dictionary.h"
+#include "gin/wrappable.h"
#include "grit/extensions_renderer_resources.h"
namespace extensions {
+class DataReceiverFactory : public gin::Wrappable<DataReceiverFactory> {
+ public:
+ using Callback = base::Callback<void(
+ mojo::InterfaceRequest<device::serial::DataSource>,
+ mojo::InterfacePtr<device::serial::DataSourceClient>)>;
+ static gin::Handle<DataReceiverFactory> Create(v8::Isolate* isolate,
+ const Callback& callback) {
+ return gin::CreateHandle(isolate,
+ new DataReceiverFactory(callback, isolate));
+ }
+
+ gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
+ v8::Isolate* isolate) override {
+ return Wrappable<DataReceiverFactory>::GetObjectTemplateBuilder(isolate)
+ .SetMethod("create", &DataReceiverFactory::CreateReceiver);
+ }
+
+ gin::Dictionary CreateReceiver() {
+ mojo::InterfacePtr<device::serial::DataSource> sink;
+ mojo::InterfacePtr<device::serial::DataSourceClient> client;
+ mojo::InterfaceRequest<device::serial::DataSourceClient> client_request =
+ mojo::GetProxy(&client);
+ callback_.Run(mojo::GetProxy(&sink), client.Pass());
+
+ gin::Dictionary result = gin::Dictionary::CreateEmpty(isolate_);
+ result.Set("source", sink.PassMessagePipe().release());
+ result.Set("client", client_request.PassMessagePipe().release());
+ return result;
+ }
+
+ static gin::WrapperInfo kWrapperInfo;
+
+ private:
+ DataReceiverFactory(const Callback& callback, v8::Isolate* isolate)
+ : callback_(callback), isolate_(isolate) {}
+
+ base::Callback<void(mojo::InterfaceRequest<device::serial::DataSource>,
+ mojo::InterfacePtr<device::serial::DataSourceClient>)>
+ callback_;
+ v8::Isolate* isolate_;
+};
+
+gin::WrapperInfo DataReceiverFactory::kWrapperInfo = {gin::kEmbedderNativeGin};
+
// Runs tests defined in extensions/test/data/data_receiver_unittest.js
class DataReceiverTest : public ApiTestBase {
public:
@@ -18,8 +64,13 @@ class DataReceiverTest : public ApiTestBase {
void SetUp() override {
ApiTestBase::SetUp();
- service_provider()->AddService(base::Bind(
- &DataReceiverTest::CreateDataSource, base::Unretained(this)));
+ gin::ModuleRegistry::From(env()->context()->v8_context())
+ ->AddBuiltinModule(env()->isolate(),
+ "device/serial/data_receiver_test_factory",
+ DataReceiverFactory::Create(
+ env()->isolate(),
+ base::Bind(&DataReceiverTest::CreateDataSource,
+ base::Unretained(this))).ToV8());
}
void TearDown() override {
@@ -35,12 +86,12 @@ class DataReceiverTest : public ApiTestBase {
private:
void CreateDataSource(
- mojo::InterfaceRequest<device::serial::DataSource> request) {
- sender_ = mojo::WeakBindToRequest(
- new device::DataSourceSender(
- base::Bind(&DataReceiverTest::ReadyToSend, base::Unretained(this)),
- base::Bind(base::DoNothing)),
- &request);
+ mojo::InterfaceRequest<device::serial::DataSource> request,
+ mojo::InterfacePtr<device::serial::DataSourceClient> client) {
+ sender_ = new device::DataSourceSender(
+ request.Pass(), client.Pass(),
+ base::Bind(&DataReceiverTest::ReadyToSend, base::Unretained(this)),
+ base::Bind(base::DoNothing));
}
void ReadyToSend(scoped_ptr<device::WritableBuffer> buffer) {
diff --git a/extensions/renderer/api/serial/data_sender_unittest.cc b/extensions/renderer/api/serial/data_sender_unittest.cc
index e6a13af..461f012 100644
--- a/extensions/renderer/api/serial/data_sender_unittest.cc
+++ b/extensions/renderer/api/serial/data_sender_unittest.cc
@@ -38,12 +38,11 @@ class DataSenderTest : public ApiTestBase {
private:
void CreateDataSink(
mojo::InterfaceRequest<device::serial::DataSink> request) {
- receiver_ = mojo::WeakBindToRequest(
- new device::DataSinkReceiver(
- base::Bind(&DataSenderTest::ReadyToReceive, base::Unretained(this)),
- base::Bind(&DataSenderTest::OnCancel, base::Unretained(this)),
- base::Bind(base::DoNothing)),
- &request);
+ receiver_ = new device::DataSinkReceiver(
+ request.Pass(),
+ base::Bind(&DataSenderTest::ReadyToReceive, base::Unretained(this)),
+ base::Bind(&DataSenderTest::OnCancel, base::Unretained(this)),
+ base::Bind(base::DoNothing));
}
void ReadyToReceive(scoped_ptr<device::ReadOnlyBuffer> buffer) {