diff options
-rw-r--r-- | chrome/service/cloud_print/print_system_cups.cc | 9 | ||||
-rw-r--r-- | printing/backend/print_backend_consts.cc | 4 | ||||
-rw-r--r-- | printing/backend/print_backend_consts.h | 4 | ||||
-rw-r--r-- | printing/backend/print_backend_cups.cc | 19 |
4 files changed, 27 insertions, 9 deletions
diff --git a/chrome/service/cloud_print/print_system_cups.cc b/chrome/service/cloud_print/print_system_cups.cc index 2bd149d..0df7ac6 100644 --- a/chrome/service/cloud_print/print_system_cups.cc +++ b/chrome/service/cloud_print/print_system_cups.cc @@ -31,13 +31,13 @@ #include "googleurl/src/gurl.h" #include "printing/backend/cups_helper.h" #include "printing/backend/print_backend.h" +#include "printing/backend/print_backend_consts.h" namespace { static const char kCUPSPrinterInfoOpt[] = "printer-info"; static const char kCUPSPrinterStateOpt[] = "printer-state"; static const char kCUPSPrintServerURLs[] = "print_server_urls"; static const char kCUPSUpdateTimeoutMs[] = "update_timeout_ms"; -static const char kCUPSPrintBackendServerURL[] = "print_server_url"; // Default port for IPP print servers. static const int kDefaultIPPServerPort = 631; @@ -380,7 +380,10 @@ void PrintSystemCUPS::AddPrintServer(const std::string& url) { // Get Print backend for the specific print server. DictionaryValue backend_settings; - backend_settings.SetString(kCUPSPrintBackendServerURL, url); + backend_settings.SetString(kCUPSPrintServerURL, url); + + // Make CUPS requests non-blocking. + backend_settings.SetString(kCUPSBlocking, kValueFalse); PrintServerInfoCUPS print_server; print_server.backend = @@ -622,6 +625,7 @@ int PrintSystemCUPS::PrintFile(const GURL& url, const char* name, return cupsPrintFile(name, filename, title, num_options, options); } else { printing::HttpConnectionCUPS http(url); + http.SetBlocking(false); return cupsPrintFile2(http.http(), name, filename, title, num_options, options); } @@ -633,6 +637,7 @@ int PrintSystemCUPS::GetJobs(cups_job_t** jobs, const GURL& url, return cupsGetJobs(jobs, name, myjobs, whichjobs); } else { printing::HttpConnectionCUPS http(url); + http.SetBlocking(false); return cupsGetJobs2(http.http(), jobs, name, myjobs, whichjobs); } } diff --git a/printing/backend/print_backend_consts.cc b/printing/backend/print_backend_consts.cc index 77a0020..4891c23 100644 --- a/printing/backend/print_backend_consts.cc +++ b/printing/backend/print_backend_consts.cc @@ -8,3 +8,7 @@ const char kLocationTagName[] = "location"; const char kDriverNameTagName[] = "drivername"; +const char kCUPSPrintServerURL[] = "print_server_url"; +const char kCUPSBlocking[] = "cups_blocking"; +const char kValueTrue[] = "true"; +const char kValueFalse[] = "false"; diff --git a/printing/backend/print_backend_consts.h b/printing/backend/print_backend_consts.h index 003a87d..39555be 100644 --- a/printing/backend/print_backend_consts.h +++ b/printing/backend/print_backend_consts.h @@ -8,5 +8,9 @@ extern const char kLocationTagName[]; extern const char kDriverNameTagName[]; +extern const char kCUPSPrintServerURL[]; +extern const char kCUPSBlocking[]; +extern const char kValueTrue[]; +extern const char kValueFalse[]; #endif // PRINTING_BACKEND_PRINT_BACKEND_CONSTS_H_ diff --git a/printing/backend/print_backend_cups.cc b/printing/backend/print_backend_cups.cc index e75a800..90f2d33 100644 --- a/printing/backend/print_backend_cups.cc +++ b/printing/backend/print_backend_cups.cc @@ -19,6 +19,7 @@ #include "base/values.h" #include "googleurl/src/gurl.h" #include "printing/backend/cups_helper.h" +#include "printing/backend/print_backend_consts.h" #if !defined(OS_MACOSX) GCRY_THREAD_OPTION_PTHREAD_IMPL; @@ -76,11 +77,10 @@ namespace printing { static const char kCUPSPrinterInfoOpt[] = "printer-info"; static const char kCUPSPrinterStateOpt[] = "printer-state"; -static const char kCUPSPrintServerURL[] = "print_server_url"; class PrintBackendCUPS : public PrintBackend { public: - explicit PrintBackendCUPS(const GURL& print_server_url); + PrintBackendCUPS(const GURL& print_server_url, bool blocking); virtual ~PrintBackendCUPS() {} // PrintBackend implementation. @@ -100,10 +100,11 @@ class PrintBackendCUPS : public PrintBackend { FilePath GetPPD(const char* name); GURL print_server_url_; + bool blocking_; }; -PrintBackendCUPS::PrintBackendCUPS(const GURL& print_server_url) - : print_server_url_(print_server_url) { +PrintBackendCUPS::PrintBackendCUPS(const GURL& print_server_url, bool blocking) + : print_server_url_(print_server_url), blocking_(blocking) { } void PrintBackendCUPS::EnumeratePrinters(PrinterList* printer_list) { @@ -194,13 +195,16 @@ scoped_refptr<PrintBackend> PrintBackend::CreateInstance( g_gcrypt_initializer.Get(); #endif - std::string print_server_url_str; + std::string print_server_url_str, cups_blocking; if (print_backend_settings) { print_backend_settings->GetString(kCUPSPrintServerURL, &print_server_url_str); + + print_backend_settings->GetString(kCUPSBlocking, + &cups_blocking); } GURL print_server_url(print_server_url_str.c_str()); - return new PrintBackendCUPS(print_server_url); + return new PrintBackendCUPS(print_server_url, cups_blocking == kValueTrue); } int PrintBackendCUPS::GetDests(cups_dest_t** dests) { @@ -208,6 +212,7 @@ int PrintBackendCUPS::GetDests(cups_dest_t** dests) { return cupsGetDests(dests); } else { HttpConnectionCUPS http(print_server_url_); + http.SetBlocking(blocking_); return cupsGetDests2(http.http(), dests); } } @@ -233,7 +238,7 @@ FilePath PrintBackendCUPS::GetPPD(const char* name) { // To distinguish error case from the normal return, will check result file // size agains content length. HttpConnectionCUPS http(print_server_url_); - http.SetBlocking(false); + http.SetBlocking(blocking_); ppd_file_path = cupsGetPPD2(http.http(), name); // Check if the get full PPD, since non-blocking call may simply return // normally after timeout expired. |