Skip to content

Commit 624acc6

Browse files
committed
Add curly braces to all blocks.
Google style guide requires adding curly braces to all block statements even if it is only has one line. This fixes it by using eslint's --fix flag followed by running clang-format to reformat the change. Change-Id: Idc086c2aa8c02df5ef8b2140a11bfb9128eeb4bd
1 parent 0a21902 commit 624acc6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+683
-368
lines changed

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ module.exports = {
5656
"camelcase": "off",
5757
"comma-dangle": "off",
5858
"comma-spacing": "off",
59-
"curly": "off",
6059
"new-cap": "off",
6160
"no-multi-spaces": "off",
6261
"no-multiple-empty-lines": "off",

demo/asset_section.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,15 @@ shakaDemo.setupAssets_ = function() {
6666
}
6767

6868
let mimeTypes = [];
69-
if (asset.features.indexOf(shakaAssets.Feature.WEBM) >= 0)
69+
if (asset.features.indexOf(shakaAssets.Feature.WEBM) >= 0) {
7070
mimeTypes.push('video/webm');
71-
if (asset.features.indexOf(shakaAssets.Feature.MP4) >= 0)
71+
}
72+
if (asset.features.indexOf(shakaAssets.Feature.MP4) >= 0) {
7273
mimeTypes.push('video/mp4');
73-
if (asset.features.indexOf(shakaAssets.Feature.MP2TS) >= 0)
74+
}
75+
if (asset.features.indexOf(shakaAssets.Feature.MP2TS) >= 0) {
7476
mimeTypes.push('video/mp2t');
77+
}
7578
if (!mimeTypes.some(
7679
function(type) { return shakaDemo.support_.media[type]; })) {
7780
option.disabled = true;
@@ -247,8 +250,9 @@ shakaDemo.preparePlayer_ = function(asset) {
247250
config.abr.enabled =
248251
document.getElementById('enableAdaptation').checked;
249252
let smallGapLimit = document.getElementById('smallGapLimit').value;
250-
if (!isNaN(Number(smallGapLimit)) && smallGapLimit.length > 0)
253+
if (!isNaN(Number(smallGapLimit)) && smallGapLimit.length > 0) {
251254
config.streaming.smallGapLimit = Number(smallGapLimit);
255+
}
252256
config.streaming.jumpLargeGaps =
253257
document.getElementById('jumpLargeGaps').checked;
254258

demo/common/controls.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,9 @@ ShakaControls.prototype.onMouseMove_ = function(event) {
300300

301301
// When there is a touch, we can get a 'mousemove' event after touch events.
302302
// This should be treated as part of the touch, which has already been handled
303-
if (this.lastTouchEventTime_ && event.type == 'mousemove')
303+
if (this.lastTouchEventTime_ && event.type == 'mousemove') {
304304
return;
305+
}
305306

306307
// Use the cursor specified in the CSS file.
307308
this.videoContainer_.style.cursor = '';

demo/common/demo_utils.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ ShakaDemoUtils.setupAssetMetadata = function(asset, player) {
2929
{ drm: {}, manifest: { dash: {} } });
3030

3131
// Add config from this asset.
32-
if (asset.licenseServers)
32+
if (asset.licenseServers) {
3333
config.drm.servers = asset.licenseServers;
34-
if (asset.drmCallback)
34+
}
35+
if (asset.drmCallback) {
3536
config.manifest.dash.customScheme = asset.drmCallback;
36-
if (asset.clearKeys)
37+
}
38+
if (asset.clearKeys) {
3739
config.drm.clearKeys = asset.clearKeys;
40+
}
3841
player.configure(config);
3942

4043
// Configure network filters.
@@ -48,13 +51,16 @@ ShakaDemoUtils.setupAssetMetadata = function(asset, player) {
4851
networkingEngine.registerRequestFilter(filter);
4952
}
5053

51-
if (asset.requestFilter)
54+
if (asset.requestFilter) {
5255
networkingEngine.registerRequestFilter(asset.requestFilter);
53-
if (asset.responseFilter)
56+
}
57+
if (asset.responseFilter) {
5458
networkingEngine.registerResponseFilter(asset.responseFilter);
55-
if (asset.extraConfig)
56-
player.configure(/** @type {shakaExtern.PlayerConfiguration} */(
57-
asset.extraConfig));
59+
}
60+
if (asset.extraConfig) {
61+
player.configure(
62+
/** @type {shakaExtern.PlayerConfiguration} */ (asset.extraConfig));
63+
}
5864
};
5965

6066

demo/info_section.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,21 @@ shakaDemo.updateTrackOptions_ = function(list, tracks, languageAndRole) {
121121
let trackInfo = '';
122122
if (track.language) trackInfo += 'language: ' + track.language + ', ';
123123
if (track.label) trackInfo += 'label: ' + track.label + ', ';
124-
if (track.roles.length)
124+
if (track.roles.length) {
125125
trackInfo += 'roles: [' + track.roles.join() + '], ';
126-
if (track.width && track.height)
126+
}
127+
if (track.width && track.height) {
127128
trackInfo += track.width + 'x' + track.height + ', ';
129+
}
128130
trackInfo += track.bandwidth + ' bits/s';
129131
return trackInfo;
130132
} ,
131133
text: function(track) {
132134
let trackInfo = 'language: ' + track.language + ', ';
133135
if (track.label) trackInfo += 'label: ' + track.label + ', ';
134-
if (track.roles.length)
136+
if (track.roles.length) {
135137
trackInfo += 'roles: [' + track.roles.join() + '], ';
138+
}
136139
trackInfo += 'kind: ' + track.kind;
137140
return trackInfo;
138141
}
@@ -239,8 +242,9 @@ shakaDemo.updateLanguageOptions_ =
239242
if (selectedTrack.language == language) {
240243
if (selectedTrack.roles.length) {
241244
selectedTrack.roles.forEach(function(selectedRole) {
242-
if (selectedRole == role)
245+
if (selectedRole == role) {
243246
isSelected = true;
247+
}
244248
});
245249
} else {
246250
isSelected = true;

demo/main.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,9 @@ shakaDemo.updateFromHash_ = function() {
433433

434434
/** @private */
435435
shakaDemo.hashShouldChange_ = function() {
436-
if (!shakaDemo.hashCanChange_)
436+
if (!shakaDemo.hashCanChange_) {
437437
return;
438+
}
438439

439440
let params = [];
440441
let oldParams = shakaDemo.getParams_();
@@ -445,8 +446,9 @@ shakaDemo.hashShouldChange_ = function() {
445446
if (shakaDemo.player_) {
446447
assetUri = shakaDemo.player_.getManifestUri();
447448
let drmInfo = shakaDemo.player_.drmInfo();
448-
if (drmInfo)
449+
if (drmInfo) {
449450
licenseServerUri = drmInfo.licenseServerUri;
451+
}
450452
}
451453
let assetList = document.getElementById('assetList');
452454
if (assetUri) {
@@ -499,8 +501,9 @@ shakaDemo.hashShouldChange_ = function() {
499501
params.push('smallGapLimit=' +
500502
document.getElementById('smallGapLimit').value);
501503
}
502-
if (document.getElementById('jumpLargeGaps').checked)
504+
if (document.getElementById('jumpLargeGaps').checked) {
503505
params.push('jumpLargeGaps');
506+
}
504507
let audioLang = document.getElementById('preferredAudioLanguage').value;
505508
let textLang = document.getElementById('preferredTextLanguage').value;
506509
if (textLang != audioLang) {
@@ -540,12 +543,14 @@ shakaDemo.hashShouldChange_ = function() {
540543
// Store values for drm configuration.
541544
let videoRobustness =
542545
document.getElementById('drmSettingsVideoRobustness').value;
543-
if (videoRobustness)
546+
if (videoRobustness) {
544547
params.push('videoRobustness=' + videoRobustness);
548+
}
545549
let audioRobustness =
546550
document.getElementById('drmSettingsAudioRobustness').value;
547-
if (audioRobustness)
551+
if (audioRobustness) {
548552
params.push('audioRobustness=' + audioRobustness);
553+
}
549554

550555
// These parameters must be added manually, so preserve them.
551556
// These are only used by the loader in load.js to decide which version of

demo/offline_section.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,16 @@ shakaDemo.updateButtons_ = function(canHide) {
6565
button.disabled = (inProgress || !supportsDrm || option.isStored);
6666
button.innerText = storedContent ? 'Delete' : 'Store';
6767
let helpText = document.getElementById('storeDeleteHelpText');
68-
if (inProgress)
68+
if (inProgress) {
6969
helpText.textContent = 'Operation is in progress...';
70-
else if (!supportsDrm)
70+
} else if (!supportsDrm) {
7171
helpText.textContent = 'This browser does not support persistent licenses.';
72-
else if (button.disabled)
72+
} else if (button.disabled) {
7373
helpText.textContent = 'The asset is stored offline. ' +
7474
'Checkout the "Offline" section in the "Asset" list';
75-
else
75+
} else {
7676
helpText.textContent = '';
77+
}
7778
};
7879

7980

@@ -187,8 +188,9 @@ shakaDemo.storeDeleteAsset_ = function() {
187188
p = storage.remove(offlineUri).then(function() {
188189
for (let i = 0; i < assetList.options.length; i++) {
189190
let option = assetList.options[i];
190-
if (option.asset && option.asset.manifestUri == originalManifestUri)
191+
if (option.asset && option.asset.manifestUri == originalManifestUri) {
191192
option.isStored = false;
193+
}
192194
}
193195
return shakaDemo.refreshAssetList_();
194196
});
@@ -198,8 +200,9 @@ shakaDemo.storeDeleteAsset_ = function() {
198200
let assetName = asset.name ? '[OFFLINE] ' + asset.name : null;
199201
let metadata = {name: assetName || nameField || asset.manifestUri};
200202
p = storage.store(asset.manifestUri, metadata).then(function() {
201-
if (option.asset)
203+
if (option.asset) {
202204
option.isStored = true;
205+
}
203206
return shakaDemo.refreshAssetList_().then(function() {
204207
// Auto-select offline copy of asset after storing.
205208
let group = shakaDemo.offlineOptGroup_;

lib/abr/simple_abr_manager.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ shaka.abr.SimpleAbrManager.prototype.chooseVariant = function() {
141141
(minBandwidth / 1e6).toFixed(3),
142142
(maxBandwidth / 1e6).toFixed(3));
143143

144-
if (currentBandwidth >= minBandwidth && currentBandwidth <= maxBandwidth)
144+
if (currentBandwidth >= minBandwidth && currentBandwidth <= maxBandwidth) {
145145
chosen = variant;
146+
}
146147
}
147148

148149
this.lastTimeChosenMs_ = Date.now();
@@ -182,8 +183,9 @@ shaka.abr.SimpleAbrManager.prototype.segmentDownloaded = function(
182183
goog.asserts.assert(deltaTimeMs >= 0, 'expected a non-negative duration');
183184
this.bandwidthEstimator_.sample(deltaTimeMs, numBytes);
184185

185-
if ((this.lastTimeChosenMs_ != null) && this.enabled_)
186+
if ((this.lastTimeChosenMs_ != null) && this.enabled_) {
186187
this.suggestStreams_();
188+
}
187189
};
188190

189191

lib/cast/cast_receiver.js

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,9 @@ shaka.cast.CastReceiver.prototype.onCastStatusChanged_ = function() {
267267
let event = new shaka.util.FakeEvent('caststatuschanged');
268268
this.dispatchEvent(event);
269269
// Send a media status message, with a media info message if appropriate.
270-
if (!this.maybeSendMediaInfoMessage_())
270+
if (!this.maybeSendMediaInfoMessage_()) {
271271
this.sendMediaStatus_(0);
272+
}
272273
}.bind(this));
273274
};
274275

@@ -385,14 +386,16 @@ shaka.cast.CastReceiver.prototype.pollAttributes_ = function() {
385386
for (let name in shaka.cast.CastUtils.PlayerGetterMethodsThatRequireLive) {
386387
let frequency =
387388
shaka.cast.CastUtils.PlayerGetterMethodsThatRequireLive[name];
388-
if (this.updateNumber_ % frequency == 0)
389-
update['player'][name] = /** @type {Object} */(this.player_)[name]();
389+
if (this.updateNumber_ % frequency == 0) {
390+
update['player'][name] = /** @type {Object} */ (this.player_)[name]();
391+
}
390392
}
391393
}
392394
for (let name in shaka.cast.CastUtils.PlayerGetterMethods) {
393395
let frequency = shaka.cast.CastUtils.PlayerGetterMethods[name];
394-
if (this.updateNumber_ % frequency == 0)
395-
update['player'][name] = /** @type {Object} */(this.player_)[name]();
396+
if (this.updateNumber_ % frequency == 0) {
397+
update['player'][name] = /** @type {Object} */ (this.player_)[name]();
398+
}
396399
}
397400

398401
// Volume attributes are tied to the system volume.
@@ -406,8 +409,9 @@ shaka.cast.CastReceiver.prototype.pollAttributes_ = function() {
406409
// Only start progressing the update number once data is loaded,
407410
// just in case any of the "rarely changing" properties with less frequent
408411
// update messages changes significantly during the loading process.
409-
if (this.startUpdatingUpdateNumber_)
412+
if (this.startUpdatingUpdateNumber_) {
410413
this.updateNumber_ += 1;
414+
}
411415

412416
this.sendMessage_({
413417
'type': 'update',
@@ -598,8 +602,9 @@ shaka.cast.CastReceiver.prototype.onGenericMessage_ = function(event) {
598602
case 'SEEK': {
599603
let currentTime = message['currentTime'];
600604
let resumeState = message['resumeState'];
601-
if (currentTime != null)
605+
if (currentTime != null) {
602606
this.video_.currentTime = Number(currentTime);
607+
}
603608
if (resumeState && resumeState == 'PLAYBACK_START') {
604609
this.video_.play();
605610
this.sendMediaStatus_(0);
@@ -628,10 +633,12 @@ shaka.cast.CastReceiver.prototype.onGenericMessage_ = function(event) {
628633
let muted = volumeObject['muted'];
629634
let oldVolumeLevel = this.video_.volume;
630635
let oldVolumeMuted = this.video_.muted;
631-
if (level != null)
636+
if (level != null) {
632637
this.video_.volume = Number(level);
633-
if (muted != null)
638+
}
639+
if (muted != null) {
634640
this.video_.muted = muted;
641+
}
635642
// Notify generic controllers if the volume changed.
636643
if (oldVolumeLevel != this.video_.volume ||
637644
oldVolumeMuted != this.video_.muted) {
@@ -650,8 +657,9 @@ shaka.cast.CastReceiver.prototype.onGenericMessage_ = function(event) {
650657
let currentTime = message['currentTime'];
651658
let manifestUri = this.opt_contentIdCallback_(contentId);
652659
let autoplay = message['autoplay'] || true;
653-
if (autoplay)
660+
if (autoplay) {
654661
this.video_.autoplay = true;
662+
}
655663
this.player_.load(manifestUri, currentTime).then(function() {
656664
// Notify generic controllers that the media has changed.
657665
this.sendMediaInfoMessage_();
@@ -730,14 +738,15 @@ shaka.cast.CastReceiver.prototype.sendMessage_ =
730738
*/
731739
shaka.cast.CastReceiver.prototype.getPlayState_ = function() {
732740
let playState = shaka.cast.CastReceiver.PLAY_STATE;
733-
if (this.isIdle_)
741+
if (this.isIdle_) {
734742
return playState.IDLE;
735-
else if (this.player_.isBuffering())
743+
} else if (this.player_.isBuffering()) {
736744
return playState.BUFFERING;
737-
else if (this.video_.paused)
745+
} else if (this.video_.paused) {
738746
return playState.PAUSED;
739-
else
747+
} else {
740748
return playState.PLAYING;
749+
}
741750
};
742751

743752

@@ -774,8 +783,9 @@ shaka.cast.CastReceiver.prototype.sendMediaStatus_ =
774783
}
775784
};
776785

777-
if (opt_media)
786+
if (opt_media) {
778787
mediaStatus['media'] = opt_media;
788+
}
779789

780790
let ret = {
781791
'requestId': requestId,

lib/cast/cast_sender.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,9 @@ shaka.cast.CastSender.prototype.get = function(targetName, property) {
334334
property + ' should be called on a live stream!');
335335
// If the property shouldn't exist, return a fake function so that the
336336
// user doesn't call an undefined function and get a second error.
337-
if (!isLive)
338-
return function() { return undefined; };
337+
if (!isLive) {
338+
return () => undefined;
339+
}
339340
}
340341
if (CastUtils.PlayerVoidMethods.indexOf(property) >= 0) {
341342
return this.remoteCall_.bind(this, targetName, property);

0 commit comments

Comments
 (0)