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

Unified Diff: chrome/service/cloud_print/print_system.h

Issue 2519002: Redesign cloud printing subsystem layer. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/service/cloud_print/job_status_updater.cc ('k') | chrome/service/cloud_print/print_system_cups.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/service/cloud_print/print_system.h
===================================================================
--- chrome/service/cloud_print/print_system.h (revision 48641)
+++ chrome/service/cloud_print/print_system.h (working copy)
@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_SERVICE_CLOUD_PRINT_PRINTER_INFO_H_
-#define CHROME_SERVICE_CLOUD_PRINT_PRINTER_INFO_H_
+#ifndef CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_
+#define CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_
#include <map>
#include <string>
#include <vector>
#include "base/file_path.h"
+#include "base/ref_counted.h"
// This is the interface for platform-specific code for cloud print
namespace cloud_print {
@@ -70,58 +71,98 @@
}
};
-// Enumerates the list of installed local and network printers.
-void EnumeratePrinters(PrinterList* printer_list);
-// Gets the capabilities and defaults for a specific printer.
-bool GetPrinterCapsAndDefaults(const std::string& printer_name,
- PrinterCapsAndDefaults* printer_info);
-bool ValidatePrintTicket(const std::string& printer_name,
- const std::string& print_ticket_data);
-std::string GenerateProxyId();
-bool SpoolPrintJob(const std::string& print_ticket,
- const FilePath& print_data_file_path,
- const std::string& print_data_mime_type,
- const std::string& printer_name,
- const std::string& job_title,
- PlatformJobId* job_id_ret);
+// PrintSystem class will provide interface for different printing systems
+// (Windows, CUPS) to implement. User will call CreateInstance() to
+// obtain available printing system.
+// Please note, that PrintSystem is not platform specific, but rather
+// print system specific. For example, CUPS is available on both Linux and Mac,
+// but not avaialble on ChromeOS, etc. This design allows us to add more
+// functionality on some platforms, while reusing core (CUPS) functions.
+class PrintSystem : public base::RefCountedThreadSafe<PrintSystem> {
+ public:
+ virtual ~PrintSystem() {}
-bool GetJobDetails(const std::string& printer_name,
- PlatformJobId job_id,
- PrintJobDetails *job_details);
-bool IsValidPrinter(const std::string& printer_name);
+ // Enumerates the list of installed local and network printers.
+ virtual void EnumeratePrinters(PrinterList* printer_list) = 0;
-// A class that watches changes to a printer or a print server.
-// The set of notifications are very coarse-grained (even though the Windows
-// API allows for listening to fine-grained details about a printer, this class
-// does not support that level of fine-grained control.
-class PrinterChangeNotifier {
- public:
- class Delegate {
- public:
- virtual void OnPrinterAdded() = 0;
- virtual void OnPrinterDeleted() = 0;
- virtual void OnPrinterChanged() = 0;
- virtual void OnJobChanged() = 0;
+ // Gets the capabilities and defaults for a specific printer.
+ virtual bool GetPrinterCapsAndDefaults(const std::string& printer_name,
+ PrinterCapsAndDefaults* printer_info) = 0;
+
+ // Returns true if ticket is valid.
+ virtual bool ValidatePrintTicket(const std::string& printer_name,
+ const std::string& print_ticket_data) = 0;
+
+ // Send job to the printer.
+ virtual bool SpoolPrintJob(const std::string& print_ticket,
+ const FilePath& print_data_file_path,
+ const std::string& print_data_mime_type,
+ const std::string& printer_name,
+ const std::string& job_title,
+ PlatformJobId* job_id_ret) = 0;
+
+ // Get details for already spooled job.
+ virtual bool GetJobDetails(const std::string& printer_name,
+ PlatformJobId job_id,
+ PrintJobDetails *job_details) = 0;
+
+ // Returns true if printer_name points to a valid printer.
+ virtual bool IsValidPrinter(const std::string& printer_name) = 0;
+
+ class PrintServerWatcher
+ : public base::RefCountedThreadSafe<PrintServerWatcher> {
+ public:
+ // Callback interface for new printer notifications.
+ class Delegate {
+ public:
+ virtual void OnPrinterAdded() = 0;
+ // TODO(gene): Do we need OnPrinterDeleted notification here?
+ };
+
+ virtual ~PrintServerWatcher() {}
+ virtual bool StartWatching(PrintServerWatcher::Delegate* delegate) = 0;
+ virtual bool StopWatching() = 0;
};
- PrinterChangeNotifier();
- ~PrinterChangeNotifier();
- bool StartWatching(const std::string& printer_name, Delegate* delegate);
- bool StopWatching();
- bool GetCurrentPrinterInfo(PrinterBasicInfo* printer_info);
- private:
- // Internal state maintained by the PrinterChangeNotifier class.
- class NotificationState;
- NotificationState* state_;
- DISALLOW_COPY_AND_ASSIGN(PrinterChangeNotifier);
+
+ class PrinterWatcher : public base::RefCountedThreadSafe<PrinterWatcher> {
+ public:
+ // Callback interface for printer updates notifications.
+ class Delegate {
+ public:
+ virtual void OnPrinterDeleted() = 0;
+ virtual void OnPrinterChanged() = 0;
+ virtual void OnJobChanged() = 0;
+ };
+
+ virtual ~PrinterWatcher() {}
+ virtual bool StartWatching(PrinterWatcher::Delegate* delegate) = 0;
+ virtual bool StopWatching() = 0;
+ virtual bool GetCurrentPrinterInfo(PrinterBasicInfo* printer_info) = 0;
+ };
+
+ // Factory methods to create corresponding watcher. Callee is responsible
+ // for deleting objects. Return NULL if failed.
+ virtual PrintServerWatcher* CreatePrintServerWatcher() = 0;
+ virtual PrinterWatcher* CreatePrinterWatcher(
+ const std::string& printer_name) = 0;
+
+ // Generate unique for proxy.
+ static std::string GenerateProxyId();
+
+ // Call this function to obtain current printing system. Return NULL if no
+ // print system available. Delete returned PrintSystem pointer using delete.
+ static scoped_refptr<PrintSystem> CreateInstance();
};
+
// This typedef is to workaround the issue with certain versions of
// Visual Studio where it gets confused between multiple Delegate
// classes and gives a C2500 error. (I saw this error on the try bots -
// the workaround was not needed for my machine).
-typedef PrinterChangeNotifier::Delegate PrinterChangeNotifierDelegate;
+typedef PrintSystem::PrintServerWatcher::Delegate PrintServerWatcherDelegate;
+typedef PrintSystem::PrinterWatcher::Delegate PrinterWatcherDelegate;
} // namespace cloud_print
-#endif // CHROME_SERVICE_CLOUD_PRINT_PRINTER_INFO_H_
+#endif // CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_
« no previous file with comments | « chrome/service/cloud_print/job_status_updater.cc ('k') | chrome/service/cloud_print/print_system_cups.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698