Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 var backgroundSetup = {} | |
| 2 | |
| 3 tryCreateActivity = function(id, title, tabId) { | |
|
achuithb
2015/07/09 21:40:10
Add a function comment
jdufault
2015/07/09 23:09:06
Done.
| |
| 4 if (id === undefined || title === undefined || tabId === undefined) | |
| 5 return null; | |
| 6 | |
| 7 return { | |
| 8 "id": id, | |
| 9 "title": title, | |
| 10 "tabId": tabId | |
| 11 }; | |
| 12 } | |
| 13 | |
| 14 var receiversActivities = []; | |
| 15 // Add a new receiver. |activityTitle| and |activityTabId| are optional | |
| 16 // parameters. | |
| 17 addReceiver = function(id, receiverName, activityTitle, activityTabId) { | |
| 18 receiversActivities.push({ | |
| 19 "activity": tryCreateActivity(id, activityTitle, activityTabId), | |
| 20 "receiver": { | |
| 21 "id": id, | |
| 22 "name": receiverName | |
| 23 } | |
| 24 }); | |
| 25 } | |
| 26 // Required API method. | |
| 27 getMirrorCapableReceiversAndActivities = function() { | |
| 28 if (this !== backgroundSetup) | |
|
achuithb
2015/07/09 21:40:10
What's this about? Add a comment
jdufault
2015/07/09 23:09:06
Done.
| |
| 29 throw 'this !== backgroundSetup'; | |
| 30 | |
| 31 return receiversActivities; | |
| 32 } | |
| 33 | |
| 34 var stopMirroringReason = ""; | |
| 35 var stopMirroringCalled = false; | |
| 36 wasStopMirroringCalledWithUserStop = function() { | |
|
achuithb
2015/07/09 21:40:10
function comment
jdufault
2015/07/09 23:09:06
It'd be something along the lines of "Returns true
| |
| 37 return stopMirroringCalled && stopMirroringReason == 'user-stop'; | |
| 38 } | |
| 39 // Required API method. | |
| 40 stopMirroring = function(reason) { | |
| 41 if (this !== backgroundSetup) | |
| 42 throw 'this !== backgroundSetup'; | |
| 43 | |
| 44 stopMirroringReason = reason; | |
| 45 stopMirroringCalled = true; | |
| 46 for (item of receiversActivities) { | |
| 47 if (item.activity != null) | |
|
achuithb
2015/07/09 21:40:10
Is it necessary to add any checks here that at lea
jdufault
2015/07/09 23:09:06
Sure, I can do that. It will help verify that stop
| |
| 48 item.activity = null; | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 var launchTabId = 1; | |
| 53 var launchTabTitle = "Fake Cast"; | |
| 54 var launchDesktopMirroringReceiverId = ""; | |
| 55 getLaunchDesktopMirroringReceiverId = function() { | |
| 56 return launchDesktopMirroringReceiverId; | |
| 57 } | |
| 58 // Required API method. | |
| 59 launchDesktopMirroring = function(receiverId) { | |
| 60 if (this !== backgroundSetup) | |
| 61 throw 'this !== backgroundSetup'; | |
| 62 | |
| 63 launchDesktopMirroringReceiverId = receiverId; | |
| 64 | |
| 65 for (item of receiversActivities) { | |
| 66 if (item.receiver.id == receiverId) { | |
|
achuithb
2015/07/09 21:40:10
Is it necessary to add any extra checks here to en
jdufault
2015/07/09 23:09:06
I'm not sure what value this will add. The testing
| |
| 67 item.activity = | |
| 68 tryCreateActivity(receiverId, launchTabId, launchTabTitle); | |
| 69 break; | |
| 70 } | |
| 71 } | |
| 72 } | |
| OLD | NEW |