Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Unified Diff: mojo/public/js/connector.js

Issue 2405093003: [WIP] Mojo native bindings interface.
Patch Set: fixes webui tests Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/js/bindings.js ('k') | mojo/public/js/interface_types.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/js/connector.js
diff --git a/mojo/public/js/connector.js b/mojo/public/js/connector.js
index ee16be80ce647aa7f22a9043ae9e1d8981fef2fb..87f818522b283b5f2dffd22c52062d6527ff48a9 100644
--- a/mojo/public/js/connector.js
+++ b/mojo/public/js/connector.js
@@ -5,13 +5,12 @@
define("mojo/public/js/connector", [
"mojo/public/js/buffer",
"mojo/public/js/codec",
- "mojo/public/js/core",
- "mojo/public/js/support",
-], function(buffer, codec, core, support) {
+], function(buffer, codec) {
function Connector(handle) {
- if (!core.isHandle(handle))
+ if (!(handle instanceof MojoHandle))
throw new Error("Connector: not a handle " + handle);
+
this.handle_ = handle;
this.dropWrites_ = false;
this.error_ = false;
@@ -20,19 +19,18 @@ define("mojo/public/js/connector", [
this.errorHandler_ = null;
if (handle) {
- this.readWatcher_ = support.watch(handle,
- core.HANDLE_SIGNAL_READABLE,
- this.readMore_.bind(this));
+ this.readWatcher_ = handle.watch({ readable: true },
+ this.readMore_.bind(this));
}
}
Connector.prototype.close = function() {
if (this.readWatcher_) {
- support.cancelWatch(this.readWatcher_);
+ this.readWatcher_.cancel();
this.readWatcher_ = null;
}
if (this.handle_ != null) {
- core.close(this.handle_);
+ this.handle_.close();
this.handle_ = null;
}
};
@@ -44,17 +42,15 @@ define("mojo/public/js/connector", [
if (this.dropWrites_)
return true;
- var result = core.writeMessage(this.handle_,
- new Uint8Array(message.buffer.arrayBuffer),
- message.handles,
- core.WRITE_MESSAGE_FLAG_NONE);
+ var result = this.handle_.writeMessage(message.buffer.arrayBuffer,
+ message.handles);
switch (result) {
- case core.RESULT_OK:
+ case Mojo.RESULT_OK:
// The handles were successfully transferred, so we don't own them
// anymore.
message.handles = [];
break;
- case core.RESULT_FAILED_PRECONDITION:
+ case Mojo.RESULT_FAILED_PRECONDITION:
// There's no point in continuing to write to this pipe since the other
// end is gone. Avoid writing any future messages. Hide write failures
// from the caller since we'd like them to continue consuming any
@@ -90,13 +86,12 @@ define("mojo/public/js/connector", [
Connector.prototype.readMore_ = function(result) {
for (;;) {
- var read = core.readMessage(this.handle_,
- core.READ_MESSAGE_FLAG_NONE);
+ var read = this.handle_.readMessage();
if (this.handle_ == null) // The connector has been closed.
return;
- if (read.result == core.RESULT_SHOULD_WAIT)
+ if (read.result == Mojo.RESULT_SHOULD_WAIT)
return;
- if (read.result != core.RESULT_OK) {
+ if (read.result != Mojo.RESULT_OK) {
this.error_ = true;
if (this.errorHandler_)
this.errorHandler_.onError(read.result);
« no previous file with comments | « mojo/public/js/bindings.js ('k') | mojo/public/js/interface_types.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698