Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: chromeos/printing/ppd_cache.h

Issue 2343983004: Add PPDProvider barebones implementation and associated cache skeleton. (Closed)
Patch Set: Initial PPDProvider/PPDCache implementation. Also, add associated unittests. This doesn't plumb th… Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/printing/ppd_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/printing/ppd_cache.h
diff --git a/chromeos/printing/ppd_cache.h b/chromeos/printing/ppd_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..77f9d7387fa4fb015b27bcfe5a1efe0f88a176ae
--- /dev/null
+++ b/chromeos/printing/ppd_cache.h
@@ -0,0 +1,57 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_PRINTING_PPD_CACHE_H_
+#define CHROMEOS_PRINTING_PPD_CACHE_H_
+
+#include <memory>
+#include <string>
+
+#include "base/files/file_path.h"
+#include "base/optional.h"
+#include "chromeos/chromeos_export.h"
+#include "chromeos/printing/printer_configuration.h"
+
+namespace chromeos {
+namespace printing {
+
+// PpdCache manages a cache of locally-stored PPD files. At its core, it
+// operates like a persistent hash from PpdReference to files. If you give the
+// same PpdReference to Find() that was previously given to store, you should
+// get the same FilePath back out (unless the previous entry has timed out of
+// the cache). However, changing *any* field in PpdReference will make the
+// previous cache entry invalid. This is the intentional behavior -- we want to
+// re-run the resolution logic if we have new meta-information about a printer.
+class CHROMEOS_EXPORT PpdCache {
+ public:
+ // Create and return a Ppdcache that uses cache_dir to store state.
+ static std::unique_ptr<PpdCache> Create(const base::FilePath& cache_base_dir);
+ virtual ~PpdCache() {}
+
+ // Find a PPD that was previously cached with the given reference. Note that
+ // all fields of the reference must be the same, otherwise we'll miss in the
+ // cache and re-run resolution for the PPD.
+ //
+ // If a FilePath is returned, it is guaranteed to be non-empty and
+ // remain valid until the next Store() call.
+ virtual base::Optional<base::FilePath> Find(
+ const Printer::PpdReference& reference) const = 0;
+
+ // Take the contents of a PPD file, store it to the cache, and return the
+ // path to the stored file keyed on reference.
+ //
+ // If a different PPD was previously Stored for the given reference, it
+ // will be replaced.
+ //
+ // If a FilePath is returned, it is guaranteed to be non-empty and
+ // remain valid until the next Store() call.
+ virtual base::Optional<base::FilePath> Store(
+ const Printer::PpdReference& reference,
+ const std::string& ppd_contents) = 0;
+};
+
+} // namespace printing
+} // namespace chromeos
+
+#endif // CHROMEOS_PRINTING_PPD_CACHE_H_
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/printing/ppd_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698