AAPT2: Rename to match new style

Use Google3 naming style to match new
projects' and open source google projects' style.

Preferred to do this in a massive CL so as to avoid
style inconsistencies that plague legacy code bases.
This is a relatively NEW code base, may as well keep
it up to date.

Test: name/style refactor - existing tests pass
Change-Id: Ie80ecb78d46ec53efdfca2336bb57d96cbb7fb87
diff --git a/tools/aapt2/proto/ProtoHelpers.cpp b/tools/aapt2/proto/ProtoHelpers.cpp
index 2aa8aa5..38bf4e3 100644
--- a/tools/aapt2/proto/ProtoHelpers.cpp
+++ b/tools/aapt2/proto/ProtoHelpers.cpp
@@ -18,120 +18,151 @@
 
 namespace aapt {
 
-void serializeStringPoolToPb(const StringPool& pool, pb::StringPool* outPbPool) {
-    BigBuffer buffer(1024);
-    StringPool::flattenUtf8(&buffer, pool);
+void SerializeStringPoolToPb(const StringPool& pool,
+                             pb::StringPool* out_pb_pool) {
+  BigBuffer buffer(1024);
+  StringPool::FlattenUtf8(&buffer, pool);
 
-    std::string* data = outPbPool->mutable_data();
-    data->reserve(buffer.size());
+  std::string* data = out_pb_pool->mutable_data();
+  data->reserve(buffer.size());
 
-    size_t offset = 0;
-    for (const BigBuffer::Block& block : buffer) {
-        data->insert(data->begin() + offset, block.buffer.get(), block.buffer.get() + block.size);
-        offset += block.size;
-    }
+  size_t offset = 0;
+  for (const BigBuffer::Block& block : buffer) {
+    data->insert(data->begin() + offset, block.buffer.get(),
+                 block.buffer.get() + block.size);
+    offset += block.size;
+  }
 }
 
-void serializeSourceToPb(const Source& source, StringPool* srcPool, pb::Source* outPbSource) {
-    StringPool::Ref ref = srcPool->makeRef(source.path);
-    outPbSource->set_path_idx(static_cast<uint32_t>(ref.getIndex()));
-    if (source.line) {
-        outPbSource->set_line_no(static_cast<uint32_t>(source.line.value()));
-    }
+void SerializeSourceToPb(const Source& source, StringPool* src_pool,
+                         pb::Source* out_pb_source) {
+  StringPool::Ref ref = src_pool->MakeRef(source.path);
+  out_pb_source->set_path_idx(static_cast<uint32_t>(ref.index()));
+  if (source.line) {
+    out_pb_source->set_line_no(static_cast<uint32_t>(source.line.value()));
+  }
 }
 
-void deserializeSourceFromPb(const pb::Source& pbSource, const android::ResStringPool& srcPool,
-                             Source* outSource) {
-    if (pbSource.has_path_idx()) {
-        outSource->path = util::getString(srcPool, pbSource.path_idx());
-    }
+void DeserializeSourceFromPb(const pb::Source& pb_source,
+                             const android::ResStringPool& src_pool,
+                             Source* out_source) {
+  if (pb_source.has_path_idx()) {
+    out_source->path = util::GetString(src_pool, pb_source.path_idx());
+  }
 
-    if (pbSource.has_line_no()) {
-        outSource->line = static_cast<size_t>(pbSource.line_no());
-    }
+  if (pb_source.has_line_no()) {
+    out_source->line = static_cast<size_t>(pb_source.line_no());
+  }
 }
 
-pb::SymbolStatus_Visibility serializeVisibilityToPb(SymbolState state) {
-    switch (state) {
-    case SymbolState::kPrivate: return pb::SymbolStatus_Visibility_Private;
-    case SymbolState::kPublic: return pb::SymbolStatus_Visibility_Public;
-    default: break;
-    }
-    return pb::SymbolStatus_Visibility_Unknown;
+pb::SymbolStatus_Visibility SerializeVisibilityToPb(SymbolState state) {
+  switch (state) {
+    case SymbolState::kPrivate:
+      return pb::SymbolStatus_Visibility_Private;
+    case SymbolState::kPublic:
+      return pb::SymbolStatus_Visibility_Public;
+    default:
+      break;
+  }
+  return pb::SymbolStatus_Visibility_Unknown;
 }
 
-SymbolState deserializeVisibilityFromPb(pb::SymbolStatus_Visibility pbVisibility) {
-    switch (pbVisibility) {
-    case pb::SymbolStatus_Visibility_Private: return SymbolState::kPrivate;
-    case pb::SymbolStatus_Visibility_Public: return SymbolState::kPublic;
-    default: break;
-    }
-    return SymbolState::kUndefined;
+SymbolState DeserializeVisibilityFromPb(
+    pb::SymbolStatus_Visibility pb_visibility) {
+  switch (pb_visibility) {
+    case pb::SymbolStatus_Visibility_Private:
+      return SymbolState::kPrivate;
+    case pb::SymbolStatus_Visibility_Public:
+      return SymbolState::kPublic;
+    default:
+      break;
+  }
+  return SymbolState::kUndefined;
 }
 
-void serializeConfig(const ConfigDescription& config, pb::ConfigDescription* outPbConfig) {
-    android::ResTable_config flatConfig = config;
-    flatConfig.size = sizeof(flatConfig);
-    flatConfig.swapHtoD();
-    outPbConfig->set_data(&flatConfig, sizeof(flatConfig));
+void SerializeConfig(const ConfigDescription& config,
+                     pb::ConfigDescription* out_pb_config) {
+  android::ResTable_config flat_config = config;
+  flat_config.size = sizeof(flat_config);
+  flat_config.swapHtoD();
+  out_pb_config->set_data(&flat_config, sizeof(flat_config));
 }
 
-bool deserializeConfigDescriptionFromPb(const pb::ConfigDescription& pbConfig,
-                                        ConfigDescription* outConfig) {
-    if (!pbConfig.has_data()) {
-        return false;
-    }
+bool DeserializeConfigDescriptionFromPb(const pb::ConfigDescription& pb_config,
+                                        ConfigDescription* out_config) {
+  if (!pb_config.has_data()) {
+    return false;
+  }
 
-    const android::ResTable_config* config;
-    if (pbConfig.data().size() > sizeof(*config)) {
-        return false;
-    }
+  const android::ResTable_config* config;
+  if (pb_config.data().size() > sizeof(*config)) {
+    return false;
+  }
 
-    config = reinterpret_cast<const android::ResTable_config*>(pbConfig.data().data());
-    outConfig->copyFromDtoH(*config);
-    return true;
+  config = reinterpret_cast<const android::ResTable_config*>(
+      pb_config.data().data());
+  out_config->copyFromDtoH(*config);
+  return true;
 }
 
-pb::Reference_Type serializeReferenceTypeToPb(Reference::Type type) {
-    switch (type) {
-    case Reference::Type::kResource:  return pb::Reference_Type_Ref;
-    case Reference::Type::kAttribute: return pb::Reference_Type_Attr;
-    default: break;
-    }
-    return pb::Reference_Type_Ref;
+pb::Reference_Type SerializeReferenceTypeToPb(Reference::Type type) {
+  switch (type) {
+    case Reference::Type::kResource:
+      return pb::Reference_Type_Ref;
+    case Reference::Type::kAttribute:
+      return pb::Reference_Type_Attr;
+    default:
+      break;
+  }
+  return pb::Reference_Type_Ref;
 }
 
-Reference::Type deserializeReferenceTypeFromPb(pb::Reference_Type pbType) {
-    switch (pbType) {
-    case pb::Reference_Type_Ref:  return Reference::Type::kResource;
-    case pb::Reference_Type_Attr: return Reference::Type::kAttribute;
-    default: break;
-    }
-    return Reference::Type::kResource;
+Reference::Type DeserializeReferenceTypeFromPb(pb::Reference_Type pb_type) {
+  switch (pb_type) {
+    case pb::Reference_Type_Ref:
+      return Reference::Type::kResource;
+    case pb::Reference_Type_Attr:
+      return Reference::Type::kAttribute;
+    default:
+      break;
+  }
+  return Reference::Type::kResource;
 }
 
-pb::Plural_Arity serializePluralEnumToPb(size_t pluralIdx) {
-    switch (pluralIdx) {
-    case Plural::Zero:  return pb::Plural_Arity_Zero;
-    case Plural::One:   return pb::Plural_Arity_One;
-    case Plural::Two:   return pb::Plural_Arity_Two;
-    case Plural::Few:   return pb::Plural_Arity_Few;
-    case Plural::Many:  return pb::Plural_Arity_Many;
-    default: break;
-    }
-    return pb::Plural_Arity_Other;
+pb::Plural_Arity SerializePluralEnumToPb(size_t plural_idx) {
+  switch (plural_idx) {
+    case Plural::Zero:
+      return pb::Plural_Arity_Zero;
+    case Plural::One:
+      return pb::Plural_Arity_One;
+    case Plural::Two:
+      return pb::Plural_Arity_Two;
+    case Plural::Few:
+      return pb::Plural_Arity_Few;
+    case Plural::Many:
+      return pb::Plural_Arity_Many;
+    default:
+      break;
+  }
+  return pb::Plural_Arity_Other;
 }
 
-size_t deserializePluralEnumFromPb(pb::Plural_Arity arity) {
-    switch (arity) {
-    case pb::Plural_Arity_Zero: return Plural::Zero;
-    case pb::Plural_Arity_One:  return Plural::One;
-    case pb::Plural_Arity_Two:  return Plural::Two;
-    case pb::Plural_Arity_Few:  return Plural::Few;
-    case pb::Plural_Arity_Many: return Plural::Many;
-    default: break;
-    }
-    return Plural::Other;
+size_t DeserializePluralEnumFromPb(pb::Plural_Arity arity) {
+  switch (arity) {
+    case pb::Plural_Arity_Zero:
+      return Plural::Zero;
+    case pb::Plural_Arity_One:
+      return Plural::One;
+    case pb::Plural_Arity_Two:
+      return Plural::Two;
+    case pb::Plural_Arity_Few:
+      return Plural::Few;
+    case pb::Plural_Arity_Many:
+      return Plural::Many;
+    default:
+      break;
+  }
+  return Plural::Other;
 }
 
-} // namespace aapt
+}  // namespace aapt
diff --git a/tools/aapt2/proto/ProtoHelpers.h b/tools/aapt2/proto/ProtoHelpers.h
index 7271e8b..735cda0 100644
--- a/tools/aapt2/proto/ProtoHelpers.h
+++ b/tools/aapt2/proto/ProtoHelpers.h
@@ -17,39 +17,44 @@
 #ifndef AAPT_PROTO_PROTOHELPERS_H
 #define AAPT_PROTO_PROTOHELPERS_H
 
+#include "androidfw/ResourceTypes.h"
+
 #include "ConfigDescription.h"
 #include "ResourceTable.h"
 #include "Source.h"
 #include "StringPool.h"
-
 #include "proto/frameworks/base/tools/aapt2/Format.pb.h"
 
-#include <androidfw/ResourceTypes.h>
-
 namespace aapt {
 
-void serializeStringPoolToPb(const StringPool& pool, pb::StringPool* outPbPool);
+void SerializeStringPoolToPb(const StringPool& pool,
+                             pb::StringPool* out_pb_pool);
 
-void serializeSourceToPb(const Source& source, StringPool* srcPool,
-                         pb::Source* outPbSource);
-void deserializeSourceFromPb(const pb::Source& pbSource,
-                             const android::ResStringPool& srcPool,
-                             Source* outSource);
+void SerializeSourceToPb(const Source& source, StringPool* src_pool,
+                         pb::Source* out_pb_source);
 
-pb::SymbolStatus_Visibility serializeVisibilityToPb(SymbolState state);
-SymbolState deserializeVisibilityFromPb(
-    pb::SymbolStatus_Visibility pbVisibility);
+void DeserializeSourceFromPb(const pb::Source& pb_source,
+                             const android::ResStringPool& src_pool,
+                             Source* out_source);
 
-void serializeConfig(const ConfigDescription& config,
-                     pb::ConfigDescription* outPbConfig);
-bool deserializeConfigDescriptionFromPb(const pb::ConfigDescription& pbConfig,
-                                        ConfigDescription* outConfig);
+pb::SymbolStatus_Visibility SerializeVisibilityToPb(SymbolState state);
 
-pb::Reference_Type serializeReferenceTypeToPb(Reference::Type type);
-Reference::Type deserializeReferenceTypeFromPb(pb::Reference_Type pbType);
+SymbolState DeserializeVisibilityFromPb(
+    pb::SymbolStatus_Visibility pb_visibility);
 
-pb::Plural_Arity serializePluralEnumToPb(size_t pluralIdx);
-size_t deserializePluralEnumFromPb(pb::Plural_Arity arity);
+void SerializeConfig(const ConfigDescription& config,
+                     pb::ConfigDescription* out_pb_config);
+
+bool DeserializeConfigDescriptionFromPb(const pb::ConfigDescription& pb_config,
+                                        ConfigDescription* out_config);
+
+pb::Reference_Type SerializeReferenceTypeToPb(Reference::Type type);
+
+Reference::Type DeserializeReferenceTypeFromPb(pb::Reference_Type pb_type);
+
+pb::Plural_Arity SerializePluralEnumToPb(size_t plural_idx);
+
+size_t DeserializePluralEnumFromPb(pb::Plural_Arity arity);
 
 }  // namespace aapt
 
diff --git a/tools/aapt2/proto/ProtoSerialize.h b/tools/aapt2/proto/ProtoSerialize.h
index 378dafd..39c5003 100644
--- a/tools/aapt2/proto/ProtoSerialize.h
+++ b/tools/aapt2/proto/ProtoSerialize.h
@@ -17,15 +17,15 @@
 #ifndef AAPT_FLATTEN_TABLEPROTOSERIALIZER_H
 #define AAPT_FLATTEN_TABLEPROTOSERIALIZER_H
 
+#include "android-base/macros.h"
+#include "google/protobuf/io/coded_stream.h"
+#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
+
 #include "Diagnostics.h"
 #include "ResourceTable.h"
 #include "Source.h"
 #include "proto/ProtoHelpers.h"
 
-#include <android-base/macros.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
-
 namespace aapt {
 
 class CompiledFileOutputStream {
@@ -42,9 +42,9 @@
  private:
   DISALLOW_COPY_AND_ASSIGN(CompiledFileOutputStream);
 
-  void ensureAlignedWrite();
+  void EnsureAlignedWrite();
 
-  google::protobuf::io::CodedOutputStream mOut;
+  google::protobuf::io::CodedOutputStream out_;
 };
 
 class CompiledFileInputStream {
@@ -58,18 +58,18 @@
  private:
   DISALLOW_COPY_AND_ASSIGN(CompiledFileInputStream);
 
-  void ensureAlignedRead();
+  void EnsureAlignedRead();
 
-  google::protobuf::io::CodedInputStream mIn;
+  google::protobuf::io::CodedInputStream in_;
 };
 
-std::unique_ptr<pb::ResourceTable> serializeTableToPb(ResourceTable* table);
-std::unique_ptr<ResourceTable> deserializeTableFromPb(
+std::unique_ptr<pb::ResourceTable> SerializeTableToPb(ResourceTable* table);
+std::unique_ptr<ResourceTable> DeserializeTableFromPb(
     const pb::ResourceTable& pbTable, const Source& source, IDiagnostics* diag);
 
-std::unique_ptr<pb::CompiledFile> serializeCompiledFileToPb(
+std::unique_ptr<pb::CompiledFile> SerializeCompiledFileToPb(
     const ResourceFile& file);
-std::unique_ptr<ResourceFile> deserializeCompiledFileFromPb(
+std::unique_ptr<ResourceFile> DeserializeCompiledFileFromPb(
     const pb::CompiledFile& pbFile, const Source& source, IDiagnostics* diag);
 
 }  // namespace aapt
diff --git a/tools/aapt2/proto/TableProtoDeserializer.cpp b/tools/aapt2/proto/TableProtoDeserializer.cpp
index 0dfb01c..d93d495 100644
--- a/tools/aapt2/proto/TableProtoDeserializer.cpp
+++ b/tools/aapt2/proto/TableProtoDeserializer.cpp
@@ -14,13 +14,15 @@
  * limitations under the License.
  */
 
+#include "proto/ProtoSerialize.h"
+
+#include "android-base/logging.h"
+#include "androidfw/ResourceTypes.h"
+
 #include "ResourceTable.h"
 #include "ResourceUtils.h"
 #include "ValueVisitor.h"
 #include "proto/ProtoHelpers.h"
-#include "proto/ProtoSerialize.h"
-
-#include <androidfw/ResourceTypes.h>
 
 namespace aapt {
 
@@ -28,28 +30,28 @@
 
 class ReferenceIdToNameVisitor : public ValueVisitor {
  public:
-  using ValueVisitor::visit;
+  using ValueVisitor::Visit;
 
   explicit ReferenceIdToNameVisitor(
       const std::map<ResourceId, ResourceNameRef>* mapping)
-      : mMapping(mapping) {
-    assert(mMapping);
+      : mapping_(mapping) {
+    CHECK(mapping_ != nullptr);
   }
 
-  void visit(Reference* reference) override {
-    if (!reference->id || !reference->id.value().isValid()) {
+  void Visit(Reference* reference) override {
+    if (!reference->id || !reference->id.value().is_valid()) {
       return;
     }
 
     ResourceId id = reference->id.value();
-    auto cacheIter = mMapping->find(id);
-    if (cacheIter != mMapping->end()) {
-      reference->name = cacheIter->second.toResourceName();
+    auto cache_iter = mapping_->find(id);
+    if (cache_iter != mapping_->end()) {
+      reference->name = cache_iter->second.ToResourceName();
     }
   }
 
  private:
-  const std::map<ResourceId, ResourceNameRef>* mMapping;
+  const std::map<ResourceId, ResourceNameRef>* mapping_;
 };
 
 class PackagePbDeserializer {
@@ -58,14 +60,14 @@
                         const android::ResStringPool* sourcePool,
                         const android::ResStringPool* symbolPool,
                         const Source& source, IDiagnostics* diag)
-      : mValuePool(valuePool),
-        mSourcePool(sourcePool),
-        mSymbolPool(symbolPool),
-        mSource(source),
-        mDiag(diag) {}
+      : value_pool_(valuePool),
+        source_pool_(sourcePool),
+        symbol_pool_(symbolPool),
+        source_(source),
+        diag_(diag) {}
 
  public:
-  bool deserializeFromPb(const pb::Package& pbPackage, ResourceTable* table) {
+  bool DeserializeFromPb(const pb::Package& pbPackage, ResourceTable* table) {
     Maybe<uint8_t> id;
     if (pbPackage.has_package_id()) {
       id = static_cast<uint8_t>(pbPackage.package_id());
@@ -74,36 +76,36 @@
     std::map<ResourceId, ResourceNameRef> idIndex;
 
     ResourceTablePackage* pkg =
-        table->createPackage(pbPackage.package_name(), id);
+        table->CreatePackage(pbPackage.package_name(), id);
     for (const pb::Type& pbType : pbPackage.types()) {
-      const ResourceType* resType = parseResourceType(pbType.name());
+      const ResourceType* resType = ParseResourceType(pbType.name());
       if (!resType) {
-        mDiag->error(DiagMessage(mSource) << "unknown type '" << pbType.name()
+        diag_->Error(DiagMessage(source_) << "unknown type '" << pbType.name()
                                           << "'");
         return {};
       }
 
-      ResourceTableType* type = pkg->findOrCreateType(*resType);
+      ResourceTableType* type = pkg->FindOrCreateType(*resType);
 
       for (const pb::Entry& pbEntry : pbType.entries()) {
-        ResourceEntry* entry = type->findOrCreateEntry(pbEntry.name());
+        ResourceEntry* entry = type->FindOrCreateEntry(pbEntry.name());
 
         // Deserialize the symbol status (public/private with source and
         // comments).
         if (pbEntry.has_symbol_status()) {
           const pb::SymbolStatus& pbStatus = pbEntry.symbol_status();
           if (pbStatus.has_source()) {
-            deserializeSourceFromPb(pbStatus.source(), *mSourcePool,
-                                    &entry->symbolStatus.source);
+            DeserializeSourceFromPb(pbStatus.source(), *source_pool_,
+                                    &entry->symbol_status.source);
           }
 
           if (pbStatus.has_comment()) {
-            entry->symbolStatus.comment = pbStatus.comment();
+            entry->symbol_status.comment = pbStatus.comment();
           }
 
           SymbolState visibility =
-              deserializeVisibilityFromPb(pbStatus.visibility());
-          entry->symbolStatus.state = visibility;
+              DeserializeVisibilityFromPb(pbStatus.visibility());
+          entry->symbol_status.state = visibility;
 
           if (visibility == SymbolState::kPublic) {
             // This is a public symbol, we must encode the ID now if there is
@@ -112,22 +114,22 @@
               entry->id = static_cast<uint16_t>(pbEntry.id());
             }
 
-            if (type->symbolStatus.state != SymbolState::kPublic) {
+            if (type->symbol_status.state != SymbolState::kPublic) {
               // If the type has not been made public, do so now.
-              type->symbolStatus.state = SymbolState::kPublic;
+              type->symbol_status.state = SymbolState::kPublic;
               if (pbType.has_id()) {
                 type->id = static_cast<uint8_t>(pbType.id());
               }
             }
           } else if (visibility == SymbolState::kPrivate) {
-            if (type->symbolStatus.state == SymbolState::kUndefined) {
-              type->symbolStatus.state = SymbolState::kPrivate;
+            if (type->symbol_status.state == SymbolState::kUndefined) {
+              type->symbol_status.state = SymbolState::kPrivate;
             }
           }
         }
 
         ResourceId resId(pbPackage.package_id(), pbType.id(), pbEntry.id());
-        if (resId.isValid()) {
+        if (resId.is_valid()) {
           idIndex[resId] = ResourceNameRef(pkg->name, type->type, entry->name);
         }
 
@@ -135,21 +137,21 @@
           const pb::ConfigDescription& pbConfig = pbConfigValue.config();
 
           ConfigDescription config;
-          if (!deserializeConfigDescriptionFromPb(pbConfig, &config)) {
-            mDiag->error(DiagMessage(mSource) << "invalid configuration");
+          if (!DeserializeConfigDescriptionFromPb(pbConfig, &config)) {
+            diag_->Error(DiagMessage(source_) << "invalid configuration");
             return {};
           }
 
           ResourceConfigValue* configValue =
-              entry->findOrCreateValue(config, pbConfig.product());
+              entry->FindOrCreateValue(config, pbConfig.product());
           if (configValue->value) {
             // Duplicate config.
-            mDiag->error(DiagMessage(mSource) << "duplicate configuration");
+            diag_->Error(DiagMessage(source_) << "duplicate configuration");
             return {};
           }
 
-          configValue->value = deserializeValueFromPb(
-              pbConfigValue.value(), config, &table->stringPool);
+          configValue->value = DeserializeValueFromPb(
+              pbConfigValue.value(), config, &table->string_pool);
           if (!configValue->value) {
             return {};
           }
@@ -158,247 +160,247 @@
     }
 
     ReferenceIdToNameVisitor visitor(&idIndex);
-    visitAllValuesInPackage(pkg, &visitor);
+    VisitAllValuesInPackage(pkg, &visitor);
     return true;
   }
 
  private:
-  std::unique_ptr<Item> deserializeItemFromPb(const pb::Item& pbItem,
+  std::unique_ptr<Item> DeserializeItemFromPb(const pb::Item& pb_item,
                                               const ConfigDescription& config,
                                               StringPool* pool) {
-    if (pbItem.has_ref()) {
-      const pb::Reference& pbRef = pbItem.ref();
+    if (pb_item.has_ref()) {
+      const pb::Reference& pb_ref = pb_item.ref();
       std::unique_ptr<Reference> ref = util::make_unique<Reference>();
-      if (!deserializeReferenceFromPb(pbRef, ref.get())) {
+      if (!DeserializeReferenceFromPb(pb_ref, ref.get())) {
         return {};
       }
       return std::move(ref);
 
-    } else if (pbItem.has_prim()) {
-      const pb::Primitive& pbPrim = pbItem.prim();
+    } else if (pb_item.has_prim()) {
+      const pb::Primitive& pb_prim = pb_item.prim();
       android::Res_value prim = {};
-      prim.dataType = static_cast<uint8_t>(pbPrim.type());
-      prim.data = pbPrim.data();
+      prim.dataType = static_cast<uint8_t>(pb_prim.type());
+      prim.data = pb_prim.data();
       return util::make_unique<BinaryPrimitive>(prim);
 
-    } else if (pbItem.has_id()) {
+    } else if (pb_item.has_id()) {
       return util::make_unique<Id>();
 
-    } else if (pbItem.has_str()) {
-      const uint32_t idx = pbItem.str().idx();
-      const std::string str = util::getString(*mValuePool, idx);
+    } else if (pb_item.has_str()) {
+      const uint32_t idx = pb_item.str().idx();
+      const std::string str = util::GetString(*value_pool_, idx);
 
-      const android::ResStringPool_span* spans = mValuePool->styleAt(idx);
+      const android::ResStringPool_span* spans = value_pool_->styleAt(idx);
       if (spans && spans->name.index != android::ResStringPool_span::END) {
-        StyleString styleStr = {str};
+        StyleString style_str = {str};
         while (spans->name.index != android::ResStringPool_span::END) {
-          styleStr.spans.push_back(
-              Span{util::getString(*mValuePool, spans->name.index),
+          style_str.spans.push_back(
+              Span{util::GetString(*value_pool_, spans->name.index),
                    spans->firstChar, spans->lastChar});
           spans++;
         }
-        return util::make_unique<StyledString>(pool->makeRef(
-            styleStr,
+        return util::make_unique<StyledString>(pool->MakeRef(
+            style_str,
             StringPool::Context(StringPool::Context::kStylePriority, config)));
       }
       return util::make_unique<String>(
-          pool->makeRef(str, StringPool::Context(config)));
+          pool->MakeRef(str, StringPool::Context(config)));
 
-    } else if (pbItem.has_raw_str()) {
-      const uint32_t idx = pbItem.raw_str().idx();
-      const std::string str = util::getString(*mValuePool, idx);
+    } else if (pb_item.has_raw_str()) {
+      const uint32_t idx = pb_item.raw_str().idx();
+      const std::string str = util::GetString(*value_pool_, idx);
       return util::make_unique<RawString>(
-          pool->makeRef(str, StringPool::Context(config)));
+          pool->MakeRef(str, StringPool::Context(config)));
 
-    } else if (pbItem.has_file()) {
-      const uint32_t idx = pbItem.file().path_idx();
-      const std::string str = util::getString(*mValuePool, idx);
-      return util::make_unique<FileReference>(pool->makeRef(
+    } else if (pb_item.has_file()) {
+      const uint32_t idx = pb_item.file().path_idx();
+      const std::string str = util::GetString(*value_pool_, idx);
+      return util::make_unique<FileReference>(pool->MakeRef(
           str,
           StringPool::Context(StringPool::Context::kHighPriority, config)));
 
     } else {
-      mDiag->error(DiagMessage(mSource) << "unknown item");
+      diag_->Error(DiagMessage(source_) << "unknown item");
     }
     return {};
   }
 
-  std::unique_ptr<Value> deserializeValueFromPb(const pb::Value& pbValue,
+  std::unique_ptr<Value> DeserializeValueFromPb(const pb::Value& pb_value,
                                                 const ConfigDescription& config,
                                                 StringPool* pool) {
-    const bool isWeak = pbValue.has_weak() ? pbValue.weak() : false;
+    const bool is_weak = pb_value.has_weak() ? pb_value.weak() : false;
 
     std::unique_ptr<Value> value;
-    if (pbValue.has_item()) {
-      value = deserializeItemFromPb(pbValue.item(), config, pool);
+    if (pb_value.has_item()) {
+      value = DeserializeItemFromPb(pb_value.item(), config, pool);
       if (!value) {
         return {};
       }
 
-    } else if (pbValue.has_compound_value()) {
-      const pb::CompoundValue& pbCompoundValue = pbValue.compound_value();
-      if (pbCompoundValue.has_attr()) {
-        const pb::Attribute& pbAttr = pbCompoundValue.attr();
-        std::unique_ptr<Attribute> attr = util::make_unique<Attribute>(isWeak);
-        attr->typeMask = pbAttr.format_flags();
-        attr->minInt = pbAttr.min_int();
-        attr->maxInt = pbAttr.max_int();
-        for (const pb::Attribute_Symbol& pbSymbol : pbAttr.symbols()) {
+    } else if (pb_value.has_compound_value()) {
+      const pb::CompoundValue& pb_compound_value = pb_value.compound_value();
+      if (pb_compound_value.has_attr()) {
+        const pb::Attribute& pb_attr = pb_compound_value.attr();
+        std::unique_ptr<Attribute> attr = util::make_unique<Attribute>(is_weak);
+        attr->type_mask = pb_attr.format_flags();
+        attr->min_int = pb_attr.min_int();
+        attr->max_int = pb_attr.max_int();
+        for (const pb::Attribute_Symbol& pb_symbol : pb_attr.symbols()) {
           Attribute::Symbol symbol;
-          deserializeItemCommon(pbSymbol, &symbol.symbol);
-          if (!deserializeReferenceFromPb(pbSymbol.name(), &symbol.symbol)) {
+          DeserializeItemCommon(pb_symbol, &symbol.symbol);
+          if (!DeserializeReferenceFromPb(pb_symbol.name(), &symbol.symbol)) {
             return {};
           }
-          symbol.value = pbSymbol.value();
+          symbol.value = pb_symbol.value();
           attr->symbols.push_back(std::move(symbol));
         }
         value = std::move(attr);
 
-      } else if (pbCompoundValue.has_style()) {
-        const pb::Style& pbStyle = pbCompoundValue.style();
+      } else if (pb_compound_value.has_style()) {
+        const pb::Style& pb_style = pb_compound_value.style();
         std::unique_ptr<Style> style = util::make_unique<Style>();
-        if (pbStyle.has_parent()) {
+        if (pb_style.has_parent()) {
           style->parent = Reference();
-          if (!deserializeReferenceFromPb(pbStyle.parent(),
+          if (!DeserializeReferenceFromPb(pb_style.parent(),
                                           &style->parent.value())) {
             return {};
           }
 
-          if (pbStyle.has_parent_source()) {
-            Source parentSource;
-            deserializeSourceFromPb(pbStyle.parent_source(), *mSourcePool,
-                                    &parentSource);
-            style->parent.value().setSource(std::move(parentSource));
+          if (pb_style.has_parent_source()) {
+            Source parent_source;
+            DeserializeSourceFromPb(pb_style.parent_source(), *source_pool_,
+                                    &parent_source);
+            style->parent.value().SetSource(std::move(parent_source));
           }
         }
 
-        for (const pb::Style_Entry& pbEntry : pbStyle.entries()) {
+        for (const pb::Style_Entry& pb_entry : pb_style.entries()) {
           Style::Entry entry;
-          deserializeItemCommon(pbEntry, &entry.key);
-          if (!deserializeReferenceFromPb(pbEntry.key(), &entry.key)) {
+          DeserializeItemCommon(pb_entry, &entry.key);
+          if (!DeserializeReferenceFromPb(pb_entry.key(), &entry.key)) {
             return {};
           }
 
-          entry.value = deserializeItemFromPb(pbEntry.item(), config, pool);
+          entry.value = DeserializeItemFromPb(pb_entry.item(), config, pool);
           if (!entry.value) {
             return {};
           }
 
-          deserializeItemCommon(pbEntry, entry.value.get());
+          DeserializeItemCommon(pb_entry, entry.value.get());
           style->entries.push_back(std::move(entry));
         }
         value = std::move(style);
 
-      } else if (pbCompoundValue.has_styleable()) {
-        const pb::Styleable& pbStyleable = pbCompoundValue.styleable();
+      } else if (pb_compound_value.has_styleable()) {
+        const pb::Styleable& pb_styleable = pb_compound_value.styleable();
         std::unique_ptr<Styleable> styleable = util::make_unique<Styleable>();
-        for (const pb::Styleable_Entry& pbEntry : pbStyleable.entries()) {
-          Reference attrRef;
-          deserializeItemCommon(pbEntry, &attrRef);
-          deserializeReferenceFromPb(pbEntry.attr(), &attrRef);
-          styleable->entries.push_back(std::move(attrRef));
+        for (const pb::Styleable_Entry& pb_entry : pb_styleable.entries()) {
+          Reference attr_ref;
+          DeserializeItemCommon(pb_entry, &attr_ref);
+          DeserializeReferenceFromPb(pb_entry.attr(), &attr_ref);
+          styleable->entries.push_back(std::move(attr_ref));
         }
         value = std::move(styleable);
 
-      } else if (pbCompoundValue.has_array()) {
-        const pb::Array& pbArray = pbCompoundValue.array();
+      } else if (pb_compound_value.has_array()) {
+        const pb::Array& pb_array = pb_compound_value.array();
         std::unique_ptr<Array> array = util::make_unique<Array>();
-        for (const pb::Array_Entry& pbEntry : pbArray.entries()) {
+        for (const pb::Array_Entry& pb_entry : pb_array.entries()) {
           std::unique_ptr<Item> item =
-              deserializeItemFromPb(pbEntry.item(), config, pool);
+              DeserializeItemFromPb(pb_entry.item(), config, pool);
           if (!item) {
             return {};
           }
 
-          deserializeItemCommon(pbEntry, item.get());
+          DeserializeItemCommon(pb_entry, item.get());
           array->items.push_back(std::move(item));
         }
         value = std::move(array);
 
-      } else if (pbCompoundValue.has_plural()) {
-        const pb::Plural& pbPlural = pbCompoundValue.plural();
+      } else if (pb_compound_value.has_plural()) {
+        const pb::Plural& pb_plural = pb_compound_value.plural();
         std::unique_ptr<Plural> plural = util::make_unique<Plural>();
-        for (const pb::Plural_Entry& pbEntry : pbPlural.entries()) {
-          size_t pluralIdx = deserializePluralEnumFromPb(pbEntry.arity());
+        for (const pb::Plural_Entry& pb_entry : pb_plural.entries()) {
+          size_t pluralIdx = DeserializePluralEnumFromPb(pb_entry.arity());
           plural->values[pluralIdx] =
-              deserializeItemFromPb(pbEntry.item(), config, pool);
+              DeserializeItemFromPb(pb_entry.item(), config, pool);
           if (!plural->values[pluralIdx]) {
             return {};
           }
 
-          deserializeItemCommon(pbEntry, plural->values[pluralIdx].get());
+          DeserializeItemCommon(pb_entry, plural->values[pluralIdx].get());
         }
         value = std::move(plural);
 
       } else {
-        mDiag->error(DiagMessage(mSource) << "unknown compound value");
+        diag_->Error(DiagMessage(source_) << "unknown compound value");
         return {};
       }
     } else {
-      mDiag->error(DiagMessage(mSource) << "unknown value");
+      diag_->Error(DiagMessage(source_) << "unknown value");
       return {};
     }
 
-    assert(value && "forgot to set value");
+    CHECK(value) << "forgot to set value";
 
-    value->setWeak(isWeak);
-    deserializeItemCommon(pbValue, value.get());
+    value->SetWeak(is_weak);
+    DeserializeItemCommon(pb_value, value.get());
     return value;
   }
 
-  bool deserializeReferenceFromPb(const pb::Reference& pbRef,
-                                  Reference* outRef) {
-    outRef->referenceType = deserializeReferenceTypeFromPb(pbRef.type());
-    outRef->privateReference = pbRef.private_();
+  bool DeserializeReferenceFromPb(const pb::Reference& pb_ref,
+                                  Reference* out_ref) {
+    out_ref->reference_type = DeserializeReferenceTypeFromPb(pb_ref.type());
+    out_ref->private_reference = pb_ref.private_();
 
-    if (!pbRef.has_id() && !pbRef.has_symbol_idx()) {
+    if (!pb_ref.has_id() && !pb_ref.has_symbol_idx()) {
       return false;
     }
 
-    if (pbRef.has_id()) {
-      outRef->id = ResourceId(pbRef.id());
+    if (pb_ref.has_id()) {
+      out_ref->id = ResourceId(pb_ref.id());
     }
 
-    if (pbRef.has_symbol_idx()) {
-      const std::string strSymbol =
-          util::getString(*mSymbolPool, pbRef.symbol_idx());
-      ResourceNameRef nameRef;
-      if (!ResourceUtils::parseResourceName(strSymbol, &nameRef, nullptr)) {
-        mDiag->error(DiagMessage(mSource) << "invalid reference name '"
-                                          << strSymbol << "'");
+    if (pb_ref.has_symbol_idx()) {
+      const std::string str_symbol =
+          util::GetString(*symbol_pool_, pb_ref.symbol_idx());
+      ResourceNameRef name_ref;
+      if (!ResourceUtils::ParseResourceName(str_symbol, &name_ref, nullptr)) {
+        diag_->Error(DiagMessage(source_) << "invalid reference name '"
+                                          << str_symbol << "'");
         return false;
       }
 
-      outRef->name = nameRef.toResourceName();
+      out_ref->name = name_ref.ToResourceName();
     }
     return true;
   }
 
   template <typename T>
-  void deserializeItemCommon(const T& pbItem, Value* outValue) {
-    if (pbItem.has_source()) {
+  void DeserializeItemCommon(const T& pb_item, Value* out_value) {
+    if (pb_item.has_source()) {
       Source source;
-      deserializeSourceFromPb(pbItem.source(), *mSourcePool, &source);
-      outValue->setSource(std::move(source));
+      DeserializeSourceFromPb(pb_item.source(), *source_pool_, &source);
+      out_value->SetSource(std::move(source));
     }
 
-    if (pbItem.has_comment()) {
-      outValue->setComment(pbItem.comment());
+    if (pb_item.has_comment()) {
+      out_value->SetComment(pb_item.comment());
     }
   }
 
  private:
-  const android::ResStringPool* mValuePool;
-  const android::ResStringPool* mSourcePool;
-  const android::ResStringPool* mSymbolPool;
-  const Source mSource;
-  IDiagnostics* mDiag;
+  const android::ResStringPool* value_pool_;
+  const android::ResStringPool* source_pool_;
+  const android::ResStringPool* symbol_pool_;
+  const Source source_;
+  IDiagnostics* diag_;
 };
 
 }  // namespace
 
-std::unique_ptr<ResourceTable> deserializeTableFromPb(
-    const pb::ResourceTable& pbTable, const Source& source,
+std::unique_ptr<ResourceTable> DeserializeTableFromPb(
+    const pb::ResourceTable& pb_table, const Source& source,
     IDiagnostics* diag) {
   // We import the android namespace because on Windows NO_ERROR is a macro, not
   // an enum, which
@@ -407,78 +409,79 @@
 
   std::unique_ptr<ResourceTable> table = util::make_unique<ResourceTable>();
 
-  if (!pbTable.has_string_pool()) {
-    diag->error(DiagMessage(source) << "no string pool found");
+  if (!pb_table.has_string_pool()) {
+    diag->Error(DiagMessage(source) << "no string pool found");
     return {};
   }
 
-  ResStringPool valuePool;
-  status_t result = valuePool.setTo(pbTable.string_pool().data().data(),
-                                    pbTable.string_pool().data().size());
+  ResStringPool value_pool;
+  status_t result = value_pool.setTo(pb_table.string_pool().data().data(),
+                                     pb_table.string_pool().data().size());
   if (result != NO_ERROR) {
-    diag->error(DiagMessage(source) << "invalid string pool");
+    diag->Error(DiagMessage(source) << "invalid string pool");
     return {};
   }
 
-  ResStringPool sourcePool;
-  if (pbTable.has_source_pool()) {
-    result = sourcePool.setTo(pbTable.source_pool().data().data(),
-                              pbTable.source_pool().data().size());
+  ResStringPool source_pool;
+  if (pb_table.has_source_pool()) {
+    result = source_pool.setTo(pb_table.source_pool().data().data(),
+                               pb_table.source_pool().data().size());
     if (result != NO_ERROR) {
-      diag->error(DiagMessage(source) << "invalid source pool");
+      diag->Error(DiagMessage(source) << "invalid source pool");
       return {};
     }
   }
 
-  ResStringPool symbolPool;
-  if (pbTable.has_symbol_pool()) {
-    result = symbolPool.setTo(pbTable.symbol_pool().data().data(),
-                              pbTable.symbol_pool().data().size());
+  ResStringPool symbol_pool;
+  if (pb_table.has_symbol_pool()) {
+    result = symbol_pool.setTo(pb_table.symbol_pool().data().data(),
+                               pb_table.symbol_pool().data().size());
     if (result != NO_ERROR) {
-      diag->error(DiagMessage(source) << "invalid symbol pool");
+      diag->Error(DiagMessage(source) << "invalid symbol pool");
       return {};
     }
   }
 
-  PackagePbDeserializer packagePbDeserializer(&valuePool, &sourcePool,
-                                              &symbolPool, source, diag);
-  for (const pb::Package& pbPackage : pbTable.packages()) {
-    if (!packagePbDeserializer.deserializeFromPb(pbPackage, table.get())) {
+  PackagePbDeserializer package_pb_deserializer(&value_pool, &source_pool,
+                                                &symbol_pool, source, diag);
+  for (const pb::Package& pb_package : pb_table.packages()) {
+    if (!package_pb_deserializer.DeserializeFromPb(pb_package, table.get())) {
       return {};
     }
   }
   return table;
 }
 
-std::unique_ptr<ResourceFile> deserializeCompiledFileFromPb(
-    const pb::CompiledFile& pbFile, const Source& source, IDiagnostics* diag) {
+std::unique_ptr<ResourceFile> DeserializeCompiledFileFromPb(
+    const pb::CompiledFile& pb_file, const Source& source, IDiagnostics* diag) {
   std::unique_ptr<ResourceFile> file = util::make_unique<ResourceFile>();
 
-  ResourceNameRef nameRef;
+  ResourceNameRef name_ref;
 
   // Need to create an lvalue here so that nameRef can point to something real.
-  if (!ResourceUtils::parseResourceName(pbFile.resource_name(), &nameRef)) {
-    diag->error(DiagMessage(source)
+  if (!ResourceUtils::ParseResourceName(pb_file.resource_name(), &name_ref)) {
+    diag->Error(DiagMessage(source)
                 << "invalid resource name in compiled file header: "
-                << pbFile.resource_name());
+                << pb_file.resource_name());
     return {};
   }
-  file->name = nameRef.toResourceName();
-  file->source.path = pbFile.source_path();
-  deserializeConfigDescriptionFromPb(pbFile.config(), &file->config);
+  file->name = name_ref.ToResourceName();
+  file->source.path = pb_file.source_path();
+  DeserializeConfigDescriptionFromPb(pb_file.config(), &file->config);
 
-  for (const pb::CompiledFile_Symbol& pbSymbol : pbFile.exported_symbols()) {
+  for (const pb::CompiledFile_Symbol& pb_symbol : pb_file.exported_symbols()) {
     // Need to create an lvalue here so that nameRef can point to something
     // real.
-    if (!ResourceUtils::parseResourceName(pbSymbol.resource_name(), &nameRef)) {
-      diag->error(DiagMessage(source)
+    if (!ResourceUtils::ParseResourceName(pb_symbol.resource_name(),
+                                          &name_ref)) {
+      diag->Error(DiagMessage(source)
                   << "invalid resource name for exported symbol in "
                      "compiled file header: "
-                  << pbFile.resource_name());
+                  << pb_file.resource_name());
       return {};
     }
-    file->exportedSymbols.push_back(
-        SourcedResourceName{nameRef.toResourceName(), pbSymbol.line_no()});
+    file->exported_symbols.push_back(
+        SourcedResourceName{name_ref.ToResourceName(), pb_symbol.line_no()});
   }
   return file;
 }
diff --git a/tools/aapt2/proto/TableProtoSerializer.cpp b/tools/aapt2/proto/TableProtoSerializer.cpp
index a5c2cbc..68db6b3 100644
--- a/tools/aapt2/proto/TableProtoSerializer.cpp
+++ b/tools/aapt2/proto/TableProtoSerializer.cpp
@@ -22,6 +22,8 @@
 #include "proto/ProtoSerialize.h"
 #include "util/BigBuffer.h"
 
+#include <android-base/logging.h>
+
 using google::protobuf::io::CodedOutputStream;
 using google::protobuf::io::CodedInputStream;
 using google::protobuf::io::ZeroCopyOutputStream;
@@ -31,179 +33,185 @@
 namespace {
 
 class PbSerializerVisitor : public RawValueVisitor {
-public:
-    using RawValueVisitor::visit;
+ public:
+  using RawValueVisitor::Visit;
 
-    /**
-     * Constructor to use when expecting to serialize any value.
-     */
-    PbSerializerVisitor(StringPool* sourcePool, StringPool* symbolPool, pb::Value* outPbValue) :
-            mSourcePool(sourcePool), mSymbolPool(symbolPool), mOutPbValue(outPbValue),
-            mOutPbItem(nullptr) {
+  /**
+   * Constructor to use when expecting to serialize any value.
+   */
+  PbSerializerVisitor(StringPool* source_pool, StringPool* symbol_pool,
+                      pb::Value* out_pb_value)
+      : source_pool_(source_pool),
+        symbol_pool_(symbol_pool),
+        out_pb_value_(out_pb_value),
+        out_pb_item_(nullptr) {}
+
+  /**
+   * Constructor to use when expecting to serialize an Item.
+   */
+  PbSerializerVisitor(StringPool* sourcePool, StringPool* symbolPool,
+                      pb::Item* outPbItem)
+      : source_pool_(sourcePool),
+        symbol_pool_(symbolPool),
+        out_pb_value_(nullptr),
+        out_pb_item_(outPbItem) {}
+
+  void Visit(Reference* ref) override {
+    SerializeReferenceToPb(*ref, pb_item()->mutable_ref());
+  }
+
+  void Visit(String* str) override {
+    pb_item()->mutable_str()->set_idx(str->value.index());
+  }
+
+  void Visit(StyledString* str) override {
+    pb_item()->mutable_str()->set_idx(str->value.index());
+  }
+
+  void Visit(FileReference* file) override {
+    pb_item()->mutable_file()->set_path_idx(file->path.index());
+  }
+
+  void Visit(Id* id) override { pb_item()->mutable_id(); }
+
+  void Visit(RawString* raw_str) override {
+    pb_item()->mutable_raw_str()->set_idx(raw_str->value.index());
+  }
+
+  void Visit(BinaryPrimitive* prim) override {
+    android::Res_value val = {};
+    prim->Flatten(&val);
+
+    pb::Primitive* pb_prim = pb_item()->mutable_prim();
+    pb_prim->set_type(val.dataType);
+    pb_prim->set_data(val.data);
+  }
+
+  void VisitItem(Item* item) override { LOG(FATAL) << "unimplemented item"; }
+
+  void Visit(Attribute* attr) override {
+    pb::Attribute* pb_attr = pb_compound_value()->mutable_attr();
+    pb_attr->set_format_flags(attr->type_mask);
+    pb_attr->set_min_int(attr->min_int);
+    pb_attr->set_max_int(attr->max_int);
+
+    for (auto& symbol : attr->symbols) {
+      pb::Attribute_Symbol* pb_symbol = pb_attr->add_symbols();
+      SerializeItemCommonToPb(symbol.symbol, pb_symbol);
+      SerializeReferenceToPb(symbol.symbol, pb_symbol->mutable_name());
+      pb_symbol->set_value(symbol.value);
+    }
+  }
+
+  void Visit(Style* style) override {
+    pb::Style* pb_style = pb_compound_value()->mutable_style();
+    if (style->parent) {
+      SerializeReferenceToPb(style->parent.value(), pb_style->mutable_parent());
+      SerializeSourceToPb(style->parent.value().GetSource(), source_pool_,
+                          pb_style->mutable_parent_source());
     }
 
-    /**
-     * Constructor to use when expecting to serialize an Item.
-     */
-    PbSerializerVisitor(StringPool* sourcePool, StringPool* symbolPool, pb::Item* outPbItem) :
-            mSourcePool(sourcePool), mSymbolPool(symbolPool), mOutPbValue(nullptr),
-            mOutPbItem(outPbItem) {
+    for (Style::Entry& entry : style->entries) {
+      pb::Style_Entry* pb_entry = pb_style->add_entries();
+      SerializeReferenceToPb(entry.key, pb_entry->mutable_key());
+
+      pb::Item* pb_item = pb_entry->mutable_item();
+      SerializeItemCommonToPb(entry.key, pb_entry);
+      PbSerializerVisitor sub_visitor(source_pool_, symbol_pool_, pb_item);
+      entry.value->Accept(&sub_visitor);
+    }
+  }
+
+  void Visit(Styleable* styleable) override {
+    pb::Styleable* pb_styleable = pb_compound_value()->mutable_styleable();
+    for (Reference& entry : styleable->entries) {
+      pb::Styleable_Entry* pb_entry = pb_styleable->add_entries();
+      SerializeItemCommonToPb(entry, pb_entry);
+      SerializeReferenceToPb(entry, pb_entry->mutable_attr());
+    }
+  }
+
+  void Visit(Array* array) override {
+    pb::Array* pb_array = pb_compound_value()->mutable_array();
+    for (auto& value : array->items) {
+      pb::Array_Entry* pb_entry = pb_array->add_entries();
+      SerializeItemCommonToPb(*value, pb_entry);
+      PbSerializerVisitor sub_visitor(source_pool_, symbol_pool_,
+                                      pb_entry->mutable_item());
+      value->Accept(&sub_visitor);
+    }
+  }
+
+  void Visit(Plural* plural) override {
+    pb::Plural* pb_plural = pb_compound_value()->mutable_plural();
+    const size_t count = plural->values.size();
+    for (size_t i = 0; i < count; i++) {
+      if (!plural->values[i]) {
+        // No plural value set here.
+        continue;
+      }
+
+      pb::Plural_Entry* pb_entry = pb_plural->add_entries();
+      pb_entry->set_arity(SerializePluralEnumToPb(i));
+      pb::Item* pb_element = pb_entry->mutable_item();
+      SerializeItemCommonToPb(*plural->values[i], pb_entry);
+      PbSerializerVisitor sub_visitor(source_pool_, symbol_pool_, pb_element);
+      plural->values[i]->Accept(&sub_visitor);
+    }
+  }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(PbSerializerVisitor);
+
+  pb::Item* pb_item() {
+    if (out_pb_value_) {
+      return out_pb_value_->mutable_item();
+    }
+    return out_pb_item_;
+  }
+
+  pb::CompoundValue* pb_compound_value() {
+    CHECK(out_pb_value_ != nullptr);
+    return out_pb_value_->mutable_compound_value();
+  }
+
+  template <typename T>
+  void SerializeItemCommonToPb(const Item& item, T* pb_item) {
+    SerializeSourceToPb(item.GetSource(), source_pool_,
+                        pb_item->mutable_source());
+    if (!item.GetComment().empty()) {
+      pb_item->set_comment(item.GetComment());
+    }
+  }
+
+  void SerializeReferenceToPb(const Reference& ref, pb::Reference* pb_ref) {
+    if (ref.id) {
+      pb_ref->set_id(ref.id.value().id);
     }
 
-    void visit(Reference* ref) override {
-        serializeReferenceToPb(*ref, getPbItem()->mutable_ref());
+    if (ref.name) {
+      StringPool::Ref symbol_ref =
+          symbol_pool_->MakeRef(ref.name.value().ToString());
+      pb_ref->set_symbol_idx(static_cast<uint32_t>(symbol_ref.index()));
     }
 
-    void visit(String* str) override {
-        getPbItem()->mutable_str()->set_idx(str->value.getIndex());
-    }
+    pb_ref->set_private_(ref.private_reference);
+    pb_ref->set_type(SerializeReferenceTypeToPb(ref.reference_type));
+  }
 
-    void visit(StyledString* str) override {
-        getPbItem()->mutable_str()->set_idx(str->value.getIndex());
-    }
-
-    void visit(FileReference* file) override {
-        getPbItem()->mutable_file()->set_path_idx(file->path.getIndex());
-    }
-
-    void visit(Id* id) override {
-        getPbItem()->mutable_id();
-    }
-
-    void visit(RawString* rawStr) override {
-        getPbItem()->mutable_raw_str()->set_idx(rawStr->value.getIndex());
-    }
-
-    void visit(BinaryPrimitive* prim) override {
-        android::Res_value val = {};
-        prim->flatten(&val);
-
-        pb::Primitive* pbPrim = getPbItem()->mutable_prim();
-        pbPrim->set_type(val.dataType);
-        pbPrim->set_data(val.data);
-    }
-
-    void visitItem(Item* item) override {
-        assert(false && "unimplemented item");
-    }
-
-    void visit(Attribute* attr) override {
-        pb::Attribute* pbAttr = getPbCompoundValue()->mutable_attr();
-        pbAttr->set_format_flags(attr->typeMask);
-        pbAttr->set_min_int(attr->minInt);
-        pbAttr->set_max_int(attr->maxInt);
-
-        for (auto& symbol : attr->symbols) {
-            pb::Attribute_Symbol* pbSymbol = pbAttr->add_symbols();
-            serializeItemCommonToPb(symbol.symbol, pbSymbol);
-            serializeReferenceToPb(symbol.symbol, pbSymbol->mutable_name());
-            pbSymbol->set_value(symbol.value);
-        }
-    }
-
-    void visit(Style* style) override {
-        pb::Style* pbStyle = getPbCompoundValue()->mutable_style();
-        if (style->parent) {
-            serializeReferenceToPb(style->parent.value(), pbStyle->mutable_parent());
-            serializeSourceToPb(style->parent.value().getSource(),
-                                mSourcePool,
-                                pbStyle->mutable_parent_source());
-        }
-
-        for (Style::Entry& entry : style->entries) {
-            pb::Style_Entry* pbEntry = pbStyle->add_entries();
-            serializeReferenceToPb(entry.key, pbEntry->mutable_key());
-
-            pb::Item* pbItem = pbEntry->mutable_item();
-            serializeItemCommonToPb(entry.key, pbEntry);
-            PbSerializerVisitor subVisitor(mSourcePool, mSymbolPool, pbItem);
-            entry.value->accept(&subVisitor);
-        }
-    }
-
-    void visit(Styleable* styleable) override {
-        pb::Styleable* pbStyleable = getPbCompoundValue()->mutable_styleable();
-        for (Reference& entry : styleable->entries) {
-            pb::Styleable_Entry* pbEntry = pbStyleable->add_entries();
-            serializeItemCommonToPb(entry, pbEntry);
-            serializeReferenceToPb(entry, pbEntry->mutable_attr());
-        }
-    }
-
-    void visit(Array* array) override {
-        pb::Array* pbArray = getPbCompoundValue()->mutable_array();
-        for (auto& value : array->items) {
-            pb::Array_Entry* pbEntry = pbArray->add_entries();
-            serializeItemCommonToPb(*value, pbEntry);
-            PbSerializerVisitor subVisitor(mSourcePool, mSymbolPool, pbEntry->mutable_item());
-            value->accept(&subVisitor);
-        }
-    }
-
-    void visit(Plural* plural) override {
-        pb::Plural* pbPlural = getPbCompoundValue()->mutable_plural();
-        const size_t count = plural->values.size();
-        for (size_t i = 0; i < count; i++) {
-            if (!plural->values[i]) {
-                // No plural value set here.
-                continue;
-            }
-
-            pb::Plural_Entry* pbEntry = pbPlural->add_entries();
-            pbEntry->set_arity(serializePluralEnumToPb(i));
-            pb::Item* pbElement = pbEntry->mutable_item();
-            serializeItemCommonToPb(*plural->values[i], pbEntry);
-            PbSerializerVisitor subVisitor(mSourcePool, mSymbolPool, pbElement);
-            plural->values[i]->accept(&subVisitor);
-        }
-    }
-
-private:
-    pb::Item* getPbItem() {
-        if (mOutPbValue) {
-            return mOutPbValue->mutable_item();
-        }
-        return mOutPbItem;
-    }
-
-    pb::CompoundValue* getPbCompoundValue() {
-        assert(mOutPbValue);
-        return mOutPbValue->mutable_compound_value();
-    }
-
-    template <typename T>
-    void serializeItemCommonToPb(const Item& item, T* pbItem) {
-        serializeSourceToPb(item.getSource(), mSourcePool, pbItem->mutable_source());
-        if (!item.getComment().empty()) {
-            pbItem->set_comment(item.getComment());
-        }
-    }
-
-    void serializeReferenceToPb(const Reference& ref, pb::Reference* pbRef) {
-        if (ref.id) {
-            pbRef->set_id(ref.id.value().id);
-        }
-
-        if (ref.name) {
-            StringPool::Ref symbolRef = mSymbolPool->makeRef(ref.name.value().toString());
-            pbRef->set_symbol_idx(static_cast<uint32_t>(symbolRef.getIndex()));
-        }
-
-        pbRef->set_private_(ref.privateReference);
-        pbRef->set_type(serializeReferenceTypeToPb(ref.referenceType));
-    }
-
-    StringPool* mSourcePool;
-    StringPool* mSymbolPool;
-    pb::Value* mOutPbValue;
-    pb::Item* mOutPbItem;
+  StringPool* source_pool_;
+  StringPool* symbol_pool_;
+  pb::Value* out_pb_value_;
+  pb::Item* out_pb_item_;
 };
 
-} // namespace
+}  // namespace
 
-std::unique_ptr<pb::ResourceTable> serializeTableToPb(ResourceTable* table) {
-    // We must do this before writing the resources, since the string pool IDs may change.
-    table->stringPool.sort([](const StringPool::Entry& a, const StringPool::Entry& b) -> bool {
+std::unique_ptr<pb::ResourceTable> SerializeTableToPb(ResourceTable* table) {
+  // We must do this before writing the resources, since the string pool IDs may
+  // change.
+  table->string_pool.Sort(
+      [](const StringPool::Entry& a, const StringPool::Entry& b) -> bool {
         int diff = a.context.priority - b.context.priority;
         if (diff < 0) return true;
         if (diff > 0) return false;
@@ -211,192 +219,195 @@
         if (diff < 0) return true;
         if (diff > 0) return false;
         return a.value < b.value;
-    });
-    table->stringPool.prune();
+      });
+  table->string_pool.Prune();
 
-    auto pbTable = util::make_unique<pb::ResourceTable>();
-    serializeStringPoolToPb(table->stringPool, pbTable->mutable_string_pool());
+  auto pb_table = util::make_unique<pb::ResourceTable>();
+  SerializeStringPoolToPb(table->string_pool, pb_table->mutable_string_pool());
 
-    StringPool sourcePool, symbolPool;
+  StringPool source_pool, symbol_pool;
 
-    for (auto& package : table->packages) {
-        pb::Package* pbPackage = pbTable->add_packages();
-        if (package->id) {
-            pbPackage->set_package_id(package->id.value());
+  for (auto& package : table->packages) {
+    pb::Package* pb_package = pb_table->add_packages();
+    if (package->id) {
+      pb_package->set_package_id(package->id.value());
+    }
+    pb_package->set_package_name(package->name);
+
+    for (auto& type : package->types) {
+      pb::Type* pb_type = pb_package->add_types();
+      if (type->id) {
+        pb_type->set_id(type->id.value());
+      }
+      pb_type->set_name(ToString(type->type).ToString());
+
+      for (auto& entry : type->entries) {
+        pb::Entry* pb_entry = pb_type->add_entries();
+        if (entry->id) {
+          pb_entry->set_id(entry->id.value());
         }
-        pbPackage->set_package_name(package->name);
+        pb_entry->set_name(entry->name);
 
-        for (auto& type : package->types) {
-            pb::Type* pbType = pbPackage->add_types();
-            if (type->id) {
-                pbType->set_id(type->id.value());
-            }
-            pbType->set_name(toString(type->type).toString());
+        // Write the SymbolStatus struct.
+        pb::SymbolStatus* pb_status = pb_entry->mutable_symbol_status();
+        pb_status->set_visibility(
+            SerializeVisibilityToPb(entry->symbol_status.state));
+        SerializeSourceToPb(entry->symbol_status.source, &source_pool,
+                            pb_status->mutable_source());
+        pb_status->set_comment(entry->symbol_status.comment);
 
-            for (auto& entry : type->entries) {
-                pb::Entry* pbEntry = pbType->add_entries();
-                if (entry->id) {
-                    pbEntry->set_id(entry->id.value());
-                }
-                pbEntry->set_name(entry->name);
+        for (auto& config_value : entry->values) {
+          pb::ConfigValue* pb_config_value = pb_entry->add_config_values();
+          SerializeConfig(config_value->config,
+                          pb_config_value->mutable_config());
+          if (!config_value->product.empty()) {
+            pb_config_value->mutable_config()->set_product(
+                config_value->product);
+          }
 
-                // Write the SymbolStatus struct.
-                pb::SymbolStatus* pbStatus = pbEntry->mutable_symbol_status();
-                pbStatus->set_visibility(serializeVisibilityToPb(entry->symbolStatus.state));
-                serializeSourceToPb(entry->symbolStatus.source, &sourcePool,
-                                    pbStatus->mutable_source());
-                pbStatus->set_comment(entry->symbolStatus.comment);
+          pb::Value* pb_value = pb_config_value->mutable_value();
+          SerializeSourceToPb(config_value->value->GetSource(), &source_pool,
+                              pb_value->mutable_source());
+          if (!config_value->value->GetComment().empty()) {
+            pb_value->set_comment(config_value->value->GetComment());
+          }
 
-                for (auto& configValue : entry->values) {
-                    pb::ConfigValue* pbConfigValue = pbEntry->add_config_values();
-                    serializeConfig(configValue->config, pbConfigValue->mutable_config());
-                    if (!configValue->product.empty()) {
-                        pbConfigValue->mutable_config()->set_product(configValue->product);
-                    }
+          if (config_value->value->IsWeak()) {
+            pb_value->set_weak(true);
+          }
 
-                    pb::Value* pbValue = pbConfigValue->mutable_value();
-                    serializeSourceToPb(configValue->value->getSource(), &sourcePool,
-                                        pbValue->mutable_source());
-                    if (!configValue->value->getComment().empty()) {
-                        pbValue->set_comment(configValue->value->getComment());
-                    }
-
-                    if (configValue->value->isWeak()) {
-                        pbValue->set_weak(true);
-                    }
-
-                    PbSerializerVisitor visitor(&sourcePool, &symbolPool, pbValue);
-                    configValue->value->accept(&visitor);
-                }
-            }
+          PbSerializerVisitor visitor(&source_pool, &symbol_pool, pb_value);
+          config_value->value->Accept(&visitor);
         }
+      }
     }
+  }
 
-    serializeStringPoolToPb(sourcePool, pbTable->mutable_source_pool());
-    serializeStringPoolToPb(symbolPool, pbTable->mutable_symbol_pool());
-    return pbTable;
+  SerializeStringPoolToPb(source_pool, pb_table->mutable_source_pool());
+  SerializeStringPoolToPb(symbol_pool, pb_table->mutable_symbol_pool());
+  return pb_table;
 }
 
-std::unique_ptr<pb::CompiledFile> serializeCompiledFileToPb(const ResourceFile& file) {
-    auto pbFile = util::make_unique<pb::CompiledFile>();
-    pbFile->set_resource_name(file.name.toString());
-    pbFile->set_source_path(file.source.path);
-    serializeConfig(file.config, pbFile->mutable_config());
+std::unique_ptr<pb::CompiledFile> SerializeCompiledFileToPb(
+    const ResourceFile& file) {
+  auto pb_file = util::make_unique<pb::CompiledFile>();
+  pb_file->set_resource_name(file.name.ToString());
+  pb_file->set_source_path(file.source.path);
+  SerializeConfig(file.config, pb_file->mutable_config());
 
-    for (const SourcedResourceName& exported : file.exportedSymbols) {
-        pb::CompiledFile_Symbol* pbSymbol = pbFile->add_exported_symbols();
-        pbSymbol->set_resource_name(exported.name.toString());
-        pbSymbol->set_line_no(exported.line);
-    }
-    return pbFile;
+  for (const SourcedResourceName& exported : file.exported_symbols) {
+    pb::CompiledFile_Symbol* pb_symbol = pb_file->add_exported_symbols();
+    pb_symbol->set_resource_name(exported.name.ToString());
+    pb_symbol->set_line_no(exported.line);
+  }
+  return pb_file;
 }
 
-CompiledFileOutputStream::CompiledFileOutputStream(ZeroCopyOutputStream* out) : mOut(out) {
-}
+CompiledFileOutputStream::CompiledFileOutputStream(ZeroCopyOutputStream* out)
+    : out_(out) {}
 
-void CompiledFileOutputStream::ensureAlignedWrite() {
-    const int padding = mOut.ByteCount() % 4;
-    if (padding > 0) {
-        uint32_t zero = 0u;
-        mOut.WriteRaw(&zero, padding);
-    }
+void CompiledFileOutputStream::EnsureAlignedWrite() {
+  const int padding = out_.ByteCount() % 4;
+  if (padding > 0) {
+    uint32_t zero = 0u;
+    out_.WriteRaw(&zero, padding);
+  }
 }
 
 void CompiledFileOutputStream::WriteLittleEndian32(uint32_t val) {
-    ensureAlignedWrite();
-    mOut.WriteLittleEndian32(val);
+  EnsureAlignedWrite();
+  out_.WriteLittleEndian32(val);
 }
 
-void CompiledFileOutputStream::WriteCompiledFile(const pb::CompiledFile* compiledFile) {
-    ensureAlignedWrite();
-    mOut.WriteLittleEndian64(static_cast<uint64_t>(compiledFile->ByteSize()));
-    compiledFile->SerializeWithCachedSizes(&mOut);
+void CompiledFileOutputStream::WriteCompiledFile(
+    const pb::CompiledFile* compiled_file) {
+  EnsureAlignedWrite();
+  out_.WriteLittleEndian64(static_cast<uint64_t>(compiled_file->ByteSize()));
+  compiled_file->SerializeWithCachedSizes(&out_);
 }
 
 void CompiledFileOutputStream::WriteData(const BigBuffer* buffer) {
-    ensureAlignedWrite();
-    mOut.WriteLittleEndian64(static_cast<uint64_t>(buffer->size()));
-    for (const BigBuffer::Block& block : *buffer) {
-        mOut.WriteRaw(block.buffer.get(), block.size);
-    }
+  EnsureAlignedWrite();
+  out_.WriteLittleEndian64(static_cast<uint64_t>(buffer->size()));
+  for (const BigBuffer::Block& block : *buffer) {
+    out_.WriteRaw(block.buffer.get(), block.size);
+  }
 }
 
 void CompiledFileOutputStream::WriteData(const void* data, size_t len) {
-    ensureAlignedWrite();
-    mOut.WriteLittleEndian64(static_cast<uint64_t>(len));
-    mOut.WriteRaw(data, len);
+  EnsureAlignedWrite();
+  out_.WriteLittleEndian64(static_cast<uint64_t>(len));
+  out_.WriteRaw(data, len);
 }
 
-bool CompiledFileOutputStream::HadError() {
-    return mOut.HadError();
+bool CompiledFileOutputStream::HadError() { return out_.HadError(); }
+
+CompiledFileInputStream::CompiledFileInputStream(const void* data, size_t size)
+    : in_(static_cast<const uint8_t*>(data), size) {}
+
+void CompiledFileInputStream::EnsureAlignedRead() {
+  const int padding = in_.CurrentPosition() % 4;
+  if (padding > 0) {
+    // Reads are always 4 byte aligned.
+    in_.Skip(padding);
+  }
 }
 
-CompiledFileInputStream::CompiledFileInputStream(const void* data, size_t size) :
-        mIn(static_cast<const uint8_t*>(data), size) {
+bool CompiledFileInputStream::ReadLittleEndian32(uint32_t* out_val) {
+  EnsureAlignedRead();
+  return in_.ReadLittleEndian32(out_val);
 }
 
-void CompiledFileInputStream::ensureAlignedRead() {
-    const int padding = mIn.CurrentPosition() % 4;
-    if (padding > 0) {
-        // Reads are always 4 byte aligned.
-        mIn.Skip(padding);
-    }
+bool CompiledFileInputStream::ReadCompiledFile(pb::CompiledFile* out_val) {
+  EnsureAlignedRead();
+
+  uint64_t pb_size = 0u;
+  if (!in_.ReadLittleEndian64(&pb_size)) {
+    return false;
+  }
+
+  CodedInputStream::Limit l = in_.PushLimit(static_cast<int>(pb_size));
+
+  // Check that we haven't tried to read past the end.
+  if (static_cast<uint64_t>(in_.BytesUntilLimit()) != pb_size) {
+    in_.PopLimit(l);
+    in_.PushLimit(0);
+    return false;
+  }
+
+  if (!out_val->ParsePartialFromCodedStream(&in_)) {
+    in_.PopLimit(l);
+    in_.PushLimit(0);
+    return false;
+  }
+
+  in_.PopLimit(l);
+  return true;
 }
 
-bool CompiledFileInputStream::ReadLittleEndian32(uint32_t* outVal) {
-    ensureAlignedRead();
-    return mIn.ReadLittleEndian32(outVal);
+bool CompiledFileInputStream::ReadDataMetaData(uint64_t* out_offset,
+                                               uint64_t* out_len) {
+  EnsureAlignedRead();
+
+  uint64_t pb_size = 0u;
+  if (!in_.ReadLittleEndian64(&pb_size)) {
+    return false;
+  }
+
+  // Check that we aren't trying to read past the end.
+  if (pb_size > static_cast<uint64_t>(in_.BytesUntilLimit())) {
+    in_.PushLimit(0);
+    return false;
+  }
+
+  uint64_t offset = static_cast<uint64_t>(in_.CurrentPosition());
+  if (!in_.Skip(pb_size)) {
+    return false;
+  }
+
+  *out_offset = offset;
+  *out_len = pb_size;
+  return true;
 }
 
-bool CompiledFileInputStream::ReadCompiledFile(pb::CompiledFile* outVal) {
-    ensureAlignedRead();
-
-    uint64_t pbSize = 0u;
-    if (!mIn.ReadLittleEndian64(&pbSize)) {
-        return false;
-    }
-
-    CodedInputStream::Limit l = mIn.PushLimit(static_cast<int>(pbSize));
-
-    // Check that we haven't tried to read past the end.
-    if (static_cast<uint64_t>(mIn.BytesUntilLimit()) != pbSize) {
-        mIn.PopLimit(l);
-        mIn.PushLimit(0);
-        return false;
-    }
-
-    if (!outVal->ParsePartialFromCodedStream(&mIn)) {
-        mIn.PopLimit(l);
-        mIn.PushLimit(0);
-        return false;
-    }
-
-    mIn.PopLimit(l);
-    return true;
-}
-
-bool CompiledFileInputStream::ReadDataMetaData(uint64_t* outOffset, uint64_t* outLen) {
-    ensureAlignedRead();
-
-    uint64_t pbSize = 0u;
-    if (!mIn.ReadLittleEndian64(&pbSize)) {
-        return false;
-    }
-
-    // Check that we aren't trying to read past the end.
-    if (pbSize > static_cast<uint64_t>(mIn.BytesUntilLimit())) {
-        mIn.PushLimit(0);
-        return false;
-    }
-
-    uint64_t offset = static_cast<uint64_t>(mIn.CurrentPosition());
-    if (!mIn.Skip(pbSize)) {
-        return false;
-    }
-
-    *outOffset = offset;
-    *outLen = pbSize;
-    return true;
-}
-
-} // namespace aapt
+}  // namespace aapt
diff --git a/tools/aapt2/proto/TableProtoSerializer_test.cpp b/tools/aapt2/proto/TableProtoSerializer_test.cpp
index 2bd9767..fdd5197 100644
--- a/tools/aapt2/proto/TableProtoSerializer_test.cpp
+++ b/tools/aapt2/proto/TableProtoSerializer_test.cpp
@@ -14,200 +14,211 @@
  * limitations under the License.
  */
 
-#include "ResourceTable.h"
 #include "proto/ProtoSerialize.h"
+
+#include "ResourceTable.h"
 #include "test/Test.h"
 
-using namespace google::protobuf::io;
+using ::google::protobuf::io::StringOutputStream;
 
 namespace aapt {
 
 TEST(TableProtoSerializer, SerializeSinglePackage) {
-    std::unique_ptr<IAaptContext> context = test::ContextBuilder().build();
-    std::unique_ptr<ResourceTable> table = test::ResourceTableBuilder()
-            .setPackageId("com.app.a", 0x7f)
-            .addFileReference("com.app.a:layout/main", ResourceId(0x7f020000),
-                              "res/layout/main.xml")
-            .addReference("com.app.a:layout/other", ResourceId(0x7f020001),
-                          "com.app.a:layout/main")
-            .addString("com.app.a:string/text", {}, "hi")
-            .addValue("com.app.a:id/foo", {}, util::make_unique<Id>())
-            .build();
+  std::unique_ptr<IAaptContext> context = test::ContextBuilder().Build();
+  std::unique_ptr<ResourceTable> table =
+      test::ResourceTableBuilder()
+          .SetPackageId("com.app.a", 0x7f)
+          .AddFileReference("com.app.a:layout/main", ResourceId(0x7f020000),
+                            "res/layout/main.xml")
+          .AddReference("com.app.a:layout/other", ResourceId(0x7f020001),
+                        "com.app.a:layout/main")
+          .AddString("com.app.a:string/text", {}, "hi")
+          .AddValue("com.app.a:id/foo", {}, util::make_unique<Id>())
+          .Build();
 
-    Symbol publicSymbol;
-    publicSymbol.state = SymbolState::kPublic;
-    ASSERT_TRUE(table->setSymbolState(test::parseNameOrDie("com.app.a:layout/main"),
-                                      ResourceId(0x7f020000),
-                                      publicSymbol, context->getDiagnostics()));
+  Symbol public_symbol;
+  public_symbol.state = SymbolState::kPublic;
+  ASSERT_TRUE(table->SetSymbolState(
+      test::ParseNameOrDie("com.app.a:layout/main"), ResourceId(0x7f020000),
+      public_symbol, context->GetDiagnostics()));
 
-    Id* id = test::getValue<Id>(table.get(), "com.app.a:id/foo");
-    ASSERT_NE(nullptr, id);
+  Id* id = test::GetValue<Id>(table.get(), "com.app.a:id/foo");
+  ASSERT_NE(nullptr, id);
 
-    // Make a plural.
-    std::unique_ptr<Plural> plural = util::make_unique<Plural>();
-    plural->values[Plural::One] = util::make_unique<String>(table->stringPool.makeRef("one"));
-    ASSERT_TRUE(table->addResource(test::parseNameOrDie("com.app.a:plurals/hey"),
-                                   ConfigDescription{}, {}, std::move(plural),
-                                   context->getDiagnostics()));
+  // Make a plural.
+  std::unique_ptr<Plural> plural = util::make_unique<Plural>();
+  plural->values[Plural::One] =
+      util::make_unique<String>(table->string_pool.MakeRef("one"));
+  ASSERT_TRUE(table->AddResource(test::ParseNameOrDie("com.app.a:plurals/hey"),
+                                 ConfigDescription{}, {}, std::move(plural),
+                                 context->GetDiagnostics()));
 
-    // Make a resource with different products.
-    ASSERT_TRUE(table->addResource(test::parseNameOrDie("com.app.a:integer/one"),
-                                   test::parseConfigOrDie("land"), {},
-                                   test::buildPrimitive(android::Res_value::TYPE_INT_DEC, 123u),
-                                   context->getDiagnostics()));
-    ASSERT_TRUE(table->addResource(test::parseNameOrDie("com.app.a:integer/one"),
-                                       test::parseConfigOrDie("land"), "tablet",
-                                       test::buildPrimitive(android::Res_value::TYPE_INT_DEC, 321u),
-                                       context->getDiagnostics()));
+  // Make a resource with different products.
+  ASSERT_TRUE(table->AddResource(
+      test::ParseNameOrDie("com.app.a:integer/one"),
+      test::ParseConfigOrDie("land"), {},
+      test::BuildPrimitive(android::Res_value::TYPE_INT_DEC, 123u),
+      context->GetDiagnostics()));
+  ASSERT_TRUE(table->AddResource(
+      test::ParseNameOrDie("com.app.a:integer/one"),
+      test::ParseConfigOrDie("land"), "tablet",
+      test::BuildPrimitive(android::Res_value::TYPE_INT_DEC, 321u),
+      context->GetDiagnostics()));
 
-    // Make a reference with both resource name and resource ID.
-    // The reference should point to a resource outside of this table to test that both
-    // name and id get serialized.
-    Reference expectedRef;
-    expectedRef.name = test::parseNameOrDie("android:layout/main");
-    expectedRef.id = ResourceId(0x01020000);
-    ASSERT_TRUE(table->addResource(test::parseNameOrDie("com.app.a:layout/abc"),
-                                   ConfigDescription::defaultConfig(), {},
-                                   util::make_unique<Reference>(expectedRef),
-                                   context->getDiagnostics()));
+  // Make a reference with both resource name and resource ID.
+  // The reference should point to a resource outside of this table to test that
+  // both
+  // name and id get serialized.
+  Reference expected_ref;
+  expected_ref.name = test::ParseNameOrDie("android:layout/main");
+  expected_ref.id = ResourceId(0x01020000);
+  ASSERT_TRUE(table->AddResource(test::ParseNameOrDie("com.app.a:layout/abc"),
+                                 ConfigDescription::DefaultConfig(), {},
+                                 util::make_unique<Reference>(expected_ref),
+                                 context->GetDiagnostics()));
 
-    std::unique_ptr<pb::ResourceTable> pbTable = serializeTableToPb(table.get());
-    ASSERT_NE(nullptr, pbTable);
+  std::unique_ptr<pb::ResourceTable> pb_table = SerializeTableToPb(table.get());
+  ASSERT_NE(nullptr, pb_table);
 
-    std::unique_ptr<ResourceTable> newTable = deserializeTableFromPb(*pbTable,
-                                                                     Source{ "test" },
-                                                                     context->getDiagnostics());
-    ASSERT_NE(nullptr, newTable);
+  std::unique_ptr<ResourceTable> new_table = DeserializeTableFromPb(
+      *pb_table, Source{"test"}, context->GetDiagnostics());
+  ASSERT_NE(nullptr, new_table);
 
-    Id* newId = test::getValue<Id>(newTable.get(), "com.app.a:id/foo");
-    ASSERT_NE(nullptr, newId);
-    EXPECT_EQ(id->isWeak(), newId->isWeak());
+  Id* new_id = test::GetValue<Id>(new_table.get(), "com.app.a:id/foo");
+  ASSERT_NE(nullptr, new_id);
+  EXPECT_EQ(id->IsWeak(), new_id->IsWeak());
 
-    Maybe<ResourceTable::SearchResult> result = newTable->findResource(
-            test::parseNameOrDie("com.app.a:layout/main"));
-    AAPT_ASSERT_TRUE(result);
-    EXPECT_EQ(SymbolState::kPublic, result.value().type->symbolStatus.state);
-    EXPECT_EQ(SymbolState::kPublic, result.value().entry->symbolStatus.state);
+  Maybe<ResourceTable::SearchResult> result =
+      new_table->FindResource(test::ParseNameOrDie("com.app.a:layout/main"));
+  AAPT_ASSERT_TRUE(result);
+  EXPECT_EQ(SymbolState::kPublic, result.value().type->symbol_status.state);
+  EXPECT_EQ(SymbolState::kPublic, result.value().entry->symbol_status.state);
 
-    // Find the product-dependent values
-    BinaryPrimitive* prim = test::getValueForConfigAndProduct<BinaryPrimitive>(
-            newTable.get(), "com.app.a:integer/one", test::parseConfigOrDie("land"), "");
-    ASSERT_NE(nullptr, prim);
-    EXPECT_EQ(123u, prim->value.data);
+  // Find the product-dependent values
+  BinaryPrimitive* prim = test::GetValueForConfigAndProduct<BinaryPrimitive>(
+      new_table.get(), "com.app.a:integer/one", test::ParseConfigOrDie("land"),
+      "");
+  ASSERT_NE(nullptr, prim);
+  EXPECT_EQ(123u, prim->value.data);
 
-    prim = test::getValueForConfigAndProduct<BinaryPrimitive>(
-            newTable.get(), "com.app.a:integer/one", test::parseConfigOrDie("land"), "tablet");
-    ASSERT_NE(nullptr, prim);
-    EXPECT_EQ(321u, prim->value.data);
+  prim = test::GetValueForConfigAndProduct<BinaryPrimitive>(
+      new_table.get(), "com.app.a:integer/one", test::ParseConfigOrDie("land"),
+      "tablet");
+  ASSERT_NE(nullptr, prim);
+  EXPECT_EQ(321u, prim->value.data);
 
-    Reference* actualRef = test::getValue<Reference>(newTable.get(), "com.app.a:layout/abc");
-    ASSERT_NE(nullptr, actualRef);
-    AAPT_ASSERT_TRUE(actualRef->name);
-    AAPT_ASSERT_TRUE(actualRef->id);
-    EXPECT_EQ(expectedRef.name.value(), actualRef->name.value());
-    EXPECT_EQ(expectedRef.id.value(), actualRef->id.value());
+  Reference* actual_ref =
+      test::GetValue<Reference>(new_table.get(), "com.app.a:layout/abc");
+  ASSERT_NE(nullptr, actual_ref);
+  AAPT_ASSERT_TRUE(actual_ref->name);
+  AAPT_ASSERT_TRUE(actual_ref->id);
+  EXPECT_EQ(expected_ref.name.value(), actual_ref->name.value());
+  EXPECT_EQ(expected_ref.id.value(), actual_ref->id.value());
 }
 
 TEST(TableProtoSerializer, SerializeFileHeader) {
-    std::unique_ptr<IAaptContext> context = test::ContextBuilder().build();
+  std::unique_ptr<IAaptContext> context = test::ContextBuilder().Build();
 
-    ResourceFile f;
-    f.config = test::parseConfigOrDie("hdpi-v9");
-    f.name = test::parseNameOrDie("com.app.a:layout/main");
-    f.source.path = "res/layout-hdpi-v9/main.xml";
-    f.exportedSymbols.push_back(SourcedResourceName{ test::parseNameOrDie("id/unchecked"), 23u });
+  ResourceFile f;
+  f.config = test::ParseConfigOrDie("hdpi-v9");
+  f.name = test::ParseNameOrDie("com.app.a:layout/main");
+  f.source.path = "res/layout-hdpi-v9/main.xml";
+  f.exported_symbols.push_back(
+      SourcedResourceName{test::ParseNameOrDie("id/unchecked"), 23u});
 
-    const std::string expectedData1 = "123";
-    const std::string expectedData2 = "1234";
+  const std::string expected_data1 = "123";
+  const std::string expected_data2 = "1234";
 
-    std::string outputStr;
-    {
-        std::unique_ptr<pb::CompiledFile> pbFile1 = serializeCompiledFileToPb(f);
+  std::string output_str;
+  {
+    std::unique_ptr<pb::CompiledFile> pb_file1 = SerializeCompiledFileToPb(f);
 
-        f.name.entry = "__" + f.name.entry + "$0";
-        std::unique_ptr<pb::CompiledFile> pbFile2 = serializeCompiledFileToPb(f);
+    f.name.entry = "__" + f.name.entry + "$0";
+    std::unique_ptr<pb::CompiledFile> pb_file2 = SerializeCompiledFileToPb(f);
 
-        StringOutputStream outStream(&outputStr);
-        CompiledFileOutputStream outFileStream(&outStream);
-        outFileStream.WriteLittleEndian32(2);
-        outFileStream.WriteCompiledFile(pbFile1.get());
-        outFileStream.WriteData(expectedData1.data(), expectedData1.size());
-        outFileStream.WriteCompiledFile(pbFile2.get());
-        outFileStream.WriteData(expectedData2.data(), expectedData2.size());
-        ASSERT_FALSE(outFileStream.HadError());
-    }
+    StringOutputStream out_stream(&output_str);
+    CompiledFileOutputStream out_file_stream(&out_stream);
+    out_file_stream.WriteLittleEndian32(2);
+    out_file_stream.WriteCompiledFile(pb_file1.get());
+    out_file_stream.WriteData(expected_data1.data(), expected_data1.size());
+    out_file_stream.WriteCompiledFile(pb_file2.get());
+    out_file_stream.WriteData(expected_data2.data(), expected_data2.size());
+    ASSERT_FALSE(out_file_stream.HadError());
+  }
 
-    CompiledFileInputStream inFileStream(outputStr.data(), outputStr.size());
-    uint32_t numFiles = 0;
-    ASSERT_TRUE(inFileStream.ReadLittleEndian32(&numFiles));
-    ASSERT_EQ(2u, numFiles);
+  CompiledFileInputStream in_file_stream(output_str.data(), output_str.size());
+  uint32_t num_files = 0;
+  ASSERT_TRUE(in_file_stream.ReadLittleEndian32(&num_files));
+  ASSERT_EQ(2u, num_files);
 
-    // Read the first compiled file.
+  // Read the first compiled file.
 
-    pb::CompiledFile newPbFile;
-    ASSERT_TRUE(inFileStream.ReadCompiledFile(&newPbFile));
+  pb::CompiledFile new_pb_file;
+  ASSERT_TRUE(in_file_stream.ReadCompiledFile(&new_pb_file));
 
-    std::unique_ptr<ResourceFile> file = deserializeCompiledFileFromPb(newPbFile, Source("test"),
-                                                                       context->getDiagnostics());
-    ASSERT_NE(nullptr, file);
+  std::unique_ptr<ResourceFile> file = DeserializeCompiledFileFromPb(
+      new_pb_file, Source("test"), context->GetDiagnostics());
+  ASSERT_NE(nullptr, file);
 
-    uint64_t offset, len;
-    ASSERT_TRUE(inFileStream.ReadDataMetaData(&offset, &len));
+  uint64_t offset, len;
+  ASSERT_TRUE(in_file_stream.ReadDataMetaData(&offset, &len));
 
-    std::string actualData(outputStr.data() + offset, len);
-    EXPECT_EQ(expectedData1, actualData);
+  std::string actual_data(output_str.data() + offset, len);
+  EXPECT_EQ(expected_data1, actual_data);
 
-    // Expect the data to be aligned.
-    EXPECT_EQ(0u, offset & 0x03);
+  // Expect the data to be aligned.
+  EXPECT_EQ(0u, offset & 0x03);
 
-    ASSERT_EQ(1u, file->exportedSymbols.size());
-    EXPECT_EQ(test::parseNameOrDie("id/unchecked"), file->exportedSymbols[0].name);
+  ASSERT_EQ(1u, file->exported_symbols.size());
+  EXPECT_EQ(test::ParseNameOrDie("id/unchecked"),
+            file->exported_symbols[0].name);
 
-    // Read the second compiled file.
+  // Read the second compiled file.
 
-    ASSERT_TRUE(inFileStream.ReadCompiledFile(&newPbFile));
+  ASSERT_TRUE(in_file_stream.ReadCompiledFile(&new_pb_file));
 
-    file = deserializeCompiledFileFromPb(newPbFile, Source("test"), context->getDiagnostics());
-    ASSERT_NE(nullptr, file);
+  file = DeserializeCompiledFileFromPb(new_pb_file, Source("test"),
+                                       context->GetDiagnostics());
+  ASSERT_NE(nullptr, file);
 
-    ASSERT_TRUE(inFileStream.ReadDataMetaData(&offset, &len));
+  ASSERT_TRUE(in_file_stream.ReadDataMetaData(&offset, &len));
 
-    actualData = std::string(outputStr.data() + offset, len);
-    EXPECT_EQ(expectedData2, actualData);
+  actual_data = std::string(output_str.data() + offset, len);
+  EXPECT_EQ(expected_data2, actual_data);
 
-    // Expect the data to be aligned.
-    EXPECT_EQ(0u, offset & 0x03);
+  // Expect the data to be aligned.
+  EXPECT_EQ(0u, offset & 0x03);
 }
 
 TEST(TableProtoSerializer, DeserializeCorruptHeaderSafely) {
-    ResourceFile f;
-    std::unique_ptr<pb::CompiledFile> pbFile = serializeCompiledFileToPb(f);
+  ResourceFile f;
+  std::unique_ptr<pb::CompiledFile> pb_file = SerializeCompiledFileToPb(f);
 
-    const std::string expectedData = "1234";
+  const std::string expected_data = "1234";
 
-    std::string outputStr;
-    {
-        StringOutputStream outStream(&outputStr);
-        CompiledFileOutputStream outFileStream(&outStream);
-        outFileStream.WriteLittleEndian32(1);
-        outFileStream.WriteCompiledFile(pbFile.get());
-        outFileStream.WriteData(expectedData.data(), expectedData.size());
-        ASSERT_FALSE(outFileStream.HadError());
-    }
+  std::string output_str;
+  {
+    StringOutputStream out_stream(&output_str);
+    CompiledFileOutputStream out_file_stream(&out_stream);
+    out_file_stream.WriteLittleEndian32(1);
+    out_file_stream.WriteCompiledFile(pb_file.get());
+    out_file_stream.WriteData(expected_data.data(), expected_data.size());
+    ASSERT_FALSE(out_file_stream.HadError());
+  }
 
-    outputStr[4] = 0xff;
+  output_str[4] = 0xff;
 
-    CompiledFileInputStream inFileStream(outputStr.data(), outputStr.size());
+  CompiledFileInputStream in_file_stream(output_str.data(), output_str.size());
 
-    uint32_t numFiles = 0;
-    EXPECT_TRUE(inFileStream.ReadLittleEndian32(&numFiles));
-    EXPECT_EQ(1u, numFiles);
+  uint32_t num_files = 0;
+  EXPECT_TRUE(in_file_stream.ReadLittleEndian32(&num_files));
+  EXPECT_EQ(1u, num_files);
 
-    pb::CompiledFile newPbFile;
-    EXPECT_FALSE(inFileStream.ReadCompiledFile(&newPbFile));
+  pb::CompiledFile new_pb_file;
+  EXPECT_FALSE(in_file_stream.ReadCompiledFile(&new_pb_file));
 
-    uint64_t offset, len;
-    EXPECT_FALSE(inFileStream.ReadDataMetaData(&offset, &len));
+  uint64_t offset, len;
+  EXPECT_FALSE(in_file_stream.ReadDataMetaData(&offset, &len));
 }
 
-} // namespace aapt
+}  // namespace aapt