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

Unified Diff: remoting/webapp/crd/js/video_frame_recorder.js

Issue 1028803002: [Chromoting] Convert VideoFrameRecorder into a proper protocol extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits Created 5 years, 9 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 | « remoting/webapp/crd/js/desktop_remoting.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/crd/js/video_frame_recorder.js
diff --git a/remoting/webapp/crd/js/video_frame_recorder.js b/remoting/webapp/crd/js/video_frame_recorder.js
index a5bceb91029c4f8e365325ab4768a1e2df60de4e..e73c832e26e967776cdf1709d1c665f9878b234f 100644
--- a/remoting/webapp/crd/js/video_frame_recorder.js
+++ b/remoting/webapp/crd/js/video_frame_recorder.js
@@ -14,39 +14,40 @@ var remoting = remoting || {};
/**
* @constructor
- * @param {remoting.ClientPlugin} plugin
+ * @implements {remoting.ProtocolExtension}
*/
-remoting.VideoFrameRecorder = function(plugin) {
+remoting.VideoFrameRecorder = function() {
+ /** @private {?function(string,string)} */
+ this.sendMessageToHostCallback_ = null;
+
this.fileWriter_ = null;
this.isRecording_ = false;
- this.plugin_ = plugin;
+};
+
+/** @private {string} */
+remoting.VideoFrameRecorder.EXTENSION_TYPE = 'video-recorder';
+
+/** @return {Array<string>} */
+remoting.VideoFrameRecorder.prototype.getExtensionTypes = function() {
+ return [remoting.VideoFrameRecorder.EXTENSION_TYPE];
};
/**
- * Starts or stops video recording.
+ * @param {function(string,string)} sendMessageToHost Callback to send a message
+ * to the host.
*/
-remoting.VideoFrameRecorder.prototype.startStopRecording = function() {
- var data = {};
- if (this.isRecording_) {
- this.isRecording_ = false;
- data = { type: 'stop' }
-
- chrome.fileSystem.chooseEntry(
- {type: 'saveFile', suggestedName: 'videoRecording.pb'},
- this.onFileChosen_.bind(this));
- } else {
- this.isRecording_ = true;
- data = { type: 'start' }
- }
- this.plugin_.sendClientMessage('video-recorder', JSON.stringify(data));
-}
+remoting.VideoFrameRecorder.prototype.startExtension =
+ function(sendMessageToHost) {
+ this.sendMessageToHostCallback_ = sendMessageToHost;
+};
/**
- * Returns true if the session is currently being recorded.
- * @return {boolean}
+ * @param {Object} data The data to send.
+ * @private
*/
-remoting.VideoFrameRecorder.prototype.isRecording = function() {
- return this.isRecording_;
+remoting.VideoFrameRecorder.prototype.sendMessageToHost_ = function(data) {
+ this.sendMessageToHostCallback_(remoting.VideoFrameRecorder.EXTENSION_TYPE,
+ JSON.stringify(data));
}
/**
@@ -57,11 +58,9 @@ remoting.VideoFrameRecorder.prototype.isRecording = function() {
* @param {Object} message The parsed extension message data.
* @return {boolean}
*/
-remoting.VideoFrameRecorder.prototype.handleMessage =
+remoting.VideoFrameRecorder.prototype.onExtensionMessage =
function(type, message) {
- if (type != 'video-recorder') {
- return false;
- }
+ base.debug.assert(type == remoting.VideoFrameRecorder.EXTENSION_TYPE);
var messageType = base.getStringAttr(message, 'type');
var messageData = base.getStringAttr(message, 'data');
@@ -115,6 +114,33 @@ remoting.VideoFrameRecorder.prototype.handleMessage =
}
/**
+ * Starts or stops video recording.
+ */
+remoting.VideoFrameRecorder.prototype.startStopRecording = function() {
+ var data = {};
+ if (this.isRecording_) {
+ this.isRecording_ = false;
+ data = { type: 'stop' }
+
+ chrome.fileSystem.chooseEntry(
+ {type: 'saveFile', suggestedName: 'videoRecording.pb'},
+ this.onFileChosen_.bind(this));
+ } else {
+ this.isRecording_ = true;
+ data = { type: 'start' }
+ }
+ this.sendMessageToHost_(data);
+}
+
+/**
+ * Returns true if the session is currently being recorded.
+ * @return {boolean}
+ */
+remoting.VideoFrameRecorder.prototype.isRecording = function() {
+ return this.isRecording_;
+}
+
+/**
* @param {Entry} entry The single file entry if multiple files are not allowed.
* @param {Array<FileEntry>} fileEntries List of file entries if multiple files
* are allowed.
@@ -147,5 +173,5 @@ remoting.VideoFrameRecorder.prototype.onWriteComplete_ = function(e) {
remoting.VideoFrameRecorder.prototype.fetchNextFrame_ = function() {
console.log("Request next video frame");
var data = { type: 'next-frame' }
- this.plugin_.sendClientMessage('video-recorder', JSON.stringify(data));
+ this.sendMessageToHost_(data);
}
« no previous file with comments | « remoting/webapp/crd/js/desktop_remoting.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698