Support disabling worker threads.

Change-Id: I17b047757738f4df54872a09a703e7fae62cce9b
Reviewed-on: https://fuchsia-review.googlesource.com/c/cobalt/+/463955
Reviewed-by: Zach Bush <zmbush@google.com>
Commit-Queue: Alexandre Zani <azani@google.com>
diff --git a/src/public/cobalt_config.h b/src/public/cobalt_config.h
index 9f4372b..2aec65c 100644
--- a/src/public/cobalt_config.h
+++ b/src/public/cobalt_config.h
@@ -261,6 +261,9 @@
 
   // |enable_replacement_metrics|: Determines wether or not replacement_metric_id should be honored
   bool enable_replacement_metrics = false;
+
+  // |start_worker_threads|: Determines whether or not to start the worker threads.
+  bool start_worker_threads = true;
 };
 
 }  // namespace cobalt
diff --git a/src/public/cobalt_service.cc b/src/public/cobalt_service.cc
index bffd2af..c4835d9 100644
--- a/src/public/cobalt_service.cc
+++ b/src/public/cobalt_service.cc
@@ -116,7 +116,8 @@
       internal_logger_(
           (global_project_context_factory_)
               ? NewLogger(cobalt::logger::kCustomerId, cobalt::logger::kProjectId, false)
-              : nullptr) {
+              : nullptr),
+      start_worker_threads_(cfg.start_worker_threads) {
   if (!internal_logger_) {
     LOG(ERROR) << "The global_registry provided does not include the expected internal metrics "
                   "project. Cobalt-measuring-cobalt will be disabled.";
@@ -128,7 +129,9 @@
     // And this sets it up for SystemData.
     system_data_.ResetInternalMetrics(internal_logger_.get());
   }
-  shipping_manager_->Start();
+  if (start_worker_threads_) {
+    shipping_manager_->Start();
+  }
 }
 
 std::unique_ptr<logger::LoggerInterface> CobaltService::NewLogger(
@@ -176,7 +179,7 @@
     undated_event_manager_.reset();
   }
 
-  if (start_event_aggregator_worker) {
+  if (start_event_aggregator_worker && start_worker_threads_) {
     local_aggregation_.Start(std::make_unique<util::SystemClockRef>(system_clock.get()));
     event_aggregator_manager_.Start(std::move(system_clock));
   }
diff --git a/src/public/cobalt_service.h b/src/public/cobalt_service.h
index 0542a35..84700e6 100644
--- a/src/public/cobalt_service.h
+++ b/src/public/cobalt_service.h
@@ -151,6 +151,7 @@
   std::shared_ptr<logger::UndatedEventManager> undated_event_manager_;
   util::ValidatedClockInterface *validated_clock_;
   std::unique_ptr<logger::LoggerInterface> internal_logger_;
+  bool start_worker_threads_;
 };
 
 }  // namespace cobalt