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

Side by Side Diff: chrome/service/cloud_print/print_system.h

Issue 3945003: Move useful printing backend code from chrome/service/cloud_print to printing... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: resolve merge conflict Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_ 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_
6 #define CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_ 6 #define CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/ref_counted.h" 13 #include "base/ref_counted.h"
14 14
15 class DictionaryValue; 15 class DictionaryValue;
16 class FilePath; 16 class FilePath;
17 17
18 namespace printing {
19 class PrintBackend;
20 struct PrinterBasicInfo;
21 }
22
18 // This is the interface for platform-specific code for cloud print 23 // This is the interface for platform-specific code for cloud print
19 namespace cloud_print { 24 namespace cloud_print {
20 25
21 typedef int PlatformJobId; 26 typedef int PlatformJobId;
22 27
23 struct PrinterBasicInfo {
24 PrinterBasicInfo();
25 ~PrinterBasicInfo();
26
27 std::string printer_name;
28 std::string printer_description;
29 int printer_status;
30 std::map<std::string, std::string> options;
31 };
32
33 typedef std::vector<PrinterBasicInfo> PrinterList;
34
35 struct PrinterCapsAndDefaults {
36 std::string printer_capabilities;
37 std::string caps_mime_type;
38 std::string printer_defaults;
39 std::string defaults_mime_type;
40 };
41
42 enum PrintJobStatus { 28 enum PrintJobStatus {
43 PRINT_JOB_STATUS_INVALID, 29 PRINT_JOB_STATUS_INVALID,
44 PRINT_JOB_STATUS_IN_PROGRESS, 30 PRINT_JOB_STATUS_IN_PROGRESS,
45 PRINT_JOB_STATUS_ERROR, 31 PRINT_JOB_STATUS_ERROR,
46 PRINT_JOB_STATUS_COMPLETED 32 PRINT_JOB_STATUS_COMPLETED
47 }; 33 };
48 34
49 struct PrintJobDetails { 35 struct PrintJobDetails {
50 PrintJobDetails(); 36 PrintJobDetails();
51 37
(...skipping 16 matching lines...) Expand all
68 std::string status_message; 54 std::string status_message;
69 int total_pages; 55 int total_pages;
70 int pages_printed; 56 int pages_printed;
71 }; 57 };
72 58
73 // PrintSystem class will provide interface for different printing systems 59 // PrintSystem class will provide interface for different printing systems
74 // (Windows, CUPS) to implement. User will call CreateInstance() to 60 // (Windows, CUPS) to implement. User will call CreateInstance() to
75 // obtain available printing system. 61 // obtain available printing system.
76 // Please note, that PrintSystem is not platform specific, but rather 62 // Please note, that PrintSystem is not platform specific, but rather
77 // print system specific. For example, CUPS is available on both Linux and Mac, 63 // print system specific. For example, CUPS is available on both Linux and Mac,
78 // but not avaialble on ChromeOS, etc. This design allows us to add more 64 // but not available on ChromeOS, etc. This design allows us to add more
79 // functionality on some platforms, while reusing core (CUPS) functions. 65 // functionality on some platforms, while reusing core (CUPS) functions.
80 class PrintSystem : public base::RefCountedThreadSafe<PrintSystem> { 66 class PrintSystem : public base::RefCountedThreadSafe<PrintSystem> {
81 public: 67 public:
82 class PrintServerWatcher 68 class PrintServerWatcher
83 : public base::RefCountedThreadSafe<PrintServerWatcher> { 69 : public base::RefCountedThreadSafe<PrintServerWatcher> {
84 public: 70 public:
85 // Callback interface for new printer notifications. 71 // Callback interface for new printer notifications.
86 class Delegate { 72 class Delegate {
87 public: 73 public:
88 virtual void OnPrinterAdded() = 0; 74 virtual void OnPrinterAdded() = 0;
(...skipping 17 matching lines...) Expand all
106 virtual void OnPrinterChanged() = 0; 92 virtual void OnPrinterChanged() = 0;
107 virtual void OnJobChanged() = 0; 93 virtual void OnJobChanged() = 0;
108 94
109 protected: 95 protected:
110 virtual ~Delegate() {} 96 virtual ~Delegate() {}
111 }; 97 };
112 98
113 virtual ~PrinterWatcher(); 99 virtual ~PrinterWatcher();
114 virtual bool StartWatching(PrinterWatcher::Delegate* delegate) = 0; 100 virtual bool StartWatching(PrinterWatcher::Delegate* delegate) = 0;
115 virtual bool StopWatching() = 0; 101 virtual bool StopWatching() = 0;
116 virtual bool GetCurrentPrinterInfo(PrinterBasicInfo* printer_info) = 0; 102 virtual bool GetCurrentPrinterInfo(
103 printing::PrinterBasicInfo* printer_info) = 0;
117 }; 104 };
118 105
119 class JobSpooler : public base::RefCountedThreadSafe<JobSpooler> { 106 class JobSpooler : public base::RefCountedThreadSafe<JobSpooler> {
120 public: 107 public:
121 // Callback interface for JobSpooler notifications. 108 // Callback interface for JobSpooler notifications.
122 class Delegate { 109 class Delegate {
123 public: 110 public:
124 virtual ~Delegate() { } 111 virtual ~Delegate() { }
125 virtual void OnJobSpoolSucceeded(const PlatformJobId& job_id) = 0; 112 virtual void OnJobSpoolSucceeded(const PlatformJobId& job_id) = 0;
126 virtual void OnJobSpoolFailed() = 0; 113 virtual void OnJobSpoolFailed() = 0;
127 }; 114 };
128 115
129 virtual ~JobSpooler(); 116 virtual ~JobSpooler();
130 // Spool job to the printer asynchronously. Caller will be notified via 117 // Spool job to the printer asynchronously. Caller will be notified via
131 // |delegate|. Note that only one print job can be in progress at any given 118 // |delegate|. Note that only one print job can be in progress at any given
132 // time. Subsequent calls to Spool (before the Delegate::OnJobSpoolSucceeded 119 // time. Subsequent calls to Spool (before the Delegate::OnJobSpoolSucceeded
133 // or Delegate::OnJobSpoolFailed methods are called) can fail. 120 // or Delegate::OnJobSpoolFailed methods are called) can fail.
134 virtual bool Spool(const std::string& print_ticket, 121 virtual bool Spool(const std::string& print_ticket,
135 const FilePath& print_data_file_path, 122 const FilePath& print_data_file_path,
136 const std::string& print_data_mime_type, 123 const std::string& print_data_mime_type,
137 const std::string& printer_name, 124 const std::string& printer_name,
138 const std::string& job_title, 125 const std::string& job_title,
139 JobSpooler::Delegate* delegate) = 0; 126 JobSpooler::Delegate* delegate) = 0;
140 }; 127 };
141 128
142 virtual ~PrintSystem(); 129 virtual ~PrintSystem();
143 130
144 // Enumerates the list of installed local and network printers. 131 // Get the printing backend.
145 virtual void EnumeratePrinters(PrinterList* printer_list) = 0; 132 virtual printing::PrintBackend* GetPrintBackend() = 0;
146
147 // Gets the capabilities and defaults for a specific printer.
148 virtual bool GetPrinterCapsAndDefaults(const std::string& printer_name,
149 PrinterCapsAndDefaults* printer_info) = 0;
150 133
151 // Returns true if ticket is valid. 134 // Returns true if ticket is valid.
152 virtual bool ValidatePrintTicket(const std::string& printer_name, 135 virtual bool ValidatePrintTicket(const std::string& printer_name,
153 const std::string& print_ticket_data) = 0; 136 const std::string& print_ticket_data) = 0;
154 137
155 // Get details for already spooled job. 138 // Get details for already spooled job.
156 virtual bool GetJobDetails(const std::string& printer_name, 139 virtual bool GetJobDetails(const std::string& printer_name,
157 PlatformJobId job_id, 140 PlatformJobId job_id,
158 PrintJobDetails *job_details) = 0; 141 PrintJobDetails *job_details) = 0;
159 142
160 // Returns true if printer_name points to a valid printer.
161 virtual bool IsValidPrinter(const std::string& printer_name) = 0;
162
163 // Factory methods to create corresponding watcher. Callee is responsible 143 // Factory methods to create corresponding watcher. Callee is responsible
164 // for deleting objects. Return NULL if failed. 144 // for deleting objects. Return NULL if failed.
165 virtual PrintServerWatcher* CreatePrintServerWatcher() = 0; 145 virtual PrintServerWatcher* CreatePrintServerWatcher() = 0;
166 virtual PrinterWatcher* CreatePrinterWatcher( 146 virtual PrinterWatcher* CreatePrinterWatcher(
167 const std::string& printer_name) = 0; 147 const std::string& printer_name) = 0;
168 virtual JobSpooler* CreateJobSpooler() = 0; 148 virtual JobSpooler* CreateJobSpooler() = 0;
169 149
170 // Generate unique for proxy. 150 // Generate unique for proxy.
171 static std::string GenerateProxyId(); 151 static std::string GenerateProxyId();
172 152
173 // Call this function to obtain printing system for specified print server. 153 // Call this function to obtain printing system for specified print server.
174 // If print settings are NULL, default settings will be used. 154 // If print settings are NULL, default settings will be used.
175 // Return NULL if no print system available. 155 // Return NULL if no print system available.
176 static scoped_refptr<PrintSystem> CreateInstance( 156 static scoped_refptr<PrintSystem> CreateInstance(
177 const DictionaryValue* print_system_settings); 157 const DictionaryValue* print_system_settings);
178 }; 158 };
179 159
180 160
181 // This typedef is to workaround the issue with certain versions of 161 // This typedef is to workaround the issue with certain versions of
182 // Visual Studio where it gets confused between multiple Delegate 162 // Visual Studio where it gets confused between multiple Delegate
183 // classes and gives a C2500 error. (I saw this error on the try bots - 163 // classes and gives a C2500 error. (I saw this error on the try bots -
184 // the workaround was not needed for my machine). 164 // the workaround was not needed for my machine).
185 typedef PrintSystem::PrintServerWatcher::Delegate PrintServerWatcherDelegate; 165 typedef PrintSystem::PrintServerWatcher::Delegate PrintServerWatcherDelegate;
186 typedef PrintSystem::PrinterWatcher::Delegate PrinterWatcherDelegate; 166 typedef PrintSystem::PrinterWatcher::Delegate PrinterWatcherDelegate;
187 typedef PrintSystem::JobSpooler::Delegate JobSpoolerDelegate; 167 typedef PrintSystem::JobSpooler::Delegate JobSpoolerDelegate;
188 168
189 } // namespace cloud_print 169 } // namespace cloud_print
190 170
191 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_ 171 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_proxy_backend.cc ('k') | chrome/service/cloud_print/print_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698