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 "chromeos/printing/printer_configuration.h" | |
13 | |
14 namespace chromeos { | |
15 namespace printing { | |
16 | |
17 // PPDCache is manages a cache of locally-stored ppd files. | |
18 class CHROMEOS_EXPORT PPDCache { | |
19 public: | |
20 struct Options { | |
21 // Directory we'll use to do the caching. | |
22 ::base::FilePath cache_directory; | |
23 }; | |
24 | |
25 static ::std::unique_ptr<PPDCache> Create(); | |
26 static ::std::unique_ptr<PPDCache> Create(const Options& options); | |
27 virtual ~PPDCache() {} | |
28 | |
29 // Return a default set of options that are sane. | |
30 static Options Defaults(); | |
31 | |
32 // Look for a PPD for the given manufacturer/model in the cache, and return it | |
33 // if it does exist. Return a null pointer if it does not exist. | |
34 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.
| |
35 const ::std::string& manufacturer, | |
36 const ::std::string& model) const = 0; | |
37 | |
38 // Take the contents of a ppd file, store it to the cache, and return a handle | |
39 // to the generated PPDFile. If this manufacturer-model tuple already exists, | |
40 // the new data will replace it. Returns null on failure-to-store. | |
41 // | |
42 // On success, the returned PPDFile is guaranteed to be valid until the next | |
43 // Store() call. | |
44 // | |
45 // TODO(justincarlson) -- What guarantees should we provide about consistency | |
46 // on failure? Probably we want to guarantee that existing entries are | |
47 // unchanged on failure. | |
48 virtual std::unique_ptr<Printer::PPDFile> Store( | |
49 const ::std::string& manufacturer, | |
50 const ::std::string& model, | |
51 int64_t time_added_ms, | |
52 int64_t last_updated_time_ms, | |
53 const ::std::string& compressed_ppd_contents) = 0; | |
54 }; | |
55 | |
56 } // namespace printing | |
57 } // namespace chromeos | |
58 | |
59 #endif // CHROMEOS_PRINTING_PPD_CACHE_H_ | |
OLD | NEW |