Implement Track Registry

Implements a track registry so the track implementation can be loaded
dynamically. Adds barebones implementation of two track types
(CpuSliceTrack and CpuCounterTrack) for demoing the registry.

The track implementation is currently represented by TrackImpl class,
which can only draw on canvas using the draw() method. How a track will
implement DOM is still TBD and out of the scope for this CL.


Bug:111540363

Change-Id: I0489f161c3783af6d54568fe839301f47ae0291a
diff --git a/ui/src/common/state.ts b/ui/src/common/state.ts
index 3974987..c3c61c1 100644
--- a/ui/src/common/state.ts
+++ b/ui/src/common/state.ts
@@ -12,10 +12,28 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-export interface State { i: number; }
+/**
+ * A plain js object, holding objects of type |Class| keyed by string id.
+ * We use this instead of using |Map| object since it is simpler and faster to
+ * serialize for use in postMessage.
+ */
+export interface ObjectById<Class extends{id: string}> { [id: string]: Class; }
+
+export interface State {
+  i: number;
+  tracks: ObjectById<TrackState>;
+}
+
+export interface TrackState {
+  id: string;
+  type: string;
+  height: number;
+  name: string;
+}
 
 export function createEmptyState(): State {
   return {
     i: 0,
+    tracks: {},
   };
 }