Fix cobalt build for fuchsia

Remove dependency on GRPC++ from cobalt/util:status

Change-Id: Iab89c30f04b5ecb91ed6a5d8897cf63021a4d9c5
diff --git a/BUILD.gn b/BUILD.gn
index 212c6e9..d094d0d 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -16,7 +16,6 @@
     "clearcut_extensions.proto",
     "encrypted_message.proto",
     "observation.proto",
-    "window_size.proto",
   ]
   import_dirs = [ "//third_party/protobuf/src" ]
   generate_python = false
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 00faacd..5f9857a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -578,7 +578,7 @@
             -I ${CMAKE_SOURCE_DIR}
             -I ${PROTOBUF_INCLUDE_DIR}
             -I ${CMAKE_SOURCE_DIR}/third_party/go/src
-            --go_out=plugins=${_plugin_prefix}Mobservation.proto=cobalt,Mencrypted_message.proto=cobalt,Mwindow_size.proto=cobalt:${_gen_root_dir}
+            --go_out=plugins=${_plugin_prefix}Mobservation.proto=cobalt,Mencrypted_message.proto=cobalt:${_gen_root_dir}
     DEPENDS ${_protofiles}
     DEPENDS build_external_projects
   )
@@ -646,16 +646,14 @@
                              encrypted_message
                              event
                              observation
-                             observation2
-                             window_size)
+                             observation2)
 
 # Generate the go bindings for the Cobalt proto files in the root directory.
 cobalt_protobuf_generate_go(generate_cobalt_pb_go_files
                             COBALT_PB_GO_FILES
                             false
                             encrypted_message
-                            observation
-                            window_size)
+                            observation)
 
 # Analagous targets to the two above also appear in the config directory for
 # the config protos. But the variables that are generated there are not
diff --git a/config/BUILD.gn b/config/BUILD.gn
index 4afdd11..b40f2ea 100644
--- a/config/BUILD.gn
+++ b/config/BUILD.gn
@@ -13,6 +13,7 @@
     "metric_definition.proto",
     "report_configs.proto",
     "report_definition.proto",
+    "window_size.proto",
   ]
   import_dirs = [ "//third_party/protobuf/src" ]
   generate_python = false
diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt
index 6d8e6ea..4592d11 100644
--- a/config/CMakeLists.txt
+++ b/config/CMakeLists.txt
@@ -25,14 +25,14 @@
                              false
                              encodings metrics metric_definition
                              report_configs report_definition
-                             cobalt_config)
+                             cobalt_config window_size)
 
 # Generate Go bindings for the config .proto files.
 cobalt_protobuf_generate_go(generate_config_pb_go_files
                             CONFIG_PB_GO_FILES
                             false
                             cobalt_config encodings metrics metric_definition
-                            report_configs report_definition)
+                            report_configs report_definition window_size)
 
 add_library(buckets_config
             buckets_config.cc
diff --git a/config/report_definition.proto b/config/report_definition.proto
index 0992c05..a9dc901 100644
--- a/config/report_definition.proto
+++ b/config/report_definition.proto
@@ -5,9 +5,9 @@
 
 package cobalt;
 
-import "window_size.proto";
 import "config/metrics.proto";
 import "config/report_configs.proto";
+import "config/window_size.proto";
 
 option go_package = "config";
 
@@ -35,7 +35,7 @@
 // A ReportDefinition defines a Cobalt Report to be generated.
 // An instance of ReportDefinition is always associated with an instance of
 // MetricDefinition called the owning MetricDefinition.
-message ReportDefinition{
+message ReportDefinition {
   // Next id: 14
 
   // Unique name for this Report within its owning MetricDefinition.
@@ -349,8 +349,9 @@
     //   - system_profile # One or more fields from the SystemProfile message
     //                      type (cobalt/observation.proto) describing the
     //                      system on which the events occurred.
-    //   - window_size # A WindowSize enum (cobalt/window_size.proto) specifying
-    //                   the time window over which to report activity.
+    //   - window_size # A WindowSize enum (cobalt/config/window_size.proto)
+    //                   specifying the time window over which to report
+    //                   activity.
     //   - samples # The number of Observations received for the window of
     //               this window_size ending on this date, for this
     //               system_profile. This is equal to the number of Fuchsia
diff --git a/window_size.proto b/config/window_size.proto
similarity index 93%
rename from window_size.proto
rename to config/window_size.proto
index 9935914..dacc211 100644
--- a/window_size.proto
+++ b/config/window_size.proto
@@ -5,6 +5,8 @@
 
 package cobalt;
 
+option go_package = "config";
+
 // A time window over which to aggregate Events on-device.
 enum WindowSize {
   UNSET = 0;
diff --git a/encoder/shipping_manager.cc b/encoder/shipping_manager.cc
index f88ced7..081b1ce 100644
--- a/encoder/shipping_manager.cc
+++ b/encoder/shipping_manager.cc
@@ -25,6 +25,12 @@
   std::time_t time_struct = std::chrono::system_clock::to_time_t(t);
   return std::ctime(&time_struct);
 }
+
+grpc::Status CobaltStatusToGrpcStatus(util::Status status) {
+  return grpc::Status(static_cast<grpc::StatusCode>(status.error_code()),
+                      status.error_message(), status.error_details());
+}
+
 }  // namespace
 
 // Definition of the static constant declared in shipping_manager.h.
@@ -356,7 +362,7 @@
     if (!status.ok()) {
       locked->fields->num_failed_attempts++;
     }
-    locked->fields->last_send_status = status.ToGrpcStatus();
+    locked->fields->last_send_status = CobaltStatusToGrpcStatus(status);
   }
   if (status.ok()) {
     VLOG(4) << "ShippingManager::SendEnvelopeToBackend: OK";
diff --git a/observation2.proto b/observation2.proto
index b11c6e1..2b8d481 100644
--- a/observation2.proto
+++ b/observation2.proto
@@ -7,7 +7,6 @@
 package cobalt;
 
 import "observation.proto";
-import "window_size.proto";
 
 // An Observation is a piece of data sent from a Cobalt client to the Cobalt
 // server as input to a Report.
@@ -87,9 +86,9 @@
   // The index of the event type that occurred.
   uint32 event_type_index = 1;
 
-   // A hash of the component name. If component_name is empty then this field
-   // will be empty. Otherwise this field will contain the 32-byte SHA256
-   // hash of component_name.
+  // A hash of the component name. If component_name is empty then this field
+  // will be empty. Otherwise this field will contain the 32-byte SHA256
+  // hash of component_name.
   bytes component_name_hash = 2;
 
   int64 value = 3;
@@ -118,9 +117,9 @@
   // The index of the event that occurred.
   uint32 event_type_index = 1;
 
-   // A hash of the component name. If component_name is empty then this field
-   // will be empty. Otherwise this field will contain the 32-byte SHA256
-   // hash of component_name.
+  // A hash of the component name. If component_name is empty then this field
+  // will be empty. Otherwise this field will contain the 32-byte SHA256
+  // hash of component_name.
   bytes component_name_hash = 2;
 
   // The set of bucket indices and their corresponding counts.
@@ -133,18 +132,18 @@
 // of this type is created by aggregating Events on-device over
 // a rolling window of 1, 7, or 30 days.
 //
-// A UniqueActivesObservation has 2 fields: a WindowSize (defined in
-// cobalt/window_size.proto), which is the length in days of the rolling
-// window, and a BasicRapporObservation. In reference to the
-// |max_num_event_types| and |event_types| fields of a MetricDefinition of
-// type EVENT_OCCURRED, the BasicRapporObservation is the Basic RAPPOR-
-// encoding of a bit vector of length |max_num_event_types| with the
-// k-th bit set if the event represented by the k-th element of |event_types|
-// occurred at least once on the device during the window.
+// A UniqueActivesObservation has 2 fields: a uint32 value representing a
+// WindowSize (defined in cobalt/config/window_size.proto), which is the length
+// in days of the rolling window, and a BasicRapporObservation. In reference to
+// the |max_num_event_types| and |event_types| fields of a MetricDefinition of
+// type EVENT_OCCURRED, the BasicRapporObservation is the Basic RAPPOR- encoding
+// of a bit vector of length |max_num_event_types| with the k-th bit set if the
+// event represented by the k-th element of |event_types| occurred at least once
+// on the device during the window.
 message UniqueActivesObservation {
   // The size in days of the rolling window for which activity is being
   // observed.
-  WindowSize window_size = 1;
+  uint32 window_size = 1;
 
   // A BasicRapporObservation representing indicators of event occurrences
   // on the device over the rolling window.
diff --git a/third_party/clearcut/BUILD.gn b/third_party/clearcut/BUILD.gn
index 4956dfe..4f6bdba 100644
--- a/third_party/clearcut/BUILD.gn
+++ b/third_party/clearcut/BUILD.gn
@@ -25,5 +25,6 @@
   public_deps = [
     ":clearcut_proto",
     "//third_party/cobalt/third_party/tensorflow_statusor:statusor",
+    "//third_party/abseil-cpp",
   ]
 }
diff --git a/util/status.h b/util/status.h
index 282004b..c4a3993 100644
--- a/util/status.h
+++ b/util/status.h
@@ -7,7 +7,6 @@
 
 #include <string>
 
-#include "grpc++/grpc++.h"
 #include "util/status_codes.h"
 
 namespace cobalt {
@@ -41,11 +40,6 @@
   // the floor.
   void IgnoreError() {}
 
-  grpc::Status ToGrpcStatus() {
-    return grpc::Status(static_cast<grpc::StatusCode>(error_code()),
-                        error_message(), error_details());
-  }
-
  private:
   StatusCode code_;
   std::string error_message_;