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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_PRINTING_PPD_CACHE_H_
6 #define CHROMEOS_PRINTING_PPD_CACHE_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/files/file_path.h"
12 #include "base/optional.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/printing/printer_configuration.h"
15
16 namespace chromeos {
17 namespace printing {
18
19 // PpdCache manages a cache of locally-stored ppd files. At its core,
20 // it operates like a persistent hash from PpdReference to files. If
skau 2016/10/14 22:10:16 hash? do you mean mapping?
21 // you give the same PpdReference to Find that was previously passed
skau 2016/10/14 22:10:16 typo?
22 // to
23 class CHROMEOS_EXPORT PpdCache {
24 public:
25 // Construction-time optional parameters. These should all have defaults that
26 // are sane.
27 struct Options {
28 // Nothing here yet. We may want to add ttl-style options here eventually
29 // so the cache doesn't grow without bound.
30 };
31
32 // Create and return a Ppdcache that uses cache_dir to store state.
33 static std::unique_ptr<PpdCache> Create(const base::FilePath& cache_base_dir,
34 const Options& options = Options());
35 virtual ~PpdCache() {}
36
37 // Find a PPD that was previously cached with the given reference. Note that
38 // all fields of the reference must be the same, otherwise we'll miss in the
39 // cache and re-run resolution for the PPD.
40 //
41 // If a FilePath is returned, it is guaranteed to remain valid until the next
42 // Store() call.
43 virtual base::Optional<base::FilePath> Find(
44 const Printer::PpdReference& reference) const = 0;
45
46 // Take the contents of a ppd file, store it to the cache, and return the
47 // path to the stored file keyed on reference.
48 //
49 // If a different ppd was previously Stored for the given reference, it
50 // will be replaced.
51 //
52 // On success, the returned FilePath is guaranteed to remain valid until the
53 // next Store* call.
54 virtual base::Optional<base::FilePath> Store(
55 const Printer::PpdReference& reference,
56 const std::string& ppd_contents) = 0;
57 };
58
59 } // namespace printing
60 } // namespace chromeos
61
62 #endif // CHROMEOS_PRINTING_PPD_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698