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..aa94de3921268bf1dfc69e6d7ff357c39a4cc94f |
--- /dev/null |
+++ b/chromeos/printing/ppd_cache.h |
@@ -0,0 +1,59 @@ |
+// 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 "chromeos/printing/printer_configuration.h" |
+ |
+namespace chromeos { |
+namespace printing { |
+ |
+// PPDCache is manages a cache of locally-stored ppd files. |
+class CHROMEOS_EXPORT PPDCache { |
+ public: |
+ struct Options { |
+ // Directory we'll use to do the caching. |
+ ::base::FilePath cache_directory; |
+ }; |
+ |
+ static ::std::unique_ptr<PPDCache> Create(); |
+ static ::std::unique_ptr<PPDCache> Create(const Options& options); |
+ virtual ~PPDCache() {} |
+ |
+ // Return a default set of options that are sane. |
+ static Options Defaults(); |
+ |
+ // Look for a PPD for the given manufacturer/model in the cache, and return it |
+ // if it does exist. Return a null pointer if it does not exist. |
+ virtual std::unique_ptr<Printer::PPDFile> Lookup( |
skau
2016/09/17 00:59:59
When specifying PPDFile, my thought was that it wo
Carlson
2016/10/06 15:56:05
Reworked this based on the discussions we had.
|
+ const ::std::string& manufacturer, |
+ const ::std::string& model) const = 0; |
+ |
+ // Take the contents of a ppd file, store it to the cache, and return a handle |
+ // to the generated PPDFile. If this manufacturer-model tuple already exists, |
+ // the new data will replace it. Returns null on failure-to-store. |
+ // |
+ // On success, the returned PPDFile is guaranteed to be valid until the next |
+ // Store() call. |
+ // |
+ // TODO(justincarlson) -- What guarantees should we provide about consistency |
+ // on failure? Probably we want to guarantee that existing entries are |
+ // unchanged on failure. |
+ virtual std::unique_ptr<Printer::PPDFile> Store( |
+ const ::std::string& manufacturer, |
+ const ::std::string& model, |
+ int64_t time_added_ms, |
+ int64_t last_updated_time_ms, |
+ const ::std::string& compressed_ppd_contents) = 0; |
+}; |
+ |
+} // namespace printing |
+} // namespace chromeos |
+ |
+#endif // CHROMEOS_PRINTING_PPD_CACHE_H_ |