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

Unified Diff: components/devtools_bridge/client/js/client_session.js

Issue 746663002: Stub for WebRTCDeviceProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webclient
Patch Set: Created 6 years, 1 month 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: components/devtools_bridge/client/js/client_session.js
diff --git a/components/devtools_bridge/client/js/client_session.js b/components/devtools_bridge/client/js/client_session.js
new file mode 100644
index 0000000000000000000000000000000000000000..1ce99a9edd9aa1ec75ed4aac7eae2c92dc0d0856
--- /dev/null
+++ b/components/devtools_bridge/client/js/client_session.js
@@ -0,0 +1,43 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * WebRTC session to the DevTools Bridge Server. Handles a peer connection.
+ * Client sends an offer to the server, waits for an answer and then
+ * handles ICE candidates exhange process.
+ *
+ * @Constructor
+ */
+function ClientSession(deviceId, gcdClient) {
+ this.deviceId_ = deviceId;
+ this.connection_ = new webkitRTCPeerConnection(null, null);
+ this.gcdClient_ = gcdClient;
+ this.id_ = ""; // TODO(serya): generate or pass ID.
+}
+
+ClientSession.prototype.start = function() {
+ this.connection_.createOffer(this.onOfferCreated_.bind(this),
+ this.onOfferFailed_.bind(this),
+ {});
+};
+
+ClientSession.prototype.stop = function() {
+ this.connection_.close();
+};
+
+ClientSession.prototype.onOfferCreated_ = function(offer) {
+ this.gcdClient_.sendCommand({
+ 'deviceId': this.deviceId_,
+ 'name': 'base._startSession',
+ 'parameters': {
+ '_sessionId': this.id_,
+ '_config': '{}',
+ '_offer': offer.sdp
+ }
+ });
+};
+
+ClientSession.prototype.onOfferFailed_ = function(error) {
+ console.log('Offer failed: ' + error);
+};

Powered by Google App Engine
This is Rietveld 408576698