ui: Move engine/query_result/etc to ui/src/trace_processor

Change-Id: Ib48957731e4bd79aa75b705fda6d8c2473a38f5d
diff --git a/ui/src/controller/aggregation/aggregation_controller.ts b/ui/src/controller/aggregation/aggregation_controller.ts
index 522131a..a038d0a 100644
--- a/ui/src/controller/aggregation/aggregation_controller.ts
+++ b/ui/src/controller/aggregation/aggregation_controller.ts
@@ -19,11 +19,11 @@
   ColumnDef,
   ThreadStateExtra,
 } from '../../common/aggregation_data';
-import {Engine} from '../../common/engine';
-import {NUM} from '../../common/query_result';
 import {Area, Sorting} from '../../common/state';
 import {globals} from '../../frontend/globals';
 import {publishAggregateData} from '../../frontend/publish';
+import {Engine} from '../../trace_processor/engine';
+import {NUM} from '../../trace_processor/query_result';
 import {AreaSelectionHandler} from '../area_selection_handler';
 import {Controller} from '../controller';
 
diff --git a/ui/src/controller/aggregation/counter_aggregation_controller.ts b/ui/src/controller/aggregation/counter_aggregation_controller.ts
index fcdb4d0..28b5b8d 100644
--- a/ui/src/controller/aggregation/counter_aggregation_controller.ts
+++ b/ui/src/controller/aggregation/counter_aggregation_controller.ts
@@ -14,10 +14,10 @@
 
 import {Duration} from '../../base/time';
 import {ColumnDef} from '../../common/aggregation_data';
-import {Engine} from '../../common/engine';
 import {pluginManager} from '../../common/plugins';
 import {Area, Sorting} from '../../common/state';
 import {globals} from '../../frontend/globals';
+import {Engine} from '../../trace_processor/engine';
 import {COUNTER_TRACK_KIND} from '../../tracks/counter';
 
 import {AggregationController} from './aggregation_controller';
diff --git a/ui/src/controller/aggregation/cpu_aggregation_controller.ts b/ui/src/controller/aggregation/cpu_aggregation_controller.ts
index ec3cf61..d2a659c 100644
--- a/ui/src/controller/aggregation/cpu_aggregation_controller.ts
+++ b/ui/src/controller/aggregation/cpu_aggregation_controller.ts
@@ -13,10 +13,10 @@
 // limitations under the License.
 
 import {ColumnDef} from '../../common/aggregation_data';
-import {Engine} from '../../common/engine';
 import {pluginManager} from '../../common/plugins';
 import {Area, Sorting} from '../../common/state';
 import {globals} from '../../frontend/globals';
+import {Engine} from '../../trace_processor/engine';
 import {CPU_SLICE_TRACK_KIND} from '../../tracks/cpu_slices';
 
 import {AggregationController} from './aggregation_controller';
diff --git a/ui/src/controller/aggregation/cpu_by_process_aggregation_controller.ts b/ui/src/controller/aggregation/cpu_by_process_aggregation_controller.ts
index deff299..e6de0f2 100644
--- a/ui/src/controller/aggregation/cpu_by_process_aggregation_controller.ts
+++ b/ui/src/controller/aggregation/cpu_by_process_aggregation_controller.ts
@@ -13,10 +13,10 @@
 // limitations under the License.
 
 import {ColumnDef} from '../../common/aggregation_data';
-import {Engine} from '../../common/engine';
 import {pluginManager} from '../../common/plugins';
 import {Area, Sorting} from '../../common/state';
 import {globals} from '../../frontend/globals';
+import {Engine} from '../../trace_processor/engine';
 import {CPU_SLICE_TRACK_KIND} from '../../tracks/cpu_slices';
 
 import {AggregationController} from './aggregation_controller';
diff --git a/ui/src/controller/aggregation/frame_aggregation_controller.ts b/ui/src/controller/aggregation/frame_aggregation_controller.ts
index cbe2448..e51bde9 100644
--- a/ui/src/controller/aggregation/frame_aggregation_controller.ts
+++ b/ui/src/controller/aggregation/frame_aggregation_controller.ts
@@ -13,10 +13,10 @@
 // limitations under the License.
 
 import {ColumnDef} from '../../common/aggregation_data';
-import {Engine} from '../../common/engine';
 import {pluginManager} from '../../common/plugins';
 import {Area, Sorting} from '../../common/state';
 import {globals} from '../../frontend/globals';
+import {Engine} from '../../trace_processor/engine';
 import {ACTUAL_FRAMES_SLICE_TRACK_KIND} from '../../tracks/actual_frames';
 
 import {AggregationController} from './aggregation_controller';
diff --git a/ui/src/controller/aggregation/slice_aggregation_controller.ts b/ui/src/controller/aggregation/slice_aggregation_controller.ts
index cb5e6f4..4de7003 100644
--- a/ui/src/controller/aggregation/slice_aggregation_controller.ts
+++ b/ui/src/controller/aggregation/slice_aggregation_controller.ts
@@ -13,10 +13,10 @@
 // limitations under the License.
 
 import {ColumnDef} from '../../common/aggregation_data';
-import {Engine} from '../../common/engine';
 import {pluginManager} from '../../common/plugins';
 import {Area, Sorting} from '../../common/state';
 import {globals} from '../../frontend/globals';
+import {Engine} from '../../trace_processor/engine';
 import {ASYNC_SLICE_TRACK_KIND} from '../../tracks/async_slices';
 import {SLICE_TRACK_KIND} from '../../tracks/chrome_slices';
 
diff --git a/ui/src/controller/aggregation/thread_aggregation_controller.ts b/ui/src/controller/aggregation/thread_aggregation_controller.ts
index 6818cfb..ae62cc4 100644
--- a/ui/src/controller/aggregation/thread_aggregation_controller.ts
+++ b/ui/src/controller/aggregation/thread_aggregation_controller.ts
@@ -13,12 +13,12 @@
 // limitations under the License.
 
 import {ColumnDef, ThreadStateExtra} from '../../common/aggregation_data';
-import {Engine} from '../../common/engine';
 import {pluginManager} from '../../common/plugins';
-import {NUM, NUM_NULL, STR_NULL} from '../../common/query_result';
 import {Area, Sorting} from '../../common/state';
 import {translateState} from '../../common/thread_state';
 import {globals} from '../../frontend/globals';
+import {Engine} from '../../trace_processor/engine';
+import {NUM, NUM_NULL, STR_NULL} from '../../trace_processor/query_result';
 import {THREAD_STATE_TRACK_KIND} from '../../tracks/thread_state';
 
 import {AggregationController} from './aggregation_controller';
diff --git a/ui/src/controller/cpu_profile_controller.ts b/ui/src/controller/cpu_profile_controller.ts
index 0f61cb2..66c1fb1 100644
--- a/ui/src/controller/cpu_profile_controller.ts
+++ b/ui/src/controller/cpu_profile_controller.ts
@@ -12,11 +12,11 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-import {Engine} from '../common/engine';
-import {NUM, STR} from '../common/query_result';
 import {CallsiteInfo, CpuProfileSampleSelection} from '../common/state';
 import {CpuProfileDetails, globals} from '../frontend/globals';
 import {publishCpuProfileDetails} from '../frontend/publish';
+import {Engine} from '../trace_processor/engine';
+import {NUM, STR} from '../trace_processor/query_result';
 
 import {Controller} from './controller';
 
diff --git a/ui/src/controller/flamegraph_controller.ts b/ui/src/controller/flamegraph_controller.ts
index c9e6f02..cebc952 100644
--- a/ui/src/controller/flamegraph_controller.ts
+++ b/ui/src/controller/flamegraph_controller.ts
@@ -14,7 +14,6 @@
 
 import {Duration, time} from '../base/time';
 import {Actions} from '../common/actions';
-import {Engine} from '../common/engine';
 import {
   ALLOC_SPACE_MEMORY_ALLOCATED_KEY,
   DEFAULT_VIEWING_OPTION,
@@ -27,10 +26,11 @@
   SPACE_MEMORY_ALLOCATED_NOT_FREED_KEY,
 } from '../common/flamegraph_util';
 import {pluginManager} from '../common/plugins';
-import {NUM, STR} from '../common/query_result';
 import {CallsiteInfo, FlamegraphState, ProfileType} from '../common/state';
 import {FlamegraphDetails, globals} from '../frontend/globals';
 import {publishFlamegraphDetails} from '../frontend/publish';
+import {Engine} from '../trace_processor/engine';
+import {NUM, STR} from '../trace_processor/query_result';
 import {PERF_SAMPLES_PROFILE_TRACK_KIND} from '../tracks/perf_samples_profile';
 
 import {AreaSelectionHandler} from './area_selection_handler';
diff --git a/ui/src/controller/flow_events_controller.ts b/ui/src/controller/flow_events_controller.ts
index bf586d9..b5be573 100644
--- a/ui/src/controller/flow_events_controller.ts
+++ b/ui/src/controller/flow_events_controller.ts
@@ -13,14 +13,14 @@
 // limitations under the License.
 
 import {Time} from '../base/time';
-import {Engine} from '../common/engine';
 import {featureFlags} from '../common/feature_flags';
 import {pluginManager} from '../common/plugins';
-import {LONG, NUM, STR_NULL} from '../common/query_result';
 import {Area} from '../common/state';
 import {Flow, globals} from '../frontend/globals';
 import {publishConnectedFlows, publishSelectedFlows} from '../frontend/publish';
 import {asSliceSqlId} from '../frontend/sql_types';
+import {Engine} from '../trace_processor/engine';
+import {LONG, NUM, STR_NULL} from '../trace_processor/query_result';
 import {ACTUAL_FRAMES_SLICE_TRACK_KIND} from '../tracks/actual_frames';
 import {SLICE_TRACK_KIND} from '../tracks/chrome_slices';
 
diff --git a/ui/src/controller/ftrace_controller.ts b/ui/src/controller/ftrace_controller.ts
index 27e600a..e596ff4 100644
--- a/ui/src/controller/ftrace_controller.ts
+++ b/ui/src/controller/ftrace_controller.ts
@@ -13,16 +13,16 @@
 // limitations under the License.
 
 import {Span, Time} from '../base/time';
-import {Engine} from '../common/engine';
 import {
   HighPrecisionTime,
   HighPrecisionTimeSpan,
 } from '../common/high_precision_time';
-import {LONG, NUM, STR, STR_NULL} from '../common/query_result';
 import {FtraceFilterState, Pagination} from '../common/state';
 import {FtraceEvent, globals} from '../frontend/globals';
 import {publishFtracePanelData} from '../frontend/publish';
 import {ratelimit} from '../frontend/rate_limiters';
+import {Engine} from '../trace_processor/engine';
+import {LONG, NUM, STR, STR_NULL} from '../trace_processor/query_result';
 
 import {Controller} from './controller';
 
diff --git a/ui/src/controller/loading_manager.ts b/ui/src/controller/loading_manager.ts
index 5b0e0cf..8b570f2 100644
--- a/ui/src/controller/loading_manager.ts
+++ b/ui/src/controller/loading_manager.ts
@@ -12,8 +12,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-import {LoadingTracker} from '../common/engine';
 import {publishLoading} from '../frontend/publish';
+import {LoadingTracker} from '../trace_processor/engine';
 
 // Used to keep track of whether the engine is currently querying.
 export class LoadingManager implements LoadingTracker {
diff --git a/ui/src/controller/logs_controller.ts b/ui/src/controller/logs_controller.ts
index 1a421ac..987a7fb 100644
--- a/ui/src/controller/logs_controller.ts
+++ b/ui/src/controller/logs_controller.ts
@@ -19,7 +19,6 @@
   Time,
   TimeSpan,
 } from '../base/time';
-import {Engine} from '../common/engine';
 import {
   LogBounds,
   LogBoundsKey,
@@ -27,11 +26,12 @@
   LogEntriesKey,
   LogExistsKey,
 } from '../common/logs';
-import {LONG, LONG_NULL, NUM, STR} from '../common/query_result';
-import {escapeGlob, escapeQuery} from '../common/query_utils';
 import {LogFilteringCriteria} from '../common/state';
 import {globals} from '../frontend/globals';
 import {publishTrackData} from '../frontend/publish';
+import {Engine} from '../trace_processor/engine';
+import {LONG, LONG_NULL, NUM, STR} from '../trace_processor/query_result';
+import {escapeGlob, escapeQuery} from '../trace_processor/query_utils';
 
 import {Controller} from './controller';
 
diff --git a/ui/src/controller/pivot_table_controller.ts b/ui/src/controller/pivot_table_controller.ts
index e8492df..adf0cf8 100644
--- a/ui/src/controller/pivot_table_controller.ts
+++ b/ui/src/controller/pivot_table_controller.ts
@@ -16,9 +16,7 @@
 
 import {Actions} from '../common/actions';
 import {DEFAULT_CHANNEL, getCurrentChannel} from '../common/channels';
-import {Engine} from '../common/engine';
 import {featureFlags} from '../common/feature_flags';
-import {ColumnType, STR} from '../common/query_result';
 import {
   AreaSelection,
   PivotTableQuery,
@@ -32,6 +30,8 @@
   generateQueryFromState,
 } from '../frontend/pivot_table_query_generator';
 import {Aggregation, PivotTree} from '../frontend/pivot_table_types';
+import {Engine} from '../trace_processor/engine';
+import {ColumnType, STR} from '../trace_processor/query_result';
 
 import {Controller} from './controller';
 
diff --git a/ui/src/controller/search_controller.ts b/ui/src/controller/search_controller.ts
index 28f8e55..4be8db7 100644
--- a/ui/src/controller/search_controller.ts
+++ b/ui/src/controller/search_controller.ts
@@ -22,14 +22,14 @@
   TimeSpan,
 } from '../base/time';
 import {exists} from '../base/utils';
-import {Engine} from '../common/engine';
 import {pluginManager} from '../common/plugins';
-import {LONG, NUM, STR} from '../common/query_result';
-import {escapeSearchQuery} from '../common/query_utils';
 import {CurrentSearchResults, SearchSummary} from '../common/search_data';
 import {OmniboxState} from '../common/state';
 import {globals} from '../frontend/globals';
 import {publishSearch, publishSearchResult} from '../frontend/publish';
+import {Engine} from '../trace_processor/engine';
+import {LONG, NUM, STR} from '../trace_processor/query_result';
+import {escapeSearchQuery} from '../trace_processor/query_utils';
 import {CPU_SLICE_TRACK_KIND} from '../tracks/cpu_slices';
 
 import {Controller} from './controller';
diff --git a/ui/src/controller/selection_controller.ts b/ui/src/controller/selection_controller.ts
index 7c44935..b75ad6f 100644
--- a/ui/src/controller/selection_controller.ts
+++ b/ui/src/controller/selection_controller.ts
@@ -15,17 +15,7 @@
 import {assertTrue} from '../base/logging';
 import {Time, time} from '../base/time';
 import {Args, ArgValue} from '../common/arg_types';
-import {Engine} from '../common/engine';
 import {pluginManager} from '../common/plugins';
-import {
-  durationFromSql,
-  LONG,
-  NUM,
-  NUM_NULL,
-  STR,
-  STR_NULL,
-  timeFromSql,
-} from '../common/query_result';
 import {ChromeSliceSelection} from '../common/state';
 import {
   CounterDetails,
@@ -38,6 +28,16 @@
   publishSliceDetails,
   publishThreadStateDetails,
 } from '../frontend/publish';
+import {Engine} from '../trace_processor/engine';
+import {
+  durationFromSql,
+  LONG,
+  NUM,
+  NUM_NULL,
+  STR,
+  STR_NULL,
+  timeFromSql,
+} from '../trace_processor/query_result';
 import {SLICE_TRACK_KIND} from '../tracks/chrome_slices';
 
 import {Controller} from './controller';
diff --git a/ui/src/controller/trace_controller.ts b/ui/src/controller/trace_controller.ts
index f323cb6..c44ce90 100644
--- a/ui/src/controller/trace_controller.ts
+++ b/ui/src/controller/trace_controller.ts
@@ -27,7 +27,6 @@
   DeferredAction,
 } from '../common/actions';
 import {cacheTrace} from '../common/cache_manager';
-import {Engine} from '../common/engine';
 import {featureFlags, Flag, PERF_SAMPLE_FLAG} from '../common/feature_flags';
 import {
   HighPrecisionTime,
@@ -39,15 +38,6 @@
   isMetatracingEnabled,
 } from '../common/metatracing';
 import {pluginManager} from '../common/plugins';
-import {
-  LONG,
-  LONG_NULL,
-  NUM,
-  NUM_NULL,
-  QueryError,
-  STR,
-  STR_NULL,
-} from '../common/query_result';
 import {onSelectionChanged} from '../common/selection_observer';
 import {
   defaultTraceTime,
@@ -74,6 +64,16 @@
 } from '../frontend/publish';
 import {runQueryInNewTab} from '../frontend/query_result_tab';
 import {Router} from '../frontend/router';
+import {Engine} from '../trace_processor/engine';
+import {
+  LONG,
+  LONG_NULL,
+  NUM,
+  NUM_NULL,
+  QueryError,
+  STR,
+  STR_NULL,
+} from '../trace_processor/query_result';
 
 import {
   CounterAggregationController,
diff --git a/ui/src/controller/trace_error_controller.ts b/ui/src/controller/trace_error_controller.ts
index ad491f7..005ed14 100644
--- a/ui/src/controller/trace_error_controller.ts
+++ b/ui/src/controller/trace_error_controller.ts
@@ -12,9 +12,9 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-import {Engine} from '../common/engine';
-import {NUM} from '../common/query_result';
 import {publishTraceErrors} from '../frontend/publish';
+import {Engine} from '../trace_processor/engine';
+import {NUM} from '../trace_processor/query_result';
 
 import {Controller} from './controller';
 
diff --git a/ui/src/controller/track_decider.ts b/ui/src/controller/track_decider.ts
index c07c1ab..5d7ddc7 100644
--- a/ui/src/controller/track_decider.ts
+++ b/ui/src/controller/track_decider.ts
@@ -21,16 +21,9 @@
   AddTrackArgs,
   DeferredAction,
 } from '../common/actions';
-import {Engine, EngineProxy} from '../common/engine';
 import {featureFlags, PERF_SAMPLE_FLAG} from '../common/feature_flags';
 import {pluginManager} from '../common/plugins';
 import {
-  NUM,
-  NUM_NULL,
-  STR,
-  STR_NULL,
-} from '../common/query_result';
-import {
   InThreadTrackSortKey,
   SCROLLING_TRACK_GROUP,
   TrackSortKey,
@@ -38,6 +31,13 @@
 } from '../common/state';
 import {PrimaryTrackSortKey} from '../public';
 import {getTrackName} from '../public/utils';
+import {Engine, EngineProxy} from '../trace_processor/engine';
+import {
+  NUM,
+  NUM_NULL,
+  STR,
+  STR_NULL,
+} from '../trace_processor/query_result';
 import {ACTUAL_FRAMES_SLICE_TRACK_KIND} from '../tracks/actual_frames';
 import {ASYNC_SLICE_TRACK_KIND} from '../tracks/async_slices';
 import {