Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_PRINTING_PPD_PROVIDER_H_ | 5 #ifndef CHROMEOS_PRINTING_PPD_PROVIDER_H_ |
| 6 #define CHROMEOS_PRINTING_PPD_PROVIDER_H_ | 6 #define CHROMEOS_PRINTING_PPD_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/sequenced_task_runner.h" | |
| 15 #include "chromeos/chromeos_export.h" | 16 #include "chromeos/chromeos_export.h" |
| 16 #include "chromeos/printing/printer_configuration.h" | 17 #include "chromeos/printing/printer_configuration.h" |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 class URLRequestContextGetter; | 20 class URLRequestContextGetter; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace chromeos { | 23 namespace chromeos { |
| 23 namespace printing { | 24 namespace printing { |
| 24 | 25 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 | 69 |
| 69 // hostname of quirks server to query. | 70 // hostname of quirks server to query. |
| 70 std::string quirks_server = "chromeosquirksserver-pa.googleapis.com"; | 71 std::string quirks_server = "chromeosquirksserver-pa.googleapis.com"; |
| 71 | 72 |
| 72 // Maximum size of the contents of a PPD file, in bytes. Trying to use a | 73 // Maximum size of the contents of a PPD file, in bytes. Trying to use a |
| 73 // PPD file bigger than this will cause INTERNAL_ERRORs at resolution time. | 74 // PPD file bigger than this will cause INTERNAL_ERRORs at resolution time. |
| 74 size_t max_ppd_contents_size_ = 100 * 1024; | 75 size_t max_ppd_contents_size_ = 100 * 1024; |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 // Create and return a new PpdProvider with the given cache and options. | 78 // Create and return a new PpdProvider with the given cache and options. |
| 79 // |io_task_runner| is used to run operations that are long latency and should | |
| 80 // not be on the UI thread. References to |url_context_getter| and | |
| 81 // |io_task_runner| are taken. | |
| 78 static std::unique_ptr<PpdProvider> Create( | 82 static std::unique_ptr<PpdProvider> Create( |
| 79 const std::string& api_key, | 83 const std::string& api_key, |
| 80 scoped_refptr<net::URLRequestContextGetter> url_context_getter, | 84 scoped_refptr<net::URLRequestContextGetter> url_context_getter, |
| 85 scoped_refptr<base::SequencedTaskRunner> io_task_runner, | |
| 81 std::unique_ptr<PpdCache> cache, | 86 std::unique_ptr<PpdCache> cache, |
| 82 const Options& options = Options()); | 87 const Options& options = Options()); |
| 83 | 88 |
| 84 virtual ~PpdProvider() {} | 89 virtual ~PpdProvider() {} |
| 85 | 90 |
| 86 // Given a PpdReference, attempt to resolve the PPD for printing. | 91 // Given a PpdReference, attempt to resolve the PPD for printing. |
| 87 // | 92 // |
| 88 // Must be called from a Sequenced Task context (i.e. | 93 // Must be called from a Sequenced Task context (i.e. |
| 89 // base::SequencedTaskRunnerHandle::IsSet() must be true). | 94 // base::SequencedTaskRunnerHandle::IsSet() must be true). |
| 90 // | 95 // |
| 91 // |cb| will only be called after the task invoking Resolve() is finished. | 96 // |cb| will only be called after the task invoking Resolve() is finished. |
| 92 // | 97 // |
| 93 // Only one Resolve() call should be outstanding at a time. | 98 // Only one Resolve() call should be outstanding at a time. |
|
stevenjb
2016/11/14 23:08:39
s/should be/may be/
| |
| 94 virtual void Resolve(const Printer::PpdReference& ppd_reference, | 99 virtual void Resolve(const Printer::PpdReference& ppd_reference, |
| 95 const ResolveCallback& cb) = 0; | 100 const ResolveCallback& cb) = 0; |
| 96 | 101 |
| 97 // Abort any outstanding Resolve() call. After this returns, it is guaranteed | |
| 98 // that no ResolveCallback will be called until the next time Resolve is | |
| 99 // called. It is a nop to call this if no Resolve() is outstanding. | |
| 100 virtual void AbortResolve() = 0; | |
| 101 | |
| 102 // Get all the printer makes and models we can support. | 102 // Get all the printer makes and models we can support. |
| 103 // | 103 // |
| 104 // Must be called from a Sequenced Task context (i.e. | 104 // Must be called from a Sequenced Task context (i.e. |
| 105 // base::SequencedTaskRunnerHandle::IsSet() must be true). | 105 // base::SequencedTaskRunnerHandle::IsSet() must be true). |
| 106 // | 106 // |
| 107 // |cb| will only be called after the task invoking QueryAvailable() is | 107 // |cb| will only be called after the task invoking QueryAvailable() is |
| 108 // finished. | 108 // finished. |
| 109 // | 109 // |
| 110 // Only one QueryAvailable() call should be outstanding at a time. | 110 // Only one QueryAvailable() call should be outstanding at a time. |
|
stevenjb
2016/11/14 23:08:39
s/should be/may be/
Carlson
2016/11/14 23:27:41
Done.
| |
| 111 virtual void QueryAvailable(const QueryAvailableCallback& cb) = 0; | 111 virtual void QueryAvailable(const QueryAvailableCallback& cb) = 0; |
| 112 | 112 |
| 113 // Abort any outstanding QueryAvailable() call. After this returns, it is | |
| 114 // guaranteed that no QueryAvailableCallback will be called until the next | |
| 115 // time QueryAvailable() is called. It is a nop to call this if no | |
| 116 // QueryAvailable() is outstanding. | |
| 117 virtual void AbortQueryAvailable() = 0; | |
| 118 | |
| 119 // Most of the time, the cache is just an invisible backend to the Provider, | 113 // Most of the time, the cache is just an invisible backend to the Provider, |
| 120 // consulted at Resolve time, but in the case of the user doing "Add Printer" | 114 // consulted at Resolve time, but in the case of the user doing "Add Printer" |
| 121 // and "Select PPD" locally, then we get into a state where we want to put | 115 // and "Select PPD" locally, then we get into a state where we want to put |
| 122 // whatever they give us directly into the cache without doing a resolve. | 116 // whatever they give us directly into the cache without doing a resolve. |
| 123 // This hook lets is do that. | 117 // This hook lets is do that. |
| 124 virtual bool CachePpd(const Printer::PpdReference& ppd_reference, | 118 virtual bool CachePpd(const Printer::PpdReference& ppd_reference, |
| 125 const base::FilePath& ppd_path) = 0; | 119 const base::FilePath& ppd_path) = 0; |
| 126 }; | 120 }; |
| 127 | 121 |
| 128 } // namespace printing | 122 } // namespace printing |
| 129 } // namespace chromeos | 123 } // namespace chromeos |
| 130 | 124 |
| 131 #endif // CHROMEOS_PRINTING_PPD_PROVIDER_H_ | 125 #endif // CHROMEOS_PRINTING_PPD_PROVIDER_H_ |
| OLD | NEW |