Some cleanups I discovered while trying to build Cobalt in google3.

Remove the use of a C++ exception.
Remove config_gen.cc that doesn't build and is no longer used.
Add a missing absl dependency.
Add a missing glog dependency.
Add a missing project_context dependency.
Add some missing proto imports.

Change-Id: I30153c70d2a2dea4f439c46e18b9d9f04e7aee2c
diff --git a/src/lib/clearcut/curl_handle.cc b/src/lib/clearcut/curl_handle.cc
index 1ff56b5..c3eee0a 100644
--- a/src/lib/clearcut/curl_handle.cc
+++ b/src/lib/clearcut/curl_handle.cc
@@ -11,12 +11,7 @@
 
 namespace cobalt::lib::clearcut {
 
-CurlHandle::CurlHandle() {
-  handle_ = curl_easy_init();
-  if (handle_ == nullptr) {
-    throw Status(util::StatusCode::INTERNAL, "curl_easy_init() returned nullptr");
-  }
-}
+CurlHandle::CurlHandle(CURL *handle) : handle_(handle) {}
 
 CurlHandle::~CurlHandle() {
   if (handle_ != nullptr) {
@@ -26,15 +21,15 @@
 }
 
 StatusOr<std::unique_ptr<CurlHandle>> CurlHandle::Init() {
-  try {
-    std::unique_ptr<CurlHandle> handle(new CurlHandle());
-    RETURN_IF_ERROR(handle->Setopt(CURLOPT_ERRORBUFFER, handle->errbuf_));
-    RETURN_IF_ERROR(handle->Setopt(CURLOPT_WRITEDATA, &handle->response_body_));
-    RETURN_IF_ERROR(handle->Setopt(CURLOPT_WRITEFUNCTION, CurlHandle::WriteResponseData));
-    return handle;
-  } catch (const Status &s) {
-    return s;
+  CURL *handle_ptr = curl_easy_init();
+  if (handle_ptr == nullptr) {
+    return Status(util::StatusCode::INTERNAL, "curl_easy_init() returned nullptr");
   }
+  std::unique_ptr<CurlHandle> handle(new CurlHandle(handle_ptr));
+  RETURN_IF_ERROR(handle->Setopt(CURLOPT_ERRORBUFFER, handle->errbuf_));
+  RETURN_IF_ERROR(handle->Setopt(CURLOPT_WRITEDATA, &handle->response_body_));
+  RETURN_IF_ERROR(handle->Setopt(CURLOPT_WRITEFUNCTION, CurlHandle::WriteResponseData));
+  return handle;
 }
 
 size_t CurlHandle::WriteResponseData(char *ptr, size_t size, size_t nmemb, void *userdata) {
diff --git a/src/lib/clearcut/curl_handle.h b/src/lib/clearcut/curl_handle.h
index 0ed5582..8fbde8c 100644
--- a/src/lib/clearcut/curl_handle.h
+++ b/src/lib/clearcut/curl_handle.h
@@ -36,7 +36,7 @@
   StatusOr<HTTPResponse> Post(const std::string &url, std::string body);
 
  private:
-  CurlHandle();
+  explicit CurlHandle(CURL *handle);
 
   static size_t WriteResponseData(char *ptr, size_t size, size_t nmemb, void *userdata);
   Status CURLCodeToStatus(CURLcode code);
diff --git a/src/logger/BUILD.gn b/src/logger/BUILD.gn
index 8e22c81..8cd5d30 100644
--- a/src/logger/BUILD.gn
+++ b/src/logger/BUILD.gn
@@ -31,6 +31,7 @@
   ]
 
   public_deps = [
+    ":project_context",
     "$cobalt_root/src/pb",
     "$cobalt_root/src/registry:cobalt_registry_proto",
   ]
@@ -93,11 +94,11 @@
   ]
   public_deps = [
     ":logger_interface",
+    ":project_context",
     ":status",
     "$cobalt_root/src:logging",
     "$cobalt_root/src/algorithms/rappor:rappor_config_helper",
     "$cobalt_root/src/lib/crypto_util",
-    "$cobalt_root/src/logger:project_context",
     "$cobalt_root/src/registry:buckets_config",
     "$cobalt_root/src/registry:cobalt_registry_proto",
     "$cobalt_root/src/registry:packed_event_codes",
diff --git a/src/logger/encoder.h b/src/logger/encoder.h
index 3a7bd1f..b571095 100644
--- a/src/logger/encoder.h
+++ b/src/logger/encoder.h
@@ -9,6 +9,8 @@
 #include <string>
 #include <vector>
 
+#include <google/protobuf/repeated_field.h>
+
 #include "src/algorithms/rappor/rappor_encoder.h"
 #include "src/lib/crypto_util/random.h"
 #include "src/logger/project_context.h"
diff --git a/src/logger/encoder_test.cc b/src/logger/encoder_test.cc
index c664ad2..e4d65c4 100644
--- a/src/logger/encoder_test.cc
+++ b/src/logger/encoder_test.cc
@@ -9,6 +9,8 @@
 #include <utility>
 #include <vector>
 
+#include <google/protobuf/repeated_field.h>
+
 #include "src/lib/crypto_util/base64.h"
 #include "src/local_aggregation/aggregation_utils.h"
 #include "src/logger/project_context.h"
diff --git a/src/logger/event_loggers.cc b/src/logger/event_loggers.cc
index 1bc528a..21e37b9 100644
--- a/src/logger/event_loggers.cc
+++ b/src/logger/event_loggers.cc
@@ -7,6 +7,8 @@
 #include <memory>
 #include <string>
 
+#include <google/protobuf/repeated_field.h>
+
 #include "src/algorithms/rappor/rappor_config_helper.h"
 #include "src/lib/util/datetime_util.h"
 #include "src/logger/event_record.h"
diff --git a/src/logger/event_record.h b/src/logger/event_record.h
index 82fd41c..3bdb339 100644
--- a/src/logger/event_record.h
+++ b/src/logger/event_record.h
@@ -9,6 +9,7 @@
 
 #include <third_party/abseil-cpp/absl/strings/str_cat.h>
 
+#include "src/logger/project_context.h"
 #include "src/pb/event.pb.h"
 #include "src/registry/metric_definition.pb.h"
 
diff --git a/src/logger/project_context.h b/src/logger/project_context.h
index 54ecea8..767916e 100644
--- a/src/logger/project_context.h
+++ b/src/logger/project_context.h
@@ -10,6 +10,8 @@
 #include <string>
 #include <utility>
 
+#include <google/protobuf/repeated_field.h>
+
 #include "src/lib/statusor/statusor.h"
 #include "src/logger/status.h"
 #include "src/registry/cobalt_registry.pb.h"
diff --git a/src/logger/types.h b/src/logger/types.h
index bfe0043..93995d2 100644
--- a/src/logger/types.h
+++ b/src/logger/types.h
@@ -8,6 +8,8 @@
 #include <memory>
 #include <string>
 
+#include <google/protobuf/repeated_field.h>
+
 #include "src/pb/event.pb.h"
 #include "src/pb/observation2.pb.h"
 #include "src/registry/metric_definition.pb.h"
diff --git a/src/registry/config_gen.cc b/src/registry/config_gen.cc
deleted file mode 100644
index 3a31a62..0000000
--- a/src/registry/config_gen.cc
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright 2016 The Fuchsia Authors
-//
-// 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.
-
-// The purpose of this utility is to generate the text representations of
-// the Cobalt configuration protocol buffer message. It is not part of
-// the production cobalt system and it is not part of any automated unit
-// test.  The intended use is to aid in the understanding of what the
-// text format of protocol buffer messages look like in order to facilitate
-// the manual editing of cobalt registration files. This
-// program writes its output to the console. An operator may edit this
-// file to add additional messages in order to see what their text format
-// looks like.
-
-#include <iostream>
-
-#include <google/protobuf/text_format.h>
-
-#include "src/registry/encoding_config.pb.h"
-
-using cobalt::EncodingConfig;
-using cobalt::ForculusConfig;
-using cobalt::MetricPart;
-using cobalt::RegisteredEncodings;
-using cobalt::RegisteredMetrics;
-using google::protobuf::TextFormat;
-
-int main(int argc, char* argv[]) {
-  std::string out;
-  RegisteredEncodings registered_encodings;
-  RegisteredMetrics registered_metrics;
-
-  std::cout << out;
-  std::cout << "------------------------------------\n";
-  std::cout << "Encodings:\n";
-  std::cout << "------------------------------------\n";
-
-  // (1, 1, 1) Forculus 20 with WEEK epoch
-  auto* encoding_config = registered_encodings.add_element();
-  encoding_config->set_customer_id(1);
-  encoding_config->set_project_id(1);
-  encoding_config->set_id(1);
-  auto* forculus_config = encoding_config->mutable_forculus();
-  forculus_config->set_threshold(20);
-  forculus_config->set_epoch_type(cobalt::WEEK);
-
-  // (1, 1, 2) RAPPOR
-  encoding_config = registered_encodings.add_element();
-  encoding_config->set_customer_id(1);
-  encoding_config->set_project_id(1);
-  encoding_config->set_id(2);
-  auto* rappor_config = encoding_config->mutable_rappor();
-  rappor_config->set_num_bloom_bits(64);
-  rappor_config->set_num_hashes(2);
-  rappor_config->set_num_cohorts(100);
-  rappor_config->set_prob_0_becomes_1(0.2);
-  rappor_config->set_prob_1_stays_1(0.8);
-
-  // (2, 1, 1) Basic RAPPOR
-  encoding_config = registered_encodings.add_element();
-  encoding_config->set_customer_id(2);
-  encoding_config->set_project_id(1);
-  encoding_config->set_id(1);
-  auto* basic_rappor_config = encoding_config->mutable_basic_rappor();
-  basic_rappor_config->set_prob_0_becomes_1(0.1);
-  basic_rappor_config->set_prob_1_stays_1(0.9);
-  basic_rappor_config->mutable_string_categories()->add_category("dog");
-  basic_rappor_config->mutable_string_categories()->add_category("cat");
-  basic_rappor_config->mutable_string_categories()->add_category("fish");
-
-  // (2, 1, 2) Forculus 50 with DAY epoch
-  encoding_config = registered_encodings.add_element();
-  encoding_config->set_customer_id(2);
-  encoding_config->set_project_id(1);
-  encoding_config->set_id(2);
-  forculus_config = encoding_config->mutable_forculus();
-  forculus_config->set_threshold(50);
-  forculus_config->set_epoch_type(cobalt::DAY);
-
-  TextFormat::PrintToString(registered_encodings, &out);
-  std::cout << out;
-  std::cout << "------------------------------------\n";
-  std::cout << "Metrics:\n";
-  std::cout << "------------------------------------\n";
-
-  auto* metric_config = registered_metrics.add_element();
-  // (1, 1, 1) Fuchsia Usage and Rating
-  metric_config->set_customer_id(1);
-  metric_config->set_project_id(1);
-  metric_config->set_id(1);
-  metric_config->set_name("Fuchsia Usage and Rating");
-  // City part
-  MetricPart city_part;
-  city_part.set_description("The name of a city");
-  city_part.set_data_type(MetricPart::STRING);
-  (*metric_config->mutable_parts())["city"] = city_part;
-  // Rating part
-  MetricPart rating_part;
-  rating_part.set_description("An integer from 0 to 10");
-  rating_part.set_data_type(MetricPart::INT);
-  (*metric_config->mutable_parts())["rating"] = rating_part;
-
-  TextFormat::PrintToString(registered_metrics, &out);
-  std::cout << out;
-
-  exit(0);
-}
diff --git a/src/registry/project_configs.h b/src/registry/project_configs.h
index 33fe7a7..400a1c4 100644
--- a/src/registry/project_configs.h
+++ b/src/registry/project_configs.h
@@ -12,6 +12,8 @@
 #include <utility>
 
 #include "src/registry/cobalt_registry.pb.h"
+#include "src/registry/metric_definition.pb.h"
+#include "src/registry/report_definition.pb.h"
 
 namespace cobalt {
 namespace config {
diff --git a/src/system_data/BUILD.gn b/src/system_data/BUILD.gn
index 6c8a43b..e314cc4 100644
--- a/src/system_data/BUILD.gn
+++ b/src/system_data/BUILD.gn
@@ -51,6 +51,7 @@
 
   deps = [
     "$cobalt_root/src/lib/crypto_util",
+    "//third_party/abseil-cpp",
   ]
 }
 
diff --git a/src/system_data/client_secret.cc b/src/system_data/client_secret.cc
index 308897f..2bdce55 100644
--- a/src/system_data/client_secret.cc
+++ b/src/system_data/client_secret.cc
@@ -18,6 +18,7 @@
 
 #include "src/lib/crypto_util/base64.h"
 #include "src/lib/crypto_util/random.h"
+#include "third_party/abseil-cpp/absl/strings/escaping.h"
 
 namespace cobalt::system_data {