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

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, it
20 // operates like a persistent hash from PpdReference to files. If you give the
21 // same PpdReference to Find() that was previously given to store, you should
22 // get the same FilePath back out (unless the previous entry has timed out of
23 // the cache). However, changing *any* field in PpdReference will make the
24 // previous cache entry invalid. This is the intentional behavior -- we want to
25 // re-run the resolution logic if we have new meta-information about a printer.
26 class CHROMEOS_EXPORT PpdCache {
27 public:
28 // Create and return a Ppdcache that uses cache_dir to store state.
29 static std::unique_ptr<PpdCache> Create(const base::FilePath& cache_base_dir);
30 virtual ~PpdCache() {}
31
32 // Find a PPD that was previously cached with the given reference. Note that
33 // all fields of the reference must be the same, otherwise we'll miss in the
34 // cache and re-run resolution for the PPD.
35 //
36 // If a FilePath is returned, it is guaranteed to be non-empty and
37 // remain valid until the next Store() call.
38 virtual base::Optional<base::FilePath> Find(
39 const Printer::PpdReference& reference) const = 0;
40
41 // Take the contents of a PPD file, store it to the cache, and return the
42 // path to the stored file keyed on reference.
43 //
44 // If a different PPD was previously Stored for the given reference, it
45 // will be replaced.
46 //
47 // On success, the returned FilePath is guaranteed to be non-empty
48 // and remain valid until the next Store* call.
skau 2016/10/21 16:12:56 Store*
Carlson 2016/10/24 17:32:33 Done.
49 virtual base::Optional<base::FilePath> Store(
50 const Printer::PpdReference& reference,
51 const std::string& ppd_contents) = 0;
52 };
53
54 } // namespace printing
55 } // namespace chromeos
56
57 #endif // CHROMEOS_PRINTING_PPD_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698