Chromium Code Reviews| 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..909a39b4b8eee3845ffd1662acfaecd7b0e503c3 |
| --- /dev/null |
| +++ b/chromeos/printing/ppd_cache.h |
| @@ -0,0 +1,87 @@ |
| +// 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" |
| + |
| +namespace chromeos { |
| +namespace printing { |
| + |
| +// PPDCache is manages a cache of locally-stored ppd files. It stores |
|
skau
2016/10/07 16:29:06
typo (is)
Carlson
2016/10/14 19:28:56
Done.
|
| +// its cache in the directory pointed at by |
| +// PathService::Get(DIR_PRINTER_DRIVERS_CACHE). |
| +class CHROMEOS_EXPORT PPDCache { |
| + public: |
| + // Construction-time optional parameters. These should all have defaults that |
| + // are sane. |
| + struct Options { |
| + // Nothing here yet. We may want to add ttl-style options |
| + // here eventually. |
| + }; |
| + |
| + static std::unique_ptr<PPDCache> Create(); |
| + static std::unique_ptr<PPDCache> Create(const Options& options); |
| + virtual ~PPDCache() {} |
| + |
| + // Look for a cached canonical PPD for the given manufacturer/model in the |
| + // cache, and return it if it does exist. |
| + // |
| + // On success, the returned FilePath is guaranteed to remain valid until the |
| + // next Store* call. |
| + virtual base::Optional<base::FilePath> Find( |
| + const std::string& manufacturer, |
| + const std::string& model) const = 0; |
| + |
| + // Look for a ppd previously cached with this key using AddLocal. Return |
| + // it if it does exist. |
| + // |
| + // On success, the returned FilePath is guaranteed to remain valid until the |
| + // next Store* call. |
| + virtual base::Optional<base::FilePath> FindLocal( |
| + const std::string& key) const = 0; |
|
skau
2016/10/07 16:29:06
Would this be the appropriate place to document wh
Carlson
2016/10/14 19:28:56
Obsolete
|
| + |
| + // Take the contents of a ppd file, store it to the cache, and return the |
| + // path to the stored file. |
| + // |
| + // If this manufacturer-model tuple already exists, the new data will replace |
| + // it. Returns nothing on failure-to-store. On failure, cache contents may |
| + // be changed, but are guaranteed to remain coherent. It's reasonable to |
| + // believe that a failure-to-store means something is very wrong in the system |
| + // (out of disk or similar). |
| + // |
| + // On success, the returned FilePath is guaranteed to remain valid until the |
| + // next Store* call. |
| + virtual base::Optional<base::FilePath> Store( |
| + const std::string& manufacturer, |
| + const std::string& model, |
| + const std::string& compressed_ppd_contents) = 0; |
| + |
| + // Store a manually added ppd with the given key. They key can be any |
| + // arbitrary string of up to 256 characters. Note that the keyspace for Local |
| + // PPDs is completely disjoint from the keyspace for manufacturer/model stored |
| + // PPDs -- one will never clobber the other due to a name collision. |
| + // |
| + // Returns nothing on failure-to-store. On failure, cache contents may be |
| + // changed, but are guaranteed to remain coherent. It's reasonable to believe |
| + // that a failure-to-store means something is very wrong in the system (out of |
| + // disk or similar). |
| + // |
| + // On success, the returned FilePath is guaranteed to remain valid until the |
| + // next Store* call. |
| + virtual base::Optional<base::FilePath> StoreLocal( |
| + const std::string& key, |
| + const std::string& compressed_ppd_contents) = 0; |
| +}; |
| + |
| +} // namespace printing |
| +} // namespace chromeos |
| + |
| +#endif // CHROMEOS_PRINTING_PPD_CACHE_H_ |