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

Unified Diff: extensions/renderer/resources/data_receiver.js

Issue 571333002: Add serialization support to the JS DataSender and DataReceiver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stash-service
Patch Set: Created 6 years, 3 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
Index: extensions/renderer/resources/data_receiver.js
diff --git a/extensions/renderer/resources/data_receiver.js b/extensions/renderer/resources/data_receiver.js
index 9224e967bc92293f8c60e8cb1374c7ceeba5dd0f..91fb4012dff4a6f01151b4ce1008568393a13f5c 100644
--- a/extensions/renderer/resources/data_receiver.js
+++ b/extensions/renderer/resources/data_receiver.js
@@ -192,6 +192,46 @@ define('data_receiver', [
}
};
+ DataReceiver.prototype.serialize = function() {
raymes 2014/09/17 02:05:04 Please add comments to these :)
Sam McNally 2014/09/17 08:07:14 Done.
+ this.waiter_.stop();
+ if (this.receive_) {
+ this.receive_.dispatchFatalError(this.fatalErrorValue_);
+ this.receive_ = null;
+ }
+ var serialized = {
+ source: this.router_.connector_.handle_,
+ data_pipe: this.receivePipe_,
+ fatal_error_value: this.fatalErrorValue_,
+ bytes_received: this.bytesReceived_,
+ paused: this.paused_,
+ shut_down: this.shutDown_,
+ };
+ this.router_.connector_.handle_ = null;
+ this.router_.close();
+ this.shutDown_ = true;
+ return Promise.resolve(serialized);
+ };
+
+ DataReceiver.deserialize = function(serialized) {
+ var receiver = $Object.create(DataReceiver.prototype);
+ receiver.deserialize_(serialized);
+ return receiver;
+ };
+
+ DataReceiver.prototype.deserialize_ = function(serialized) {
+ this.receivePipe_ = serialized.data_pipe;
+ this.fatalErrorValue_ = serialized.fatal_error_value;
+ this.bytesReceived_ = serialized.bytes_received;
+ this.paused_ = serialized.paused;
+ this.shutDown_ = serialized.shut_down;
+ this.router_ = new router.Router(serialized.source);
+ this.router_.setIncomingReceiver(this);
+ this.source_ = new dataStream.DataSourceProxy(this.router_);
+ this.waiter_ = new asyncWaiter.AsyncWaiter(this.receivePipe_,
+ core.HANDLE_SIGNAL_READABLE,
+ this.onHandleReady_.bind(this));
+ };
+
/**
* Receive data from the DataSource.
* @return {Promise.<ArrayBuffer>} A promise to the received data. If an error

Powered by Google App Engine
This is Rietveld 408576698