summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/api
diff options
context:
space:
mode:
authorsammc <sammc@chromium.org>2015-02-04 00:53:51 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-04 08:54:34 +0000
commit4b7484b40acaec1d7904c5f38bd4be116468013a (patch)
treefd1de1e8203ea228c53fdd22280d1d0fc7d816eb /extensions/renderer/api
parent332f0228d0231cf7b3c7d9bdbc4b9c3d35e9899c (diff)
downloadchromium_src-4b7484b40acaec1d7904c5f38bd4be116468013a.zip
chromium_src-4b7484b40acaec1d7904c5f38bd4be116468013a.tar.gz
chromium_src-4b7484b40acaec1d7904c5f38bd4be116468013a.tar.bz2
Revert of Remove Client= from device/serial/data_stream.mojom. (patchset #1 id:20001 of https://codereview.chromium.org/889283002/)
Reason for revert: Switching to two pipes broke FIFO assumption, causing DataSinkTest.CancelDuringError and SerialConnectionTest.Cancel to become flaky Original issue's description: > Remove Client= from device/serial/data_stream.mojom. > > BUG=451321 > > Committed: https://crrev.com/bc78a2320b50eba4fe397f1f838a82ad30b16cd6 > Cr-Commit-Position: refs/heads/master@{#314231} TBR=rockot@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=451321 Review URL: https://codereview.chromium.org/873293006 Cr-Commit-Position: refs/heads/master@{#314524}
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.cc67
2 files changed, 17 insertions, 117 deletions
diff --git a/extensions/renderer/api/serial/data_receiver_unittest.cc b/extensions/renderer/api/serial/data_receiver_unittest.cc
index 1be15969..f699d02 100644
--- a/extensions/renderer/api/serial/data_receiver_unittest.cc
+++ b/extensions/renderer/api/serial/data_receiver_unittest.cc
@@ -7,56 +7,10 @@
#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:
@@ -64,13 +18,8 @@ class DataReceiverTest : public ApiTestBase {
void SetUp() override {
ApiTestBase::SetUp();
- 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());
+ service_provider()->AddService(base::Bind(
+ &DataReceiverTest::CreateDataSource, base::Unretained(this)));
}
void TearDown() override {
@@ -86,12 +35,12 @@ class DataReceiverTest : public ApiTestBase {
private:
void CreateDataSource(
- 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));
+ mojo::InterfaceRequest<device::serial::DataSource> request) {
+ sender_ = mojo::WeakBindToRequest(
+ new device::DataSourceSender(
+ base::Bind(&DataReceiverTest::ReadyToSend, base::Unretained(this)),
+ base::Bind(base::DoNothing)),
+ &request);
}
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 f137007..e6a13af 100644
--- a/extensions/renderer/api/serial/data_sender_unittest.cc
+++ b/extensions/renderer/api/serial/data_sender_unittest.cc
@@ -7,55 +7,10 @@
#include "device/serial/data_sink_receiver.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 DataSenderFactory : public gin::Wrappable<DataSenderFactory> {
- public:
- using Callback =
- base::Callback<void(mojo::InterfaceRequest<device::serial::DataSink>,
- mojo::InterfacePtr<device::serial::DataSinkClient>)>;
- static gin::Handle<DataSenderFactory> Create(v8::Isolate* isolate,
- const Callback& callback) {
- return gin::CreateHandle(isolate, new DataSenderFactory(callback, isolate));
- }
-
- gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
- v8::Isolate* isolate) override {
- return Wrappable<DataSenderFactory>::GetObjectTemplateBuilder(isolate)
- .SetMethod("create", &DataSenderFactory::CreateReceiver);
- }
-
- gin::Dictionary CreateReceiver() {
- mojo::InterfacePtr<device::serial::DataSink> sink;
- mojo::InterfacePtr<device::serial::DataSinkClient> client;
- mojo::InterfaceRequest<device::serial::DataSinkClient> client_request =
- mojo::GetProxy(&client);
- callback_.Run(mojo::GetProxy(&sink), client.Pass());
-
- gin::Dictionary result = gin::Dictionary::CreateEmpty(isolate_);
- result.Set("sink", sink.PassMessagePipe().release());
- result.Set("client", client_request.PassMessagePipe().release());
- return result;
- }
-
- static gin::WrapperInfo kWrapperInfo;
-
- private:
- DataSenderFactory(const Callback& callback, v8::Isolate* isolate)
- : callback_(callback), isolate_(isolate) {}
-
- base::Callback<void(mojo::InterfaceRequest<device::serial::DataSink>,
- mojo::InterfacePtr<device::serial::DataSinkClient>)>
- callback_;
- v8::Isolate* isolate_;
-};
-
-gin::WrapperInfo DataSenderFactory::kWrapperInfo = {gin::kEmbedderNativeGin};
-
// Runs tests defined in extensions/test/data/data_sender_unittest.js
class DataSenderTest : public ApiTestBase {
public:
@@ -63,12 +18,8 @@ class DataSenderTest : public ApiTestBase {
void SetUp() override {
ApiTestBase::SetUp();
- gin::ModuleRegistry::From(env()->context()->v8_context())
- ->AddBuiltinModule(
- env()->isolate(), "device/serial/data_sender_test_factory",
- DataSenderFactory::Create(
- env()->isolate(), base::Bind(&DataSenderTest::CreateDataSink,
- base::Unretained(this))).ToV8());
+ service_provider()->AddService(
+ base::Bind(&DataSenderTest::CreateDataSink, base::Unretained(this)));
}
void TearDown() override {
@@ -86,13 +37,13 @@ class DataSenderTest : public ApiTestBase {
private:
void CreateDataSink(
- mojo::InterfaceRequest<device::serial::DataSink> request,
- mojo::InterfacePtr<device::serial::DataSinkClient> client) {
- receiver_ = new device::DataSinkReceiver(
- request.Pass(), client.Pass(),
- base::Bind(&DataSenderTest::ReadyToReceive, base::Unretained(this)),
- base::Bind(&DataSenderTest::OnCancel, base::Unretained(this)),
- base::Bind(base::DoNothing));
+ 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);
}
void ReadyToReceive(scoped_ptr<device::ReadOnlyBuffer> buffer) {