OLD | NEW |
---|---|
(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 | |
15 namespace chromeos { | |
16 namespace printing { | |
17 | |
18 // 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.
| |
19 // its cache in the directory pointed at by | |
20 // PathService::Get(DIR_PRINTER_DRIVERS_CACHE). | |
21 class CHROMEOS_EXPORT PPDCache { | |
22 public: | |
23 // Construction-time optional parameters. These should all have defaults that | |
24 // are sane. | |
25 struct Options { | |
26 // Nothing here yet. We may want to add ttl-style options | |
27 // here eventually. | |
28 }; | |
29 | |
30 static std::unique_ptr<PPDCache> Create(); | |
31 static std::unique_ptr<PPDCache> Create(const Options& options); | |
32 virtual ~PPDCache() {} | |
33 | |
34 // Look for a cached canonical PPD for the given manufacturer/model in the | |
35 // cache, and return it if it does exist. | |
36 // | |
37 // On success, the returned FilePath is guaranteed to remain valid until the | |
38 // next Store* call. | |
39 virtual base::Optional<base::FilePath> Find( | |
40 const std::string& manufacturer, | |
41 const std::string& model) const = 0; | |
42 | |
43 // Look for a ppd previously cached with this key using AddLocal. Return | |
44 // it if it does exist. | |
45 // | |
46 // On success, the returned FilePath is guaranteed to remain valid until the | |
47 // next Store* call. | |
48 virtual base::Optional<base::FilePath> FindLocal( | |
49 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
| |
50 | |
51 // Take the contents of a ppd file, store it to the cache, and return the | |
52 // path to the stored file. | |
53 // | |
54 // If this manufacturer-model tuple already exists, the new data will replace | |
55 // it. Returns nothing on failure-to-store. On failure, cache contents may | |
56 // be changed, but are guaranteed to remain coherent. It's reasonable to | |
57 // believe that a failure-to-store means something is very wrong in the system | |
58 // (out of disk or similar). | |
59 // | |
60 // On success, the returned FilePath is guaranteed to remain valid until the | |
61 // next Store* call. | |
62 virtual base::Optional<base::FilePath> Store( | |
63 const std::string& manufacturer, | |
64 const std::string& model, | |
65 const std::string& compressed_ppd_contents) = 0; | |
66 | |
67 // Store a manually added ppd with the given key. They key can be any | |
68 // arbitrary string of up to 256 characters. Note that the keyspace for Local | |
69 // PPDs is completely disjoint from the keyspace for manufacturer/model stored | |
70 // PPDs -- one will never clobber the other due to a name collision. | |
71 // | |
72 // Returns nothing on failure-to-store. On failure, cache contents may be | |
73 // changed, but are guaranteed to remain coherent. It's reasonable to believe | |
74 // that a failure-to-store means something is very wrong in the system (out of | |
75 // disk or similar). | |
76 // | |
77 // On success, the returned FilePath is guaranteed to remain valid until the | |
78 // next Store* call. | |
79 virtual base::Optional<base::FilePath> StoreLocal( | |
80 const std::string& key, | |
81 const std::string& compressed_ppd_contents) = 0; | |
82 }; | |
83 | |
84 } // namespace printing | |
85 } // namespace chromeos | |
86 | |
87 #endif // CHROMEOS_PRINTING_PPD_CACHE_H_ | |
OLD | NEW |