bigtrace: remove from aosp

As we're developing in G3, remove the copy in AOSP to avoid confusion

Change-Id: Ia0bbdc899086b4d3f690dc8086067c8b3e264c7f
diff --git a/Android.bp b/Android.bp
index 06befe4..66838b7 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1956,11 +1956,6 @@
     name: "perfetto_include_perfetto_ext_base_version",
 }
 
-// GN: //include/perfetto/ext/bigtrace:bigtrace
-filegroup {
-    name: "perfetto_include_perfetto_ext_bigtrace_bigtrace",
-}
-
 // GN: //include/perfetto/ext/ipc:ipc
 filegroup {
     name: "perfetto_include_perfetto_ext_ipc_ipc",
@@ -2522,55 +2517,6 @@
     test_config: "PerfettoIntegrationTests.xml",
 }
 
-// GN: //protos/perfetto/bigtrace:lite
-filegroup {
-    name: "perfetto_protos_perfetto_bigtrace_lite",
-    srcs: [
-        "protos/perfetto/bigtrace/orchestrator.proto",
-        "protos/perfetto/bigtrace/worker.proto",
-    ],
-}
-
-// GN: //protos/perfetto/bigtrace:lite
-genrule {
-    name: "perfetto_protos_perfetto_bigtrace_lite_gen",
-    srcs: [
-        ":perfetto_protos_perfetto_bigtrace_lite",
-        ":perfetto_protos_perfetto_common_lite",
-        ":perfetto_protos_perfetto_trace_processor_lite",
-    ],
-    tools: [
-        "aprotoc",
-    ],
-    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --cpp_out=lite=true:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_bigtrace_lite)",
-    out: [
-        "external/perfetto/protos/perfetto/bigtrace/orchestrator.pb.cc",
-        "external/perfetto/protos/perfetto/bigtrace/worker.pb.cc",
-    ],
-}
-
-// GN: //protos/perfetto/bigtrace:lite
-genrule {
-    name: "perfetto_protos_perfetto_bigtrace_lite_gen_headers",
-    srcs: [
-        ":perfetto_protos_perfetto_bigtrace_lite",
-        ":perfetto_protos_perfetto_common_lite",
-        ":perfetto_protos_perfetto_trace_processor_lite",
-    ],
-    tools: [
-        "aprotoc",
-    ],
-    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --cpp_out=lite=true:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_bigtrace_lite)",
-    out: [
-        "external/perfetto/protos/perfetto/bigtrace/orchestrator.pb.h",
-        "external/perfetto/protos/perfetto/bigtrace/worker.pb.h",
-    ],
-    export_include_dirs: [
-        ".",
-        "protos",
-    ],
-}
-
 // GN: //protos/perfetto/common:cpp
 filegroup {
     name: "perfetto_protos_perfetto_common_cpp",
@@ -8136,56 +8082,6 @@
     ],
 }
 
-// GN: //protos/perfetto/trace_processor:lite
-filegroup {
-    name: "perfetto_protos_perfetto_trace_processor_lite",
-    srcs: [
-        "protos/perfetto/trace_processor/metatrace_categories.proto",
-        "protos/perfetto/trace_processor/stack.proto",
-        "protos/perfetto/trace_processor/trace_processor.proto",
-    ],
-}
-
-// GN: //protos/perfetto/trace_processor:lite
-genrule {
-    name: "perfetto_protos_perfetto_trace_processor_lite_gen",
-    srcs: [
-        ":perfetto_protos_perfetto_common_lite",
-        ":perfetto_protos_perfetto_trace_processor_lite",
-    ],
-    tools: [
-        "aprotoc",
-    ],
-    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --cpp_out=lite=true:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_processor_lite)",
-    out: [
-        "external/perfetto/protos/perfetto/trace_processor/metatrace_categories.pb.cc",
-        "external/perfetto/protos/perfetto/trace_processor/stack.pb.cc",
-        "external/perfetto/protos/perfetto/trace_processor/trace_processor.pb.cc",
-    ],
-}
-
-// GN: //protos/perfetto/trace_processor:lite
-genrule {
-    name: "perfetto_protos_perfetto_trace_processor_lite_gen_headers",
-    srcs: [
-        ":perfetto_protos_perfetto_common_lite",
-        ":perfetto_protos_perfetto_trace_processor_lite",
-    ],
-    tools: [
-        "aprotoc",
-    ],
-    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --cpp_out=lite=true:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_processor_lite)",
-    out: [
-        "external/perfetto/protos/perfetto/trace_processor/metatrace_categories.pb.h",
-        "external/perfetto/protos/perfetto/trace_processor/stack.pb.h",
-        "external/perfetto/protos/perfetto/trace_processor/trace_processor.pb.h",
-    ],
-    export_include_dirs: [
-        ".",
-        "protos",
-    ],
-}
-
 // GN: //protos/perfetto/trace_processor:metrics_impl_zero
 filegroup {
     name: "perfetto_protos_perfetto_trace_processor_metrics_impl_zero",
@@ -9847,24 +9743,6 @@
     ],
 }
 
-// GN: //src/bigtrace:sources
-filegroup {
-    name: "perfetto_src_bigtrace_sources",
-    srcs: [
-        "src/bigtrace/orchestrator_impl.cc",
-        "src/bigtrace/trace_processor_wrapper.cc",
-        "src/bigtrace/worker_impl.cc",
-    ],
-}
-
-// GN: //src/bigtrace:unittests
-filegroup {
-    name: "perfetto_src_bigtrace_unittests",
-    srcs: [
-        "src/bigtrace/trace_processor_wrapper_unittest.cc",
-    ],
-}
-
 // GN: //src/ipc:client
 filegroup {
     name: "perfetto_src_ipc_client",
@@ -13502,7 +13380,6 @@
         ":perfetto_include_perfetto_ext_base_http_http",
         ":perfetto_include_perfetto_ext_base_threading_threading",
         ":perfetto_include_perfetto_ext_base_version",
-        ":perfetto_include_perfetto_ext_bigtrace_bigtrace",
         ":perfetto_include_perfetto_ext_ipc_ipc",
         ":perfetto_include_perfetto_ext_trace_processor_demangle",
         ":perfetto_include_perfetto_ext_trace_processor_export_json",
@@ -13527,7 +13404,6 @@
         ":perfetto_include_perfetto_tracing_core_core",
         ":perfetto_include_perfetto_tracing_core_forward_decls",
         ":perfetto_include_perfetto_tracing_tracing",
-        ":perfetto_protos_perfetto_bigtrace_lite_gen",
         ":perfetto_protos_perfetto_common_cpp_gen",
         ":perfetto_protos_perfetto_common_lite_gen",
         ":perfetto_protos_perfetto_common_zero_gen",
@@ -13606,7 +13482,6 @@
         ":perfetto_protos_perfetto_trace_power_cpp_gen",
         ":perfetto_protos_perfetto_trace_power_lite_gen",
         ":perfetto_protos_perfetto_trace_power_zero_gen",
-        ":perfetto_protos_perfetto_trace_processor_lite_gen",
         ":perfetto_protos_perfetto_trace_processor_metrics_impl_zero_gen",
         ":perfetto_protos_perfetto_trace_processor_zero_gen",
         ":perfetto_protos_perfetto_trace_profiling_cpp_gen",
@@ -13645,8 +13520,6 @@
         ":perfetto_src_base_unittests",
         ":perfetto_src_base_unix_socket",
         ":perfetto_src_base_version",
-        ":perfetto_src_bigtrace_sources",
-        ":perfetto_src_bigtrace_unittests",
         ":perfetto_src_ipc_client",
         ":perfetto_src_ipc_common",
         ":perfetto_src_ipc_host",
@@ -13884,7 +13757,6 @@
         "perfetto_gtest_logcat_printer",
     ],
     generated_headers: [
-        "perfetto_protos_perfetto_bigtrace_lite_gen_headers",
         "perfetto_protos_perfetto_common_cpp_gen_headers",
         "perfetto_protos_perfetto_common_lite_gen_headers",
         "perfetto_protos_perfetto_common_zero_gen_headers",
@@ -13963,7 +13835,6 @@
         "perfetto_protos_perfetto_trace_power_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_power_lite_gen_headers",
         "perfetto_protos_perfetto_trace_power_zero_gen_headers",
-        "perfetto_protos_perfetto_trace_processor_lite_gen_headers",
         "perfetto_protos_perfetto_trace_processor_metrics_impl_zero_gen_headers",
         "perfetto_protos_perfetto_trace_processor_zero_gen_headers",
         "perfetto_protos_perfetto_trace_profiling_cpp_gen_headers",
diff --git a/BUILD.gn b/BUILD.gn
index 0a93081..0369d78 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -45,7 +45,6 @@
 }
 
 if (enable_perfetto_trace_processor && enable_perfetto_trace_processor_sqlite) {
-  all_targets += [ "src/bigtrace" ]
   all_targets += [ "src/trace_processor:trace_processor_shell" ]
 }
 
diff --git a/gn/perfetto_unittests.gni b/gn/perfetto_unittests.gni
index 91e8d5d..f5f9bb3 100644
--- a/gn/perfetto_unittests.gni
+++ b/gn/perfetto_unittests.gni
@@ -77,7 +77,6 @@
 
   if (enable_perfetto_trace_processor_sqlite) {
     perfetto_unittests_targets += [ "src/trace_processor/metrics:unittests" ]
-    perfetto_unittests_targets += [ "src/bigtrace:unittests" ]
   }
 }
 
diff --git a/include/perfetto/ext/bigtrace/BUILD.gn b/include/perfetto/ext/bigtrace/BUILD.gn
deleted file mode 100644
index e40ba6d..0000000
--- a/include/perfetto/ext/bigtrace/BUILD.gn
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2023 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-source_set("bigtrace") {
-  sources = [
-    "environment.h",
-    "orchestrator.h",
-    "worker.h",
-  ]
-  deps = [
-    "../../../../gn:default_deps",
-    "../base",
-    "../base/threading",
-  ]
-}
diff --git a/include/perfetto/ext/bigtrace/environment.h b/include/perfetto/ext/bigtrace/environment.h
deleted file mode 100644
index 943ad94..0000000
--- a/include/perfetto/ext/bigtrace/environment.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef INCLUDE_PERFETTO_EXT_BIGTRACE_ENVIRONMENT_H_
-#define INCLUDE_PERFETTO_EXT_BIGTRACE_ENVIRONMENT_H_
-
-#include <functional>
-#include <memory>
-#include <vector>
-
-#include "perfetto/base/status.h"
-#include "perfetto/base/task_runner.h"
-#include "perfetto/ext/base/status_or.h"
-#include "perfetto/ext/base/threading/stream.h"
-
-namespace perfetto {
-namespace bigtrace {
-
-// Shim interface allowing embedders to change how operations which interact
-// with the OS operate (e.g. IO, networking etc).
-class Environment {
- public:
-  virtual ~Environment();
-
-  // Opens the file at |path| and reads the contents in chunks, returning the
-  // the chunks as a Stream. The size of the chunks is implementation defined
-  // but should be sized to balance memory use and syscall count.
-  virtual base::StatusOrStream<std::vector<uint8_t>> ReadFile(
-      const std::string& path) = 0;
-};
-
-}  // namespace bigtrace
-}  // namespace perfetto
-
-#endif  // INCLUDE_PERFETTO_EXT_BIGTRACE_ENVIRONMENT_H_
diff --git a/include/perfetto/ext/bigtrace/orchestrator.h b/include/perfetto/ext/bigtrace/orchestrator.h
deleted file mode 100644
index 0cefe46..0000000
--- a/include/perfetto/ext/bigtrace/orchestrator.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef INCLUDE_PERFETTO_EXT_BIGTRACE_ORCHESTRATOR_H_
-#define INCLUDE_PERFETTO_EXT_BIGTRACE_ORCHESTRATOR_H_
-
-#include <memory>
-#include <vector>
-
-#include "perfetto/base/status.h"
-#include "perfetto/base/task_runner.h"
-#include "perfetto/ext/base/status_or.h"
-#include "perfetto/ext/base/threading/future.h"
-#include "perfetto/ext/base/threading/stream.h"
-
-namespace perfetto {
-namespace protos {
-class TracePoolCreateArgs;
-class TracePoolCreateResponse;
-
-class TracePoolSetTracesArgs;
-class TracePoolSetTracesResponse;
-
-class TracePoolQueryArgs;
-class TracePoolQueryResponse;
-
-class TracePoolDestroyArgs;
-class TracePoolDestroyResponse;
-}  // namespace protos
-}  // namespace perfetto
-
-namespace perfetto {
-namespace bigtrace {
-
-class Worker;
-
-// Interface for a BigTrace "Orchestrator".
-//
-// See BigTraceOrchestrator RPC service for high-level documentation.
-class Orchestrator {
- public:
-  virtual ~Orchestrator();
-
-  // Returns an in-process implementation of the Orchestrator, given a group of
-  // workers which can be delegated to.
-  //
-  // Note that the passed workers instances can be "remote" (i.e. in another
-  // process or even on another machine); the returned manager will gracefully
-  // handle this.
-  static std::unique_ptr<Orchestrator> CreateInProcess(
-      base::TaskRunner*,
-      std::vector<std::unique_ptr<Worker>> workers);
-
-  // Creates a TracePool with the specified arguments.
-  virtual base::StatusOrFuture<protos::TracePoolCreateResponse> TracePoolCreate(
-      const protos::TracePoolCreateArgs&) = 0;
-
-  // Associates the provided list of traces to this TracePoolShard.
-  virtual base::StatusOrFuture<protos::TracePoolSetTracesResponse>
-  TracePoolSetTraces(const protos::TracePoolSetTracesArgs&) = 0;
-
-  // Executes a SQL query on the specified TracePool.
-  virtual base::StatusOrStream<protos::TracePoolQueryResponse> TracePoolQuery(
-      const protos::TracePoolQueryArgs&) = 0;
-
-  // Destroys the TracePool with the specified id.
-  virtual base::StatusOrFuture<protos::TracePoolDestroyResponse>
-  TracePoolDestroy(const protos::TracePoolDestroyArgs&) = 0;
-};
-
-}  // namespace bigtrace
-}  // namespace perfetto
-
-#endif  // INCLUDE_PERFETTO_EXT_BIGTRACE_ORCHESTRATOR_H_
diff --git a/include/perfetto/ext/bigtrace/worker.h b/include/perfetto/ext/bigtrace/worker.h
deleted file mode 100644
index 93af24b..0000000
--- a/include/perfetto/ext/bigtrace/worker.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef INCLUDE_PERFETTO_EXT_BIGTRACE_WORKER_H_
-#define INCLUDE_PERFETTO_EXT_BIGTRACE_WORKER_H_
-
-#include <memory>
-#include <vector>
-
-#include "perfetto/base/task_runner.h"
-#include "perfetto/ext/base/threading/future.h"
-#include "perfetto/ext/base/threading/stream.h"
-
-namespace perfetto {
-
-namespace base {
-class ThreadPool;
-}
-
-namespace protos {
-class SyncTraceStateArgs;
-class SyncTraceStateResponse;
-
-class QueryTraceArgs;
-class QueryTraceResponse;
-}  // namespace protos
-
-namespace bigtrace {
-
-class Environment;
-
-// Interface for a BigTrace "Worker".
-//
-// See BigTraceWorker RPC service for high-level documentation.
-class Worker {
- public:
-  virtual ~Worker();
-
-  // Returns an in-process implementation of the Worker given an instance of
-  // |Environment| and a |ThreadPool|. The |Environment| will be used to
-  // perform any interaction with the OS (e.g. opening and reading files) and
-  // the |ThreadPool| will be used to dispatch requests to TraceProcessor.
-  static std::unique_ptr<Worker> CreateInProcesss(base::TaskRunner*,
-                                                  Environment*,
-                                                  base::ThreadPool*);
-
-  // Synchronize the state of the traces in the worker to the orchestrator.
-  virtual base::StatusOrStream<protos::SyncTraceStateResponse> SyncTraceState(
-      const protos::SyncTraceStateArgs&) = 0;
-
-  // Executes a SQL query on the specified trace.
-  virtual base::StatusOrStream<protos::QueryTraceResponse> QueryTrace(
-      const protos::QueryTraceArgs&) = 0;
-};
-
-}  // namespace bigtrace
-}  // namespace perfetto
-
-#endif  // INCLUDE_PERFETTO_EXT_BIGTRACE_WORKER_H_
diff --git a/protos/perfetto/bigtrace/BUILD.gn b/protos/perfetto/bigtrace/BUILD.gn
deleted file mode 100644
index 33e87d2..0000000
--- a/protos/perfetto/bigtrace/BUILD.gn
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import("../../../gn/proto_library.gni")
-
-SOURCES = [
-  "orchestrator.proto",
-  "worker.proto",
-]
-
-perfetto_proto_library("@TYPE@") {
-  proto_generators = [
-    "lite",
-    "zero",
-    "source_set",
-  ]
-  deps = [ "../trace_processor:@TYPE@" ]  # needed for descriptor.proto.
-  sources = SOURCES
-}
-
-if (enable_perfetto_grpc) {
-  perfetto_grpc_library("bigtrace_grpc") {
-    deps = [ ":lite" ]
-    sources = SOURCES
-  }
-}
diff --git a/protos/perfetto/bigtrace/orchestrator.proto b/protos/perfetto/bigtrace/orchestrator.proto
deleted file mode 100644
index 4807289..0000000
--- a/protos/perfetto/bigtrace/orchestrator.proto
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-syntax = "proto2";
-
-package perfetto.protos;
-
-import "protos/perfetto/trace_processor/trace_processor.proto";
-
-// RPC interface for a BigTrace Orchestrator.
-//
-// Each BigTrace instance has a single Orchestrator which is
-// responsible for receiving requests for loading and querying traces from
-// clients and shards these requests among a set of "Workers".
-service BigTraceOrchestrator {
-  // Creates a TracePool with the specified arguments.
-  //
-  // A TracePool is a logical group of traces which can be addressed with a
-  // single id.
-  //
-  // Pools are shared: the trace processor instances backing the pool are shared
-  // among a group of users. This implicitly means that the pools are
-  // "stateless" (i.e. do not preserve trace processor state between RPCs) as
-  // the state of one user should not interfere with the state of another.
-  rpc TracePoolCreate(TracePoolCreateArgs) returns (TracePoolCreateResponse);
-
-  // Changes the set of traces associated with the specified TracePool.
-  //
-  // If this operation completes successfully, any future requests to this pool
-  // will refer to this set of traces.
-  rpc TracePoolSetTraces(TracePoolSetTracesArgs)
-      returns (TracePoolSetTracesResponse);
-
-  // Executes a SQL query on the specified TracePool and returns a stream
-  // with each element being the response for executing the query on the
-  // associated trace.
-  //
-  // Note that each trace can return >1 result due to chunking of protos at the
-  // TraceProcessor::QueryResult level.
-  rpc TracePoolQuery(TracePoolQueryArgs)
-      returns (stream TracePoolQueryResponse);
-
-  // Destroys the TracePool with the specified id.
-  //
-  // Any future requests to this pool will return an error. However, the
-  // same pool id can be used to create a new pool.
-  rpc TracePoolDestroy(TracePoolDestroyArgs) returns (TracePoolDestroyResponse);
-}
-
-// Request/Response for Orchestrator::TracePoolCreate.
-message TracePoolCreateArgs {
-  // The name which should be refer to the pool. This name will form part of
-  // |pool_id|.
-  optional string pool_name = 2;
-}
-message TracePoolCreateResponse {
-  // The id of the pool which should be used to reference the pool in all future
-  // RPCs. This id is expected to be a stable transformation of |pool_name|.
-  optional string pool_id = 1;
-}
-
-// Request/Response for Orchestrator::TracePoolSetTraces.
-message TracePoolSetTracesArgs {
-  optional string pool_id = 1;
-
-  // The list of traces which should be associated with this pool. The existing
-  // loaded trace list will be diffed against this list. Traces not present in
-  // this list and loaded will be unloaded while traces present in this list
-  // and unloaded will be loaded.
-  repeated string traces = 2;
-}
-message TracePoolSetTracesResponse {}
-
-// Request/Response for Orchestrator::TracePoolQuery.
-message TracePoolQueryArgs {
-  optional string pool_id = 1;
-  optional string sql_query = 2;
-}
-message TracePoolQueryResponse {
-  optional string trace = 1;
-  optional QueryResult result = 2;
-}
-
-// Request/Response for Orchestrator::TracePoolDestroy.
-message TracePoolDestroyArgs {
-  optional string pool_id = 1;
-}
-message TracePoolDestroyResponse {}
diff --git a/protos/perfetto/bigtrace/worker.proto b/protos/perfetto/bigtrace/worker.proto
deleted file mode 100644
index af24fa5..0000000
--- a/protos/perfetto/bigtrace/worker.proto
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-syntax = "proto2";
-
-package perfetto.protos;
-
-import "protos/perfetto/trace_processor/trace_processor.proto";
-
-// Interface for a BigTrace "Worker".
-//
-// Workers are owned by an |Orchestrator| which assigns traces and forwards any
-// requests from end users. Workers are responsible for loading assigned traces
-// with TraceProcessor and executing the requests.
-service BigTraceWorker {
-  // Synchronize the state of the traces in the worker to the orchestrator. The
-  // orchestrator uses this method to ensure the worker is always fully up to
-  // date with the state according to the orchestrator. This makes the system
-  // resilient to worker restarts (i.e. loss of local state).
-  rpc SyncTraceState(SyncTraceStateArgs)
-      returns (stream SyncTraceStateResponse);
-
-  // Executes a SQL query on the specified trace and returns a stream of
-  // execution responses. Note that this method returns a stream because each
-  // trace can return >1 result due to chunking of protos at the
-  // TraceProcessor::QueryResult level.
-  rpc QueryTrace(QueryTraceArgs) returns (stream QueryTraceResponse);
-}
-
-// Request/Response for Worker::Sync.
-message SyncTraceStateArgs {
-  repeated string traces = 1;
-}
-message SyncTraceStateResponse {
-  optional double load_progress = 1;
-}
-
-// Request/Response for Worker::TraceQuery.
-message QueryTraceArgs {
-  optional string trace = 1;
-  optional string sql_query = 2;
-}
-message QueryTraceResponse {
-  optional string trace = 1;
-  optional QueryResult result = 2;
-}
diff --git a/src/bigtrace/BUILD.gn b/src/bigtrace/BUILD.gn
deleted file mode 100644
index 270363f..0000000
--- a/src/bigtrace/BUILD.gn
+++ /dev/null
@@ -1,64 +0,0 @@
-# Copyright (C) 2023 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import("../../gn/perfetto.gni")
-import("../../gn/test.gni")
-
-assert(
-    enable_perfetto_trace_processor && enable_perfetto_trace_processor_sqlite)
-
-# The "core" business logic of BigTrace which is agnostic to the
-# RPC transport. Allows wrapping with any RPC framework capable of handling
-# protobufs.
-static_library("bigtrace") {
-  complete_static_lib = true
-  deps = [ ":sources" ]
-  public_deps = [ "../../include/perfetto/ext/bigtrace" ]
-}
-
-source_set("sources") {
-  sources = [
-    "orchestrator_impl.cc",
-    "orchestrator_impl.h",
-    "trace_processor_wrapper.cc",
-    "trace_processor_wrapper.h",
-    "worker_impl.cc",
-    "worker_impl.h",
-  ]
-  deps = [
-    "../../gn:default_deps",
-    "../../include/perfetto/ext/bigtrace",
-    "../../protos/perfetto/bigtrace:lite",
-    "../base",
-    "../base/threading",
-    "../protozero",
-    "../protozero:proto_ring_buffer",
-    "../trace_processor:lib",
-    "../trace_processor/rpc",
-    "../trace_processor/util",
-  ]
-}
-
-perfetto_unittest_source_set("unittests") {
-  testonly = true
-  sources = [ "trace_processor_wrapper_unittest.cc" ]
-  deps = [
-    ":sources",
-    "../../gn:default_deps",
-    "../../gn:gtest_and_gmock",
-    "../../protos/perfetto/bigtrace:lite",
-    "../base",
-    "../base/threading",
-  ]
-}
diff --git a/src/bigtrace/orchestrator_impl.cc b/src/bigtrace/orchestrator_impl.cc
deleted file mode 100644
index d6aa22f..0000000
--- a/src/bigtrace/orchestrator_impl.cc
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "src/bigtrace/orchestrator_impl.h"
-
-#include <memory>
-#include <optional>
-#include <string>
-#include <unordered_set>
-#include <utility>
-#include <vector>
-
-#include "perfetto/base/status.h"
-#include "perfetto/base/task_runner.h"
-#include "perfetto/ext/base/flat_hash_map.h"
-#include "perfetto/ext/base/periodic_task.h"
-#include "perfetto/ext/base/status_or.h"
-#include "perfetto/ext/base/threading/future.h"
-#include "perfetto/ext/base/threading/poll.h"
-#include "perfetto/ext/base/threading/spawn.h"
-#include "perfetto/ext/base/threading/stream.h"
-#include "perfetto/ext/bigtrace/orchestrator.h"
-#include "perfetto/ext/bigtrace/worker.h"
-#include "protos/perfetto/bigtrace/orchestrator.pb.h"
-#include "protos/perfetto/bigtrace/worker.pb.h"
-#include "src/trace_processor/util/status_macros.h"
-
-namespace perfetto {
-namespace bigtrace {
-namespace {
-
-base::Future<base::StatusOr<protos::TracePoolQueryResponse>>
-RpcResponseToPoolResponse(base::StatusOr<protos::QueryTraceResponse> resp) {
-  RETURN_IF_ERROR(resp.status());
-  protos::TracePoolQueryResponse ret;
-  ret.set_trace(std::move(resp->trace()));
-  *ret.mutable_result() = std::move(*resp->mutable_result());
-  return ret;
-}
-
-// The period of sync of state from the orchestrator to all the workers. This
-// constant trades freshness (i.e. lower period) vs unnecessary work (i.e.
-// higher period). 15s seems an acceptable number even for interactive trace
-// loads.
-static constexpr uint32_t kDefaultWorkerSyncPeriod = 15000;
-
-}  // namespace
-
-Orchestrator::~Orchestrator() = default;
-
-std::unique_ptr<Orchestrator> Orchestrator::CreateInProcess(
-    base::TaskRunner* task_runner,
-    std::vector<std::unique_ptr<Worker>> workers) {
-  return std::unique_ptr<Orchestrator>(
-      new OrchestratorImpl(task_runner, std::move(workers)));
-}
-
-OrchestratorImpl::OrchestratorImpl(base::TaskRunner* task_runner,
-                                   std::vector<std::unique_ptr<Worker>> workers)
-    : task_runner_(task_runner),
-      periodic_sync_task_(task_runner),
-      workers_(std::move(workers)) {
-  base::PeriodicTask::Args args;
-  args.task = [this] { ExecuteSyncWorkers(); };
-  args.period_ms = kDefaultWorkerSyncPeriod;
-  args.start_first_task_immediately = true;
-  periodic_sync_task_.Start(std::move(args));
-}
-
-base::StatusOrFuture<protos::TracePoolCreateResponse>
-OrchestratorImpl::TracePoolCreate(const protos::TracePoolCreateArgs& args) {
-  if (!args.has_pool_name()) {
-    return base::StatusOr<protos::TracePoolCreateResponse>(
-        base::ErrStatus("Pool name must be provided"));
-  }
-  std::string id = "stateless:" + args.pool_name();
-  if (auto it_inserted = pools_.Insert(id, TracePool()); !it_inserted.second) {
-    return base::StatusOr<protos::TracePoolCreateResponse>(
-        base::ErrStatus("Pool '%s' already exists", id.c_str()));
-  }
-  return protos::TracePoolCreateResponse();
-}
-
-base::StatusOrFuture<protos::TracePoolSetTracesResponse>
-OrchestratorImpl::TracePoolSetTraces(
-    const protos::TracePoolSetTracesArgs& args) {
-  std::string id = args.pool_id();
-  TracePool* pool = pools_.Find(id);
-  if (!pool) {
-    return base::StatusOr<protos::TracePoolSetTracesResponse>(
-        base::ErrStatus("Unable to find pool %s", id.c_str()));
-  }
-  if (!pool->traces.empty()) {
-    return base::StatusOr<protos::TracePoolSetTracesResponse>(base::ErrStatus(
-        "Incrementally adding/removing items to pool not currently supported"));
-  }
-  pool->traces.assign(args.traces().begin(), args.traces().end());
-
-  uint32_t round_robin_worker_idx = 0;
-  for (const std::string& trace_path : pool->traces) {
-    auto it_and_inserted = traces_.Insert(trace_path, Trace());
-    it_and_inserted.first->refcount++;
-    if (it_and_inserted.second) {
-      it_and_inserted.first->worker = workers_[round_robin_worker_idx].get();
-      // Set the worker index to the next worker in a round-robin fashion.
-      round_robin_worker_idx = (round_robin_worker_idx + 1) % workers_.size();
-    } else {
-      PERFETTO_CHECK(it_and_inserted.first);
-    }
-  }
-  return protos::TracePoolSetTracesResponse();
-}
-
-base::StatusOrStream<protos::TracePoolQueryResponse>
-OrchestratorImpl::TracePoolQuery(const protos::TracePoolQueryArgs& args) {
-  TracePool* pool = pools_.Find(args.pool_id());
-  if (!pool) {
-    return base::StreamOf(base::StatusOr<protos::TracePoolQueryResponse>(
-        base::ErrStatus("Unable to find pool %s", args.pool_id().c_str())));
-  }
-
-  std::vector<base::StatusOrStream<protos::QueryTraceResponse>> streams;
-  protos::QueryTraceArgs query_args;
-  *query_args.mutable_sql_query() = args.sql_query();
-  for (const std::string& trace_path : pool->traces) {
-    auto* trace = traces_.Find(trace_path);
-    *query_args.mutable_trace() = trace_path;
-    streams.emplace_back(trace->worker->QueryTrace(query_args));
-  }
-  return base::FlattenStreams(std::move(streams))
-      .MapFuture(&RpcResponseToPoolResponse);
-}
-
-base::StatusOrFuture<protos::TracePoolDestroyResponse>
-OrchestratorImpl::TracePoolDestroy(const protos::TracePoolDestroyArgs& args) {
-  std::string id = args.pool_id();
-  TracePool* pool = pools_.Find(id);
-  if (!pool) {
-    return base::StatusOr<protos::TracePoolDestroyResponse>(
-        base::ErrStatus("Unable to find pool %s", id.c_str()));
-  }
-  std::unordered_set<std::string> to_erase;
-  for (auto it = traces_.GetIterator(); it; ++it) {
-    PERFETTO_CHECK(it.value().refcount-- > 0);
-    if (it.value().refcount == 0) {
-      to_erase.emplace(it.key());
-    }
-  }
-  for (const std::string& trace_path : to_erase) {
-    traces_.Erase(trace_path);
-  }
-  PERFETTO_CHECK(pools_.Erase(id));
-  return protos::TracePoolDestroyResponse();
-}
-
-void OrchestratorImpl::ExecuteSyncWorkers() {
-  if (periodic_sync_handle_) {
-    return;
-  }
-  periodic_sync_handle_ = base::SpawnFuture(task_runner_, [this]() {
-    return SyncWorkers().ContinueWith([this](base::Status status) {
-      if (!status.ok()) {
-        PERFETTO_ELOG("%s", status.c_message());
-      }
-      periodic_sync_handle_ = std::nullopt;
-      return base::Future<base::FVoid>(base::FVoid());
-    });
-  });
-}
-
-void OrchestratorImpl::ExecuteForceSyncWorkers() {
-  // Destroy the sync handle to cancel any currently running sync.
-  periodic_sync_handle_ = std::nullopt;
-  ExecuteSyncWorkers();
-}
-
-base::StatusFuture OrchestratorImpl::SyncWorkers() {
-  std::vector<base::StatusOrStream<protos::SyncTraceStateResponse>> streams;
-  base::FlatHashMap<Worker*, std::vector<std::string>> worker_to_traces;
-  for (auto it = traces_.GetIterator(); it; ++it) {
-    auto it_and_inserted = worker_to_traces.Insert(it.value().worker, {});
-    it_and_inserted.first->emplace_back(it.key());
-  }
-  for (auto& worker : workers_) {
-    auto* traces = worker_to_traces.Find(worker.get());
-    if (!traces) {
-      continue;
-    }
-    protos::SyncTraceStateArgs args;
-    for (const auto& trace : *traces) {
-      args.add_traces(trace);
-    }
-    streams.push_back(worker->SyncTraceState(std::move(args)));
-  }
-  return base::FlattenStreams(std::move(streams))
-      .MapFuture([](base::StatusOr<protos::SyncTraceStateResponse> resp) {
-        return base::StatusFuture(resp.status());
-      })
-      .Collect(base::AllOkCollector());
-}
-
-}  // namespace bigtrace
-}  // namespace perfetto
diff --git a/src/bigtrace/orchestrator_impl.h b/src/bigtrace/orchestrator_impl.h
deleted file mode 100644
index 44bb52d..0000000
--- a/src/bigtrace/orchestrator_impl.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SRC_BIGTRACE_ORCHESTRATOR_IMPL_H_
-#define SRC_BIGTRACE_ORCHESTRATOR_IMPL_H_
-
-#include <memory>
-#include <optional>
-#include <vector>
-
-#include "perfetto/base/task_runner.h"
-#include "perfetto/ext/base/flat_hash_map.h"
-#include "perfetto/ext/base/periodic_task.h"
-#include "perfetto/ext/base/threading/future.h"
-#include "perfetto/ext/base/threading/spawn.h"
-#include "perfetto/ext/bigtrace/orchestrator.h"
-
-namespace perfetto {
-namespace protos {
-class TracePoolShardCreateArgs;
-}
-
-namespace bigtrace {
-
-class OrchestratorImpl : public Orchestrator {
- public:
-  explicit OrchestratorImpl(base::TaskRunner*,
-                            std::vector<std::unique_ptr<Worker>>);
-
-  base::StatusOrStream<protos::TracePoolQueryResponse> TracePoolQuery(
-      const protos::TracePoolQueryArgs&) override;
-
-  base::StatusOrFuture<protos::TracePoolCreateResponse> TracePoolCreate(
-      const protos::TracePoolCreateArgs&) override;
-
-  base::StatusOrFuture<protos::TracePoolSetTracesResponse> TracePoolSetTraces(
-      const protos::TracePoolSetTracesArgs&) override;
-
-  base::StatusOrFuture<protos::TracePoolDestroyResponse> TracePoolDestroy(
-      const protos::TracePoolDestroyArgs&) override;
-
- private:
-  struct TracePool {
-    std::vector<std::string> traces;
-  };
-  struct Trace {
-    Worker* worker = nullptr;
-    uint32_t refcount = 0;
-  };
-  void ExecuteSyncWorkers();
-  void ExecuteForceSyncWorkers();
-  base::StatusFuture SyncWorkers();
-
-  base::TaskRunner* task_runner_ = nullptr;
-  base::PeriodicTask periodic_sync_task_;
-  std::optional<base::SpawnHandle> periodic_sync_handle_;
-
-  std::vector<std::unique_ptr<Worker>> workers_;
-  base::FlatHashMap<std::string, TracePool> pools_;
-  base::FlatHashMap<std::string, Trace> traces_;
-};
-
-}  // namespace bigtrace
-}  // namespace perfetto
-
-#endif  // SRC_BIGTRACE_ORCHESTRATOR_IMPL_H_
diff --git a/src/bigtrace/trace_processor_wrapper.cc b/src/bigtrace/trace_processor_wrapper.cc
deleted file mode 100644
index f1e4e71..0000000
--- a/src/bigtrace/trace_processor_wrapper.cc
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "src/bigtrace/trace_processor_wrapper.h"
-
-#include <atomic>
-#include <memory>
-#include <mutex>
-#include <optional>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "perfetto/base/status.h"
-#include "perfetto/ext/base/file_utils.h"
-#include "perfetto/ext/base/status_or.h"
-#include "perfetto/ext/base/threading/future.h"
-#include "perfetto/ext/base/threading/poll.h"
-#include "perfetto/ext/base/threading/stream.h"
-#include "perfetto/ext/base/threading/thread_pool.h"
-#include "perfetto/ext/base/threading/util.h"
-#include "perfetto/protozero/proto_utils.h"
-#include "perfetto/protozero/scattered_heap_buffer.h"
-#include "perfetto/trace_processor/trace_blob.h"
-#include "perfetto/trace_processor/trace_blob_view.h"
-#include "perfetto/trace_processor/trace_processor.h"
-#include "protos/perfetto/bigtrace/worker.pb.h"
-#include "src/protozero/proto_ring_buffer.h"
-#include "src/trace_processor/util/status_macros.h"
-
-namespace perfetto {
-namespace bigtrace {
-namespace {
-
-using trace_processor::QueryResultSerializer;
-using trace_processor::TraceBlob;
-using trace_processor::TraceBlobView;
-using trace_processor::TraceProcessor;
-using Statefulness = TraceProcessorWrapper::Statefulness;
-
-struct QueryRunner {
-  QueryRunner(std::shared_ptr<TraceProcessor> _tp,
-              std::string _query,
-              std::string _trace_path,
-              Statefulness _statefulness)
-      : tp(std::move(_tp)),
-        query(std::move(_query)),
-        trace_path(std::move(_trace_path)),
-        statefulness(_statefulness) {}
-
-  std::optional<protos::QueryTraceResponse> operator()() {
-    if (!has_more) {
-      if (statefulness == Statefulness::kStateless) {
-        serializer.reset();
-        tp->RestoreInitialTables();
-      }
-      return std::nullopt;
-    }
-    // If the serializer does not exist yet, that means we have not yet run
-    // the query so make sure to do that first.
-    EnsureSerializerExists();
-    has_more = serializer->Serialize(&result);
-
-    protos::QueryTraceResponse resp;
-    *resp.mutable_trace() = trace_path;
-    resp.mutable_result()->ParseFromArray(result.data(),
-                                          static_cast<int>(result.size()));
-    result.clear();
-    return std::make_optional(std::move(resp));
-  }
-
-  void EnsureSerializerExists() {
-    if (serializer) {
-      return;
-    }
-    auto it = tp->ExecuteQuery(query);
-    serializer.reset(new QueryResultSerializer(std::move(it)));
-  }
-
-  std::shared_ptr<TraceProcessor> tp;
-  std::string query;
-  std::string trace_path;
-  TraceProcessorWrapper::Statefulness statefulness;
-
-  // shared_ptr to allow copying when this type is coerced to std::function.
-  std::shared_ptr<QueryResultSerializer> serializer;
-  std::vector<uint8_t> result;
-  bool has_more = true;
-};
-
-}  // namespace
-
-TraceProcessorWrapper::TraceProcessorWrapper(std::string trace_path,
-                                             base::ThreadPool* thread_pool,
-                                             Statefulness statefulness)
-    : trace_path_(std::move(trace_path)),
-      thread_pool_(thread_pool),
-      statefulness_(statefulness) {
-  trace_processor::Config config;
-  config.ingest_ftrace_in_raw_table = false;
-  trace_processor_ = TraceProcessor::CreateInstance(config);
-}
-
-base::StatusFuture TraceProcessorWrapper::LoadTrace(
-    base::StatusOrStream<std::vector<uint8_t>> file_stream) {
-  if (trace_processor_.use_count() != 1) {
-    return base::ErrStatus("Request is already in flight");
-  }
-  return std::move(file_stream)
-      .MapFuture(
-          [thread_pool = thread_pool_, tp = trace_processor_](
-              base::StatusOr<std::vector<uint8_t>> d) -> base::StatusFuture {
-            RETURN_IF_ERROR(d.status());
-            return base::RunOnceOnThreadPool<base::Status>(
-                thread_pool, [res = std::move(*d), tp = std::move(tp)] {
-                  return tp->Parse(TraceBlobView(
-                      TraceBlob::CopyFrom(res.data(), res.size())));
-                });
-          })
-      .Collect(base::AllOkCollector())
-      .ContinueWith([thread_pool = thread_pool_, tp = trace_processor_](
-                        base::Status status) -> base::StatusFuture {
-        RETURN_IF_ERROR(status);
-        return base::RunOnceOnThreadPool<base::Status>(
-            thread_pool, [tp = std::move(tp)] {
-              tp->NotifyEndOfFile();
-              return base::OkStatus();
-            });
-      });
-}
-
-base::StatusOrStream<protos::QueryTraceResponse> TraceProcessorWrapper::Query(
-    const std::string& query) {
-  using StatusOrResponse = base::StatusOr<protos::QueryTraceResponse>;
-  if (trace_processor_.use_count() != 1) {
-    return base::StreamOf<StatusOrResponse>(
-        base::ErrStatus("Request is already in flight"));
-  }
-  return base::RunOnThreadPool<StatusOrResponse>(
-      thread_pool_,
-      QueryRunner(trace_processor_, query, trace_path_, statefulness_),
-      [tp = trace_processor_] { tp->InterruptQuery(); });
-}
-
-}  // namespace bigtrace
-}  // namespace perfetto
diff --git a/src/bigtrace/trace_processor_wrapper.h b/src/bigtrace/trace_processor_wrapper.h
deleted file mode 100644
index 8010614..0000000
--- a/src/bigtrace/trace_processor_wrapper.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SRC_BIGTRACE_TRACE_PROCESSOR_WRAPPER_H_
-#define SRC_BIGTRACE_TRACE_PROCESSOR_WRAPPER_H_
-
-#include "perfetto/ext/base/threading/future.h"
-#include "perfetto/ext/base/threading/stream.h"
-#include "perfetto/ext/base/threading/thread_pool.h"
-#include "perfetto/ext/trace_processor/rpc/query_result_serializer.h"
-#include "perfetto/trace_processor/trace_processor.h"
-
-namespace perfetto {
-namespace protos {
-
-class QueryTraceResponse;
-
-}  // namespace protos
-}  // namespace perfetto
-
-namespace perfetto {
-namespace bigtrace {
-
-// Wrapper class around an instance of TraceProcessor to adapt it for the needs
-// of a BigTrace Worker.
-class TraceProcessorWrapper {
- public:
-  enum Statefulness {
-    // Indicates that the state of the trace processor instance should be purged
-    // after every query.
-    kStateless,
-
-    // Indicates that the state of the trace processor instance should be
-    // preserved across queries.
-    kStateful,
-  };
-
-  TraceProcessorWrapper(std::string trace_path,
-                        base::ThreadPool*,
-                        Statefulness);
-
-  // Loads the trace given a stream of chunks to parse.
-  base::StatusFuture LoadTrace(
-      base::StatusOrStream<std::vector<uint8_t>> file_stream);
-
-  // Executes the given query on the trace processor and returns the results
-  // as a stream.
-  base::StatusOrStream<protos::QueryTraceResponse> Query(
-      const std::string& sql);
-
- private:
-  using TraceProcessor = trace_processor::TraceProcessor;
-
-  TraceProcessorWrapper(const TraceProcessorWrapper&) = delete;
-  TraceProcessorWrapper& operator=(const TraceProcessorWrapper&) = delete;
-
-  TraceProcessorWrapper(TraceProcessorWrapper&&) = delete;
-  TraceProcessorWrapper& operator=(TraceProcessorWrapper&&) = delete;
-
-  const std::string trace_path_;
-  base::ThreadPool* thread_pool_ = nullptr;
-  const Statefulness statefulness_ = Statefulness::kStateless;
-  std::shared_ptr<TraceProcessor> trace_processor_;
-};
-
-}  // namespace bigtrace
-}  // namespace perfetto
-
-#endif  // SRC_BIGTRACE_TRACE_PROCESSOR_WRAPPER_H_
diff --git a/src/bigtrace/trace_processor_wrapper_unittest.cc b/src/bigtrace/trace_processor_wrapper_unittest.cc
deleted file mode 100644
index a495395..0000000
--- a/src/bigtrace/trace_processor_wrapper_unittest.cc
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "src/bigtrace/trace_processor_wrapper.h"
-#include <cstdint>
-#include <optional>
-#include <vector>
-
-#include "perfetto/base/flat_set.h"
-#include "perfetto/base/platform_handle.h"
-#include "perfetto/base/status.h"
-#include "perfetto/base/time.h"
-#include "perfetto/ext/base/status_or.h"
-#include "perfetto/ext/base/string_utils.h"
-#include "perfetto/ext/base/string_view.h"
-#include "perfetto/ext/base/threading/stream.h"
-#include "perfetto/ext/base/threading/thread_pool.h"
-#include "perfetto/ext/base/threading/util.h"
-#include "protos/perfetto/bigtrace/worker.pb.h"
-#include "test/gtest_and_gmock.h"
-
-namespace perfetto {
-namespace bigtrace {
-namespace {
-
-using SF = TraceProcessorWrapper::Statefulness;
-
-const char kSimpleSystrace[] = R"--(# tracer
-  surfaceflinger-598   (  598) [004] .... 10852.771242: tracing_mark_write: B|598|some event
-  surfaceflinger-598   (  598) [004] .... 10852.771245: tracing_mark_write: E|598
-)--";
-
-base::StatusOr<std::vector<uint8_t>> SimpleSystrace() {
-  return std::vector<uint8_t>(kSimpleSystrace,
-                              kSimpleSystrace + strlen(kSimpleSystrace));
-}
-
-std::vector<base::StatusOr<std::vector<uint8_t>>> SimpleSystraceChunked() {
-  std::string systrace(kSimpleSystrace);
-  std::vector<base::StatusOr<std::vector<uint8_t>>> chunks;
-  for (auto& chunk : base::SplitString(systrace, "\n")) {
-    auto with_newline = chunk + "\n";
-    chunks.push_back(std::vector<uint8_t>(
-        with_newline.data(), with_newline.data() + with_newline.size()));
-  }
-
-  return chunks;
-}
-
-template <typename T>
-std::optional<T> WaitForFutureReady(base::Future<T>& future,
-                                    std::optional<uint32_t> timeout_ms) {
-  base::FlatSet<base::PlatformHandle> ready;
-  base::FlatSet<base::PlatformHandle> interested;
-  base::PollContext ctx(&interested, &ready);
-  auto res = future.Poll(&ctx);
-  for (; res.IsPending(); res = future.Poll(&ctx)) {
-    PERFETTO_CHECK(interested.size() == 1);
-    if (!base::BlockUntilReadableFd(*interested.begin(), timeout_ms)) {
-      return std::nullopt;
-    }
-    interested = {};
-  }
-  return res.item();
-}
-
-template <typename T>
-T WaitForFutureReady(base::Future<T>& future) {
-  return *WaitForFutureReady(future, std::nullopt);
-}
-
-template <typename T>
-std::optional<T> WaitForStreamReady(base::Stream<T>& stream) {
-  base::FlatSet<base::PlatformHandle> ready;
-  base::FlatSet<base::PlatformHandle> interested;
-  base::PollContext ctx(&interested, &ready);
-  auto res = stream.PollNext(&ctx);
-  for (; res.IsPending(); res = stream.PollNext(&ctx)) {
-    PERFETTO_CHECK(interested.size() == 1);
-    base::BlockUntilReadableFd(*interested.begin());
-    interested = {};
-  }
-  return res.IsDone() ? std::nullopt : std::make_optional(res.item());
-}
-
-TEST(TraceProcessorWrapperUnittest, Stateful) {
-  base::ThreadPool pool(1);
-  TraceProcessorWrapper wrapper("foobar", &pool, SF::kStateful);
-  {
-    auto load = wrapper.LoadTrace(base::StreamOf(SimpleSystrace()));
-    base::Status status = WaitForFutureReady(load);
-    ASSERT_TRUE(status.ok()) << status.message();
-  }
-  {
-    auto stream = wrapper.Query("CREATE VIEW foo AS SELECT ts, dur FROM slice");
-    auto proto = WaitForStreamReady(stream);
-    ASSERT_TRUE(proto.has_value());
-    ASSERT_TRUE(proto->ok()) << proto->status().message();
-
-    ASSERT_FALSE(WaitForStreamReady(stream).has_value());
-  }
-  {
-    auto stream = wrapper.Query("SELECT ts, dur FROM foo");
-    auto proto = WaitForStreamReady(stream);
-
-    ASSERT_TRUE(proto.has_value());
-    ASSERT_TRUE(proto->ok()) << proto->status().message();
-
-    ASSERT_EQ(proto->value().trace(), "foobar");
-
-    auto& result = proto.value()->result();
-    ASSERT_EQ(result.batch_size(), 1);
-    ASSERT_EQ(result.batch(0).cells_size(), 2);
-
-    ASSERT_EQ(result.batch(0).cells(0),
-              protos::QueryResult::CellsBatch::CELL_VARINT);
-    ASSERT_EQ(result.batch(0).cells(1),
-              protos::QueryResult::CellsBatch::CELL_VARINT);
-    ASSERT_EQ(result.batch(0).varint_cells(0), 10852771242000);
-    ASSERT_EQ(result.batch(0).varint_cells(1), 3000);
-
-    ASSERT_FALSE(WaitForStreamReady(stream).has_value());
-  }
-}
-
-TEST(TraceProcessorWrapperUnittest, Stateless) {
-  base::ThreadPool pool(1);
-  TraceProcessorWrapper wrapper("foobar", &pool, SF::kStateless);
-  {
-    auto load = wrapper.LoadTrace(base::StreamOf(SimpleSystrace()));
-    base::Status status = WaitForFutureReady(load);
-    ASSERT_TRUE(status.ok()) << status.message();
-  }
-  {
-    auto stream = wrapper.Query("CREATE VIEW foo AS SELECT ts, dur FROM slice");
-    auto proto = WaitForStreamReady(stream);
-    ASSERT_TRUE(proto.has_value());
-    ASSERT_TRUE(proto->ok()) << proto->status().message();
-
-    ASSERT_FALSE(WaitForStreamReady(stream).has_value());
-  }
-
-  // Second CREATE VIEW should also succeed because the first one should have
-  // been wiped.
-  {
-    auto stream = wrapper.Query("CREATE VIEW foo AS SELECT ts, dur FROM slice");
-    auto proto = WaitForStreamReady(stream);
-    ASSERT_TRUE(proto.has_value());
-    ASSERT_TRUE(proto->ok()) << proto->status().message();
-
-    ASSERT_FALSE(WaitForStreamReady(stream).has_value());
-  }
-
-  // Selecting from it should return an error.
-  {
-    auto stream = wrapper.Query("SELECT ts, dur FROM foo");
-    auto proto = WaitForStreamReady(stream);
-    ASSERT_TRUE(proto.has_value());
-    ASSERT_TRUE(proto->ok()) << proto->status().message();
-    ASSERT_TRUE(proto->value().result().has_error());
-
-    ASSERT_FALSE(WaitForStreamReady(stream).has_value());
-  }
-}
-
-TEST(TraceProcessorWrapperUnittest, Chunked) {
-  base::ThreadPool pool(1);
-  TraceProcessorWrapper wrapper("foobar", &pool, SF::kStateless);
-  {
-    auto chunked = SimpleSystraceChunked();
-    ASSERT_EQ(chunked.size(), 3u);
-    auto load = wrapper.LoadTrace(base::StreamFrom(chunked));
-    base::Status status = WaitForFutureReady(load);
-    ASSERT_TRUE(status.ok()) << status.message();
-  }
-  {
-    auto stream = wrapper.Query("SELECT ts, dur FROM slice");
-    auto proto = WaitForStreamReady(stream);
-
-    ASSERT_TRUE(proto.has_value());
-    ASSERT_TRUE(proto->ok()) << proto->status().message();
-
-    ASSERT_EQ(proto->value().trace(), "foobar");
-
-    auto& result = proto.value()->result();
-    ASSERT_EQ(result.batch_size(), 1);
-    ASSERT_EQ(result.batch(0).cells_size(), 2);
-
-    ASSERT_EQ(result.batch(0).cells(0),
-              protos::QueryResult::CellsBatch::CELL_VARINT);
-    ASSERT_EQ(result.batch(0).cells(1),
-              protos::QueryResult::CellsBatch::CELL_VARINT);
-    ASSERT_EQ(result.batch(0).varint_cells(0), 10852771242000);
-    ASSERT_EQ(result.batch(0).varint_cells(1), 3000);
-
-    ASSERT_FALSE(WaitForStreamReady(stream).has_value());
-  }
-}
-
-TEST(TraceProcessorWrapperUnittest, Interrupt) {
-  base::ThreadPool pool(1);
-  TraceProcessorWrapper wrapper("foobar", &pool, SF::kStateful);
-
-  // Create a query which will run ~forever. When this stream is dropped we
-  // should propogate to the TP instance to also stop running the query.
-  {
-    auto stream = wrapper.Query(
-        "WITH RECURSIVE nums AS ( "
-        "SELECT 1 num "
-        "UNION "
-        "SELECT num + 1 from nums WHERE num < 100000000000000) "
-        "SELECT COUNT(num) FROM nums");
-
-    // Wait for a bit for the thread to start running. To do something better
-    // we would need a way to figure out that the thread has started executing
-    // so we could stop. Unfortunately, this is quite a difficult problem to
-    // solve and probably not worth doing.
-    base::SleepMicroseconds(10 * 1000);
-  }
-
-  // Verify that we are able to run something on the thread pool in a reasonable
-  // amount of time.
-  {
-    auto future = base::RunOnceOnThreadPool<int>(&pool, []() { return 1; });
-    ASSERT_EQ(WaitForFutureReady(future, 250), 1);
-  }
-}
-
-}  // namespace
-}  // namespace bigtrace
-}  // namespace perfetto
diff --git a/src/bigtrace/worker_impl.cc b/src/bigtrace/worker_impl.cc
deleted file mode 100644
index 300d11c..0000000
--- a/src/bigtrace/worker_impl.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "src/bigtrace/worker_impl.h"
-
-#include <memory>
-
-#include "perfetto/base/logging.h"
-#include "perfetto/base/status.h"
-#include "perfetto/base/task_runner.h"
-#include "perfetto/ext/base/status_or.h"
-#include "perfetto/ext/base/threading/future.h"
-#include "perfetto/ext/base/threading/spawn.h"
-#include "perfetto/ext/base/threading/stream.h"
-#include "perfetto/ext/base/threading/util.h"
-#include "perfetto/ext/base/uuid.h"
-#include "perfetto/ext/bigtrace/worker.h"
-#include "protos/perfetto/bigtrace/orchestrator.pb.h"
-#include "protos/perfetto/bigtrace/worker.pb.h"
-#include "src/bigtrace/trace_processor_wrapper.h"
-#include "src/trace_processor/util/status_macros.h"
-
-namespace perfetto {
-namespace bigtrace {
-
-Worker::~Worker() = default;
-
-std::unique_ptr<Worker> Worker::CreateInProcesss(base::TaskRunner* runner,
-                                                 Environment* environment,
-                                                 base::ThreadPool* pool) {
-  return std::make_unique<WorkerImpl>(runner, environment, pool);
-}
-
-WorkerImpl::WorkerImpl(base::TaskRunner* runner,
-                       Environment* environment,
-                       base::ThreadPool* pool)
-    : task_runner_(runner), environment_(environment), thread_pool_(pool) {}
-
-base::StatusOrStream<protos::SyncTraceStateResponse> WorkerImpl::SyncTraceState(
-    const protos::SyncTraceStateArgs& args) {
-  base::FlatHashMap<std::string, Trace> new_traces;
-  std::vector<base::StatusStream> streams;
-  for (const std::string& trace : args.traces()) {
-    if (auto* ptr = traces_.Find(trace); ptr) {
-      auto it_and_inserted = new_traces.Insert(trace, std::move(*ptr));
-      PERFETTO_CHECK(it_and_inserted.second);
-      continue;
-    }
-    auto [handle, stream] =
-        base::SpawnResultFuture<base::Status>(task_runner_, [this, trace] {
-          auto t = traces_.Find(trace);
-          if (!t) {
-            return base::StatusFuture(
-                base::ErrStatus("%s: trace not found", trace.c_str()));
-          }
-          return t->wrapper->LoadTrace(environment_->ReadFile(trace));
-        });
-    auto tp = std::make_unique<TraceProcessorWrapper>(
-        trace, thread_pool_, TraceProcessorWrapper::Statefulness::kStateless);
-    streams.emplace_back(base::StreamFromFuture(std::move(stream)));
-    new_traces.Insert(trace, Trace{std::move(tp), std::move(handle)});
-  }
-  traces_ = std::move(new_traces);
-  return base::FlattenStreams(std::move(streams))
-      .MapFuture([](base::Status status) {
-        if (!status.ok()) {
-          return base::StatusOrFuture<protos::SyncTraceStateResponse>(status);
-        }
-        return base::StatusOrFuture<protos::SyncTraceStateResponse>(
-            protos::SyncTraceStateResponse());
-      });
-}
-
-base::StatusOrStream<protos::QueryTraceResponse> WorkerImpl::QueryTrace(
-    const protos::QueryTraceArgs& args) {
-  auto* tp = traces_.Find(args.trace());
-  if (!tp) {
-    return base::StreamOf<base::StatusOr<protos::QueryTraceResponse>>(
-        base::ErrStatus("%s: trace not found", args.trace().c_str()));
-  }
-  return tp->wrapper->Query(args.sql_query());
-}
-
-}  // namespace bigtrace
-}  // namespace perfetto
diff --git a/src/bigtrace/worker_impl.h b/src/bigtrace/worker_impl.h
deleted file mode 100644
index 720d022..0000000
--- a/src/bigtrace/worker_impl.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SRC_BIGTRACE_WORKER_IMPL_H_
-#define SRC_BIGTRACE_WORKER_IMPL_H_
-
-#include <memory>
-#include <optional>
-#include <variant>
-#include <vector>
-
-#include "perfetto/base/task_runner.h"
-#include "perfetto/ext/base/flat_hash_map.h"
-#include "perfetto/ext/base/threading/spawn.h"
-#include "perfetto/ext/base/threading/thread_pool.h"
-#include "perfetto/ext/bigtrace/environment.h"
-#include "perfetto/ext/bigtrace/worker.h"
-#include "src/bigtrace/trace_processor_wrapper.h"
-
-namespace perfetto {
-namespace protos {
-
-enum GroupType : int;
-
-}  // namespace protos
-}  // namespace perfetto
-
-namespace perfetto {
-namespace bigtrace {
-
-class WorkerImpl : public Worker {
- public:
-  explicit WorkerImpl(base::TaskRunner*, Environment*, base::ThreadPool*);
-
-  // Synchronize the state of the traces in the worker to the orchestrator.
-  base::StatusOrStream<protos::SyncTraceStateResponse> SyncTraceState(
-      const protos::SyncTraceStateArgs&) override;
-
-  // Executes a SQL query on the specified trace.
-  base::StatusOrStream<protos::QueryTraceResponse> QueryTrace(
-      const protos::QueryTraceArgs&) override;
-
- private:
-  struct Trace {
-    std::unique_ptr<TraceProcessorWrapper> wrapper;
-    base::SpawnHandle load_handle;
-  };
-  base::TaskRunner* const task_runner_;
-  Environment* const environment_;
-  base::ThreadPool* const thread_pool_;
-  base::FlatHashMap<std::string, Trace> traces_;
-};
-
-}  // namespace bigtrace
-}  // namespace perfetto
-
-#endif  // SRC_BIGTRACE_WORKER_IMPL_H_