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 {
};
enum class PpdMetadataType {
LOCALES,
MANUFACTURERS, // locale-sensitive
PRINTERS, // locale-sensitive
INDEX,
REVERSE_INDEX, // locale-sensitive
USB_INDEX,
kLocales,
kManufacturers, // locale-sensitive
kPrinters, // locale-sensitive
kForwardIndex,
kReverseIndex, // locale-sensitive
kUsbIndex,
};
// Control argument that fully specifies the basename and containing
......@@ -349,10 +349,10 @@ struct PpdMetadataPathSpecifier {
PpdMetadataType type;
// 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
// 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
// locale (as previously advertised by the serving root).
//
......@@ -361,10 +361,10 @@ struct PpdMetadataPathSpecifier {
const char* optional_tag;
// 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
// 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
// sought.
int optional_shard;
......@@ -376,16 +376,16 @@ struct PpdMetadataPathSpecifier {
std::string PpdMetadataPathInServingRoot(
const PpdMetadataPathSpecifier& options) {
switch (options.type) {
case PpdMetadataType::LOCALES:
case PpdMetadataType::kLocales:
return base::StringPrintf("%s/locales.json", kMetadataParentDirectory);
case PpdMetadataType::MANUFACTURERS:
case PpdMetadataType::kManufacturers:
// This type is locale-sensitive; the tag carries the locale.
DCHECK(!base::StringPiece(options.optional_tag).empty());
return base::StringPrintf("%s/manufacturers-%s.json",
kMetadataParentDirectory, options.optional_tag);
case PpdMetadataType::PRINTERS:
case PpdMetadataType::kPrinters:
// This type is locale-sensitive; in this context, the tag carries
// the full basename, which caller will have extracted from a leaf
// in manufacturers metadata.
......@@ -393,13 +393,13 @@ std::string PpdMetadataPathInServingRoot(
return base::StringPrintf("%s/%s", kMetadataParentDirectory,
options.optional_tag);
case PpdMetadataType::INDEX:
case PpdMetadataType::kForwardIndex:
DCHECK(options.optional_shard >= 0 &&
options.optional_shard < kNumShards);
return base::StringPrintf("%s/index-%02d.json", kMetadataParentDirectory,
options.optional_shard);
case PpdMetadataType::REVERSE_INDEX:
case PpdMetadataType::kReverseIndex:
// This type is locale-sensitive; the tag carries the locale.
DCHECK(!base::StringPiece(options.optional_tag).empty());
DCHECK(options.optional_shard >= 0 &&
......@@ -408,7 +408,7 @@ std::string PpdMetadataPathInServingRoot(
kMetadataParentDirectory, options.optional_tag,
options.optional_shard);
case PpdMetadataType::USB_INDEX:
case PpdMetadataType::kUsbIndex:
DCHECK(options.optional_shard >= 0 &&
options.optional_shard <= kSixteenBitsMaximum);
return base::StringPrintf("%s/usb-%04x.json", kMetadataParentDirectory,
......@@ -455,7 +455,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
return;
}
const PpdMetadataPathSpecifier options = {PpdMetadataType::LOCALES};
const PpdMetadataPathSpecifier options = {PpdMetadataType::kLocales};
const std::string metadata_name = PpdMetadataPathInServingRoot(options);
PrinterConfigCache::FetchCallback fetch_cb =
......@@ -472,7 +472,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!metadata_locale_.empty());
const PpdMetadataPathSpecifier options = {PpdMetadataType::MANUFACTURERS,
const PpdMetadataPathSpecifier options = {PpdMetadataType::kManufacturers,
metadata_locale_.c_str()};
const std::string metadata_name = PpdMetadataPathInServingRoot(options);
......@@ -548,7 +548,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
return;
}
const PpdMetadataPathSpecifier options = {PpdMetadataType::USB_INDEX,
const PpdMetadataPathSpecifier options = {PpdMetadataType::kUsbIndex,
nullptr, vendor_id};
const std::string metadata_name = PpdMetadataPathInServingRoot(options);
......@@ -571,7 +571,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
DCHECK(!metadata_locale_.empty());
const PpdMetadataPathSpecifier reverse_index_options = {
PpdMetadataType::REVERSE_INDEX, metadata_locale_.c_str(),
PpdMetadataType::kReverseIndex, metadata_locale_.c_str(),
IndexShard(effective_make_and_model)};
const std::string metadata_name =
PpdMetadataPathInServingRoot(reverse_index_options);
......@@ -609,7 +609,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
}
// 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()};
const std::string manufacturers_name =
PpdMetadataPathInServingRoot(options);
......@@ -742,7 +742,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
base::Optional<std::string> GetPrintersMetadataName(
base::StringPiece manufacturer) {
const PpdMetadataPathSpecifier manufacturers_options = {
PpdMetadataType::MANUFACTURERS, metadata_locale_.c_str()};
PpdMetadataType::kManufacturers, metadata_locale_.c_str()};
const std::string manufacturers_metadata_name =
PpdMetadataPathInServingRoot(manufacturers_options);
if (!cached_manufacturers_.contains(manufacturers_metadata_name)) {
......@@ -759,7 +759,7 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
}
const PpdMetadataPathSpecifier printers_options = {
PpdMetadataType::PRINTERS,
PpdMetadataType::kPrinters,
manufacturers.value.at(manufacturer).c_str()};
return PpdMetadataPathInServingRoot(printers_options);
}
......@@ -864,7 +864,8 @@ class PpdMetadataManagerImpl : public PpdMetadataManager {
ForwardIndexSearchStatus SearchForwardIndicesForOneEmm() {
const ForwardIndexSearchContext& context =
forward_index_search_queue_.CurrentContext();
const PpdMetadataPathSpecifier options = {PpdMetadataType::INDEX, nullptr,
const PpdMetadataPathSpecifier options = {PpdMetadataType::kForwardIndex,
nullptr,
IndexShard(context.CurrentEmm())};
const std::string forward_index_name =
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