Commit 2c7db6e6 authored by Kalvin Lee's avatar Kalvin Lee Committed by Commit Bot

PpdProvider v3: implement using forward index

This change implements
PpdMetadataManager::FindAllEmmsAvailableInIndex(), which seeks out PPD
PPD information via the forward index metadata for a given list of
effective-make-and-model strings. This is the first method in a series
needed to implement PpdProvider::ResolvePpdReference().

Bug: chromium:888189
Test: chromeos_unittests --gtest_filter='PpdMetadataManagerTest.*'
Change-Id: I465d7fa6589aa519ed80709a2320d8c1ec4b0e74
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2333582Reviewed-by: default avatarLuum Habtemariam <luum@chromium.org>
Commit-Queue: Kalvin Lee <kdlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797876}
parent 4a16aeb6
This diff is collapsed.
......@@ -9,6 +9,7 @@
#include <string>
#include "base/containers/flat_map.h"
#include "base/containers/span.h"
#include "base/optional.h"
#include "base/strings/string_piece.h"
#include "base/time/time.h"
......@@ -37,6 +38,15 @@ class CHROMEOS_EXPORT PpdMetadataManager {
using GetPrintersCallback =
base::OnceCallback<void(bool, const ParsedPrinters&)>;
// Used by FindAllEmmsAvailableInIndex().
// Contains a map
// * whose keys are effective-make-and-model strings (provided by the
// caller) that are available in forward index metadata and
// * whose values contain the corresponding information read from the
// forward index metadata.
using FindAllEmmsAvailableInIndexCallback = base::OnceCallback<void(
const base::flat_map<std::string, ParsedIndexValues>&)>;
// Assumes ownership of |config_cache|.
static std::unique_ptr<PpdMetadataManager> Create(
base::StringPiece browser_locale,
......@@ -78,6 +88,17 @@ class CHROMEOS_EXPORT PpdMetadataManager {
base::TimeDelta age,
GetPrintersCallback cb) = 0;
// Calls |cb| with the subset of strings from |emms| that are
// available in forward index metadata mapped to the corresponding
// values read from forward index metadata.
// * Does not rely on prior call to GetLocale().
// * During operation, operates with metadata no older than |age|.
// * On failure, calls |cb| with an empty map.
virtual void FindAllEmmsAvailableInIndex(
const std::vector<std::string>& emms,
base::TimeDelta age,
FindAllEmmsAvailableInIndexCallback cb) = 0;
// Calls |cb| with the make and model of
// |effective_make_and_model|.
// * On success, the split is performed against metadata no older than
......
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