Chromium Code Reviews| 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 PRINTING_BACKEND_CUPS_CONNECTION_H_ | |
| 6 #define PRINTING_BACKEND_CUPS_CONNECTION_H_ | |
| 7 | |
| 8 #include <cups/cups.h> | |
| 9 | |
| 10 #include <memory> | |
| 11 #include <string> | |
| 12 #include <vector> | |
| 13 | |
| 14 #include "base/macros.h" | |
| 15 #include "base/memory/weak_ptr.h" | |
| 16 #include "printing/backend/cups_deleters.h" | |
| 17 #include "printing/backend/cups_printer.h" | |
| 18 #include "printing/printing_export.h" | |
| 19 #include "url/gurl.h" | |
| 20 | |
| 21 namespace printing { | |
| 22 | |
| 23 // Represents a connection to a CUPS server. | |
| 24 class PRINTING_EXPORT CupsConnection { | |
| 25 public: | |
| 26 CupsConnection(const GURL& print_server_url, | |
| 27 http_encryption_t encryption, | |
| 28 bool blocking); | |
| 29 | |
| 30 CupsConnection(CupsConnection&& connection); | |
| 31 | |
| 32 ~CupsConnection(); | |
| 33 | |
| 34 // Returns a vector of all the printers configure on the CUPS server. | |
| 35 std::vector<CupsPrinter> GetDests(); | |
| 36 | |
| 37 // Returns a printer for |printer_name| from the connected server. | |
| 38 std::unique_ptr<CupsPrinter> GetPrinter(const std::string& printer_name); | |
| 39 | |
| 40 std::string server_name() const; | |
| 41 | |
| 42 int last_error() const; | |
| 43 | |
| 44 private: | |
| 45 class Impl { | |
| 46 public: | |
| 47 explicit Impl(http_t* http); | |
| 48 ~Impl(); | |
| 49 | |
| 50 base::WeakPtr<http_t> GetHttp(); | |
| 51 | |
| 52 private: | |
| 53 std::unique_ptr<http_t, HttpDeleter> cups_http_; | |
| 54 base::WeakPtrFactory<http_t> http_factory_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(Impl); | |
| 57 }; | |
| 58 | |
| 59 // lazily initialize http connection | |
| 60 bool Connect(); | |
| 61 | |
| 62 GURL print_server_url_; | |
| 63 http_encryption_t cups_encryption_; | |
| 64 bool blocking_; | |
| 65 | |
| 66 std::unique_ptr<Impl> impl_; | |
| 67 base::WeakPtr<http_t> cups_http_; | |
|
Lei Zhang
2016/07/19 22:49:17
Since CupsConnection owns |impl_|, as written |Cus
| |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(CupsConnection); | |
| 70 }; | |
| 71 | |
| 72 } // namespace printing | |
| 73 | |
| 74 #endif // PRINTING_BACKEND_CUPS_CONNECTION_H_ | |
| OLD | NEW |