Commit 5d8b7b9e authored by Kalvin Lee's avatar Kalvin Lee Committed by Commit Bot

PpdProvider v3: fix enum names

This change brings the variants of the metadata type enum (internal to
the PpdMetadataManager class) in line with the style guide's guidance.

Bug: chromium:888189
Test: chromeos_unittests --gtest_filter='PpdMetadataManagerTest.*'
Change-Id: I9b87932b187c95f600db4caa3f945f9a9d6af5ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2340634
Commit-Queue: Kalvin Lee <kdlee@chromium.org>
Reviewed-by: default avatarLuum Habtemariam <luum@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801972}
parent f326a5b9
...@@ -330,12 +330,12 @@ class MetadataLocaleFinder { ...@@ -330,12 +330,12 @@ class MetadataLocaleFinder {
}; };
enum class PpdMetadataType { enum class PpdMetadataType {
LOCALES, kLocales,
MANUFACTURERS, // locale-sensitive kManufacturers, // locale-sensitive
PRINTERS, // locale-sensitive kPrinters, // locale-sensitive
INDEX, kForwardIndex,
REVERSE_INDEX, // locale-sensitive kReverseIndex, // locale-sensitive
USB_INDEX, kUsbIndex,
}; };
// Control argument that fully specifies the basename and containing // Control argument that fully specifies the basename and containing
...@@ -349,10 +349,10 @@ struct PpdMetadataPathSpecifier { ...@@ -349,10 +349,10 @@ struct PpdMetadataPathSpecifier {
PpdMetadataType type; PpdMetadataType type;
// Used in two different ways as needed: // Used in two different ways as needed:
// 1. if |type| == PRINTERS, // 1. if |type| == kPrinters,
// then caller should populate this with the full basename of the // then caller should populate this with the full basename of the
// target printers metadata file. Or, // target printers metadata file. Or,
// 2. if |type| is locale-sensitive and != PRINTERS, // 2. if |type| is locale-sensitive and != kPrinters,
// then caller should populate this with the two-letter target // then caller should populate this with the two-letter target
// locale (as previously advertised by the serving root). // locale (as previously advertised by the serving root).
// //
...@@ -361,10 +361,10 @@ struct PpdMetadataPathSpecifier { ...@@ -361,10 +361,10 @@ struct PpdMetadataPathSpecifier {
const char* optional_tag; const char* optional_tag;
// Used in two different ways as needed: // Used in two different ways as needed:
// 1. if |type| != USB_INDEX, // 1. if |type| != kUsbIndex,
// then this is the numerical shard of the target metadata // then this is the numerical shard of the target metadata
// basename, if needed. Or, // basename, if needed. Or,
// 2. if |type| == USB_INDEX, // 2. if |type| == kUsbIndex,
// then this is the vendor ID of the the device manufacturer being // then this is the vendor ID of the the device manufacturer being
// sought. // sought.
int optional_shard; int optional_shard;
...@@ -376,16 +376,16 @@ struct PpdMetadataPathSpecifier { ...@@ -376,16 +376,16 @@ struct PpdMetadataPathSpecifier {
std::string PpdMetadataPathInServingRoot( std::string PpdMetadataPathInServingRoot(
const PpdMetadataPathSpecifier& options) { const PpdMetadataPathSpecifier& options) {
switch (options.type) { switch (options.type) {
case PpdMetadataType::LOCALES: case PpdMetadataType::kLocales:
return base::StringPrintf("%s/locales.json", kMetadataParentDirectory); return base::StringPrintf("%s/locales.json", kMetadataParentDirectory);
case PpdMetadataType::MANUFACTURERS: case PpdMetadataType::kManufacturers:
// This type is locale-sensitive; the tag carries the locale. // This type is locale-sensitive; the tag carries the locale.
DCHECK(!base::StringPiece(options.optional_tag).empty()); DCHECK(!base::StringPiece(options.optional_tag).empty());
return base::StringPrintf("%s/manufacturers-%s.json", return base::StringPrintf("%s/manufacturers-%s.json",
kMetadataParentDirectory, options.optional_tag); kMetadataParentDirectory, options.optional_tag);
case PpdMetadataType::PRINTERS: case PpdMetadataType::kPrinters:
// This type is locale-sensitive; in this context, the tag carries // This type is locale-sensitive; in this context, the tag carries
// the full basename, which caller will have extracted from a leaf // the full basename, which caller will have extracted from a leaf
// in manufacturers metadata. // in manufacturers metadata.
...@@ -393,13 +393,13 @@ std::string PpdMetadataPathInServingRoot( ...@@ -393,13 +393,13 @@ std::string PpdMetadataPathInServingRoot(
return base::StringPrintf("%s/%s", kMetadataParentDirectory, return base::StringPrintf("%s/%s", kMetadataParentDirectory,
options.optional_tag); options.optional_tag);
case PpdMetadataType::INDEX: case PpdMetadataType::kForwardIndex:
DCHECK(options.optional_shard >= 0 && DCHECK(options.optional_shard >= 0 &&
options.optional_shard < kNumShards); options.optional_shard < kNumShards);
return base::StringPrintf("%s/index-%02d.json", kMetadataParentDirectory, return base::StringPrintf("%s/index-%02d.json", kMetadataParentDirectory,
options.optional_shard); options.optional_shard);
case PpdMetadataType::REVERSE_INDEX: case PpdMetadataType::kReverseIndex:
// This type is locale-sensitive; the tag carries the locale. // This type is locale-sensitive; the tag carries the locale.
DCHECK(!base::StringPiece(options.optional_tag).empty()); DCHECK(!base::StringPiece(options.optional_tag).empty());
DCHECK(options.optional_shard >= 0 && DCHECK(options.optional_shard >= 0 &&
...@@ -408,7 +408,7 @@ std::string PpdMetadataPathInServingRoot( ...@@ -408,7 +408,7 @@ std::string PpdMetadataPathInServingRoot(
kMetadataParentDirectory, options.optional_tag, kMetadataParentDirectory, options.optional_tag,
options.optional_shard); options.optional_shard);
case PpdMetadataType::USB_INDEX: case PpdMetadataType::kUsbIndex:
DCHECK(options.optional_shard >= 0 && DCHECK(options.optional_shard >= 0 &&
options.optional_shard <= kSixteenBitsMaximum); options.optional_shard <= kSixteenBitsMaximum);
return base::StringPrintf("%s/usb-%04x.json", kMetadataParentDirectory, return base::StringPrintf("%s/usb-%04x.json", kMetadataParentDirectory,
...@@ -455,7 +455,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager { ...@@ -455,7 +455,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
return; return;
} }
const PpdMetadataPathSpecifier options = {PpdMetadataType::LOCALES}; const PpdMetadataPathSpecifier options = {PpdMetadataType::kLocales};
const std::string metadata_name = PpdMetadataPathInServingRoot(options); const std::string metadata_name = PpdMetadataPathInServingRoot(options);
PrinterConfigCache::FetchCallback fetch_cb = PrinterConfigCache::FetchCallback fetch_cb =
...@@ -472,7 +472,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager { ...@@ -472,7 +472,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!metadata_locale_.empty()); DCHECK(!metadata_locale_.empty());
const PpdMetadataPathSpecifier options = {PpdMetadataType::MANUFACTURERS, const PpdMetadataPathSpecifier options = {PpdMetadataType::kManufacturers,
metadata_locale_.c_str()}; metadata_locale_.c_str()};
const std::string metadata_name = PpdMetadataPathInServingRoot(options); const std::string metadata_name = PpdMetadataPathInServingRoot(options);
...@@ -548,7 +548,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager { ...@@ -548,7 +548,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
return; return;
} }
const PpdMetadataPathSpecifier options = {PpdMetadataType::USB_INDEX, const PpdMetadataPathSpecifier options = {PpdMetadataType::kUsbIndex,
nullptr, vendor_id}; nullptr, vendor_id};
const std::string metadata_name = PpdMetadataPathInServingRoot(options); const std::string metadata_name = PpdMetadataPathInServingRoot(options);
...@@ -571,7 +571,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager { ...@@ -571,7 +571,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
DCHECK(!metadata_locale_.empty()); DCHECK(!metadata_locale_.empty());
const PpdMetadataPathSpecifier reverse_index_options = { const PpdMetadataPathSpecifier reverse_index_options = {
PpdMetadataType::REVERSE_INDEX, metadata_locale_.c_str(), PpdMetadataType::kReverseIndex, metadata_locale_.c_str(),
IndexShard(effective_make_and_model)}; IndexShard(effective_make_and_model)};
const std::string metadata_name = const std::string metadata_name =
PpdMetadataPathInServingRoot(reverse_index_options); PpdMetadataPathInServingRoot(reverse_index_options);
...@@ -609,7 +609,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager { ...@@ -609,7 +609,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
} }
// We need to name the manufacturers metadata manually to store it. // We need to name the manufacturers metadata manually to store it.
const PpdMetadataPathSpecifier options = {PpdMetadataType::MANUFACTURERS, const PpdMetadataPathSpecifier options = {PpdMetadataType::kManufacturers,
metadata_locale_.c_str()}; metadata_locale_.c_str()};
const std::string manufacturers_name = const std::string manufacturers_name =
PpdMetadataPathInServingRoot(options); PpdMetadataPathInServingRoot(options);
...@@ -742,7 +742,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager { ...@@ -742,7 +742,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
base::Optional<std::string> GetPrintersMetadataName( base::Optional<std::string> GetPrintersMetadataName(
base::StringPiece manufacturer) { base::StringPiece manufacturer) {
const PpdMetadataPathSpecifier manufacturers_options = { const PpdMetadataPathSpecifier manufacturers_options = {
PpdMetadataType::MANUFACTURERS, metadata_locale_.c_str()}; PpdMetadataType::kManufacturers, metadata_locale_.c_str()};
const std::string manufacturers_metadata_name = const std::string manufacturers_metadata_name =
PpdMetadataPathInServingRoot(manufacturers_options); PpdMetadataPathInServingRoot(manufacturers_options);
if (!cached_manufacturers_.contains(manufacturers_metadata_name)) { if (!cached_manufacturers_.contains(manufacturers_metadata_name)) {
...@@ -759,7 +759,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager { ...@@ -759,7 +759,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
} }
const PpdMetadataPathSpecifier printers_options = { const PpdMetadataPathSpecifier printers_options = {
PpdMetadataType::PRINTERS, PpdMetadataType::kPrinters,
manufacturers.value.at(manufacturer).c_str()}; manufacturers.value.at(manufacturer).c_str()};
return PpdMetadataPathInServingRoot(printers_options); return PpdMetadataPathInServingRoot(printers_options);
} }
...@@ -864,7 +864,8 @@ class PpdMetadataManagerImpl : public PpdMetadataManager { ...@@ -864,7 +864,8 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
ForwardIndexSearchStatus SearchForwardIndicesForOneEmm() { ForwardIndexSearchStatus SearchForwardIndicesForOneEmm() {
const ForwardIndexSearchContext& context = const ForwardIndexSearchContext& context =
forward_index_search_queue_.CurrentContext(); forward_index_search_queue_.CurrentContext();
const PpdMetadataPathSpecifier options = {PpdMetadataType::INDEX, nullptr, const PpdMetadataPathSpecifier options = {PpdMetadataType::kForwardIndex,
nullptr,
IndexShard(context.CurrentEmm())}; IndexShard(context.CurrentEmm())};
const std::string forward_index_name = const std::string forward_index_name =
PpdMetadataPathInServingRoot(options); PpdMetadataPathInServingRoot(options);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment