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

Side by Side Diff: printing/backend/cups_connection.h

Issue 2105463002: Create a new print backend for the updated CUPS APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix printing gyp file. Created 4 years, 5 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 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_printer.h"
17 #include "printing/printing_export.h"
18 #include "url/gurl.h"
19
20 namespace printing {
21
22 class HttpDeleter {
23 public:
24 void operator()(http_t* http) const;
25 };
26
27 // Represents a connection to a CUPS server.
28 class PRINTING_EXPORT CupsConnection {
29 public:
30 explicit CupsConnection(const GURL& print_server_url,
Lei Zhang 2016/07/13 01:08:42 Not explicit
skau 2016/07/14 20:43:05 Done.
31 http_encryption_t encryption,
32 bool blocking);
33
34 CupsConnection(CupsConnection&& connection);
35
36 ~CupsConnection();
37
38 // Returns the number of destinations and populates |destinations|.
Lei Zhang 2016/07/13 01:08:42 Comment doesn't match code.
skau 2016/07/14 20:43:05 Done.
39 std::vector<CupsPrinter> GetDests();
40
41 // Returns a printer for |printer_name| from the connected server.
42 CupsPrinter* GetPrinter(const std::string& printer_name);
Lei Zhang 2016/07/13 01:08:42 Caller owns the returned pointer, right? Make it r
skau 2016/07/14 20:43:05 Yes it does. Done.
43
44 std::string server_name() const;
45
46 int last_error() const;
47
48 private:
49 // lazily initialize http connection
50 bool Connect();
51
52 GURL print_server_url_;
53 http_encryption_t cups_encryption_;
54 bool blocking_;
55
56 class Impl {
Lei Zhang 2016/07/13 01:08:42 Put this as the first thing in the private section
skau 2016/07/14 20:43:05 Done.
57 public:
58 explicit Impl(http_t* http);
59 ~Impl();
60
61 base::WeakPtr<http_t> GetHttp();
Lei Zhang 2016/07/13 01:08:42 Can you explain the ownership model? Why do we nee
skau 2016/07/14 20:43:05 CupsConnection owns the http_t so I can make sure
Lei Zhang 2016/07/19 22:49:17 Can you show we where CupsPrinters can outlive Cup
skau 2016/07/20 23:58:22 Per offline discussion, building printers with raw
62
63 private:
64 std::unique_ptr<http_t, HttpDeleter> cups_http_;
65 base::WeakPtrFactory<http_t> http_factory_;
66
67 DISALLOW_COPY_AND_ASSIGN(Impl);
68 };
69
70 std::unique_ptr<Impl> impl_;
71 base::WeakPtr<http_t> cups_http_;
72
73 DISALLOW_COPY_AND_ASSIGN(CupsConnection);
74 };
75
76 } // namespace printing
77
78 #endif // PRINTING_BACKEND_CUPS_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698