Skip to content

Commit

Permalink
Add flow typing to QuickPerformanceLogger
Browse files Browse the repository at this point in the history
Reviewed By: cwdick

Differential Revision: D6613292

fbshipit-source-id: 58e41507a3c7cf9fbc6b972e327ae76d294d6807
  • Loading branch information
alexeylang authored and facebook-github-bot committed Jan 22, 2018
1 parent 5e11b88 commit bcfbdf4
Showing 1 changed file with 48 additions and 48 deletions.
96 changes: 48 additions & 48 deletions Libraries/Performance/QuickPerformanceLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,83 +7,83 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule QuickPerformanceLogger
* @flow
*/

'use strict';

var fixOpts = function(opts) {
var AUTO_SET_TIMESTAMP = -1;
var DUMMY_INSTANCE_KEY = 0;
opts = opts || {};
opts.instanceKey = opts.instanceKey || DUMMY_INSTANCE_KEY;
opts.timestamp = opts.timestamp || AUTO_SET_TIMESTAMP;
return opts;
};
const AUTO_SET_TIMESTAMP = -1;
const DUMMY_INSTANCE_KEY = 0;

var QuickPerformanceLogger = {
markerStart(markerId, opts) {
if (typeof markerId !== 'number') {
return;
}
const QuickPerformanceLogger = {
markerStart(
markerId: number,
instanceKey: number = DUMMY_INSTANCE_KEY,
timestamp: number = AUTO_SET_TIMESTAMP,
): void {
if (global.nativeQPLMarkerStart) {
opts = fixOpts(opts);
global.nativeQPLMarkerStart(markerId, opts.instanceKey, opts.timestamp);
global.nativeQPLMarkerStart(markerId, instanceKey, timestamp);
}
},

markerEnd(markerId, actionId, opts) {
if (typeof markerId !== 'number' || typeof actionId !== 'number') {
return;
}
markerEnd(
markerId: number,
actionId: number,
instanceKey: number = DUMMY_INSTANCE_KEY,
timestamp: number = AUTO_SET_TIMESTAMP,
): void {
if (global.nativeQPLMarkerEnd) {
opts = fixOpts(opts);
global.nativeQPLMarkerEnd(markerId, opts.instanceKey, actionId, opts.timestamp);
global.nativeQPLMarkerEnd(markerId, instanceKey, actionId, timestamp);
}
},

markerNote(markerId, actionId, opts) {
if (typeof markerId !== 'number' || typeof actionId !== 'number') {
return;
}
markerNote(
markerId: number,
actionId: number,
instanceKey: number = DUMMY_INSTANCE_KEY,
timestamp: number = AUTO_SET_TIMESTAMP,
): void {
if (global.nativeQPLMarkerNote) {
opts = fixOpts(opts);
global.nativeQPLMarkerNote(markerId, opts.instanceKey, actionId, opts.timestamp);
global.nativeQPLMarkerNote(markerId, instanceKey, actionId, timestamp);
}
},

markerTag(markerId, tag, opts) {
if (typeof markerId !== 'number' || typeof tag !== 'string') {
return;
}
markerTag(
markerId: number,
tag: string,
instanceKey: number = DUMMY_INSTANCE_KEY,
): void {
if (global.nativeQPLMarkerTag) {
opts = fixOpts(opts);
global.nativeQPLMarkerTag(markerId, opts.instanceKey, tag);
global.nativeQPLMarkerTag(markerId, instanceKey, tag);
}
},

markerAnnotate(markerId, annotationKey, annotationValue, opts) {
if (typeof markerId !== 'number' ||
typeof annotationKey !== 'string' ||
typeof annotationValue !== 'string') {
return;
}
markerAnnotate(
markerId: number,
annotationKey: string,
annotationValue: string,
instanceKey: number = DUMMY_INSTANCE_KEY,
): void {
if (global.nativeQPLMarkerAnnotate) {
opts = fixOpts(opts);
global.nativeQPLMarkerAnnotate(markerId, opts.instanceKey, annotationKey, annotationValue);
global.nativeQPLMarkerAnnotate(
markerId,
instanceKey,
annotationKey,
annotationValue,
);
}
},

markerCancel(markerId, opts) {
if (typeof markerId !== 'number') {
return;
}
markerCancel(
markerId: number,
instanceKey?: number = DUMMY_INSTANCE_KEY,
): void {
if (global.nativeQPLMarkerCancel) {
opts = fixOpts(opts);
global.nativeQPLMarkerCancel(markerId, opts.instanceKey);
global.nativeQPLMarkerCancel(markerId, instanceKey);
}
},

currentTimestamp() {
currentTimestamp(): number {
if (global.nativeQPLTimestamp) {
return global.nativeQPLTimestamp();
}
Expand Down

0 comments on commit bcfbdf4

Please sign in to comment.