diff options
author | gene@google.com <gene@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-16 00:55:39 +0000 |
---|---|---|
committer | gene@google.com <gene@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-16 00:55:39 +0000 |
commit | 9c6ca60304227622dc3de44ec5014ea7188d2cb4 (patch) | |
tree | a7cc0d47e13c3014d97d6918e83785e068422237 /printing | |
parent | cded31b2222c66ffdb2c6292efd78f729e335c91 (diff) | |
download | chromium_src-9c6ca60304227622dc3de44ec5014ea7188d2cb4.zip chromium_src-9c6ca60304227622dc3de44ec5014ea7188d2cb4.tar.gz chromium_src-9c6ca60304227622dc3de44ec5014ea7188d2cb4.tar.bz2 |
Making CUPS calls non-blocking.
BUG=none
TEST=Verify proxy is not blocked on CUPS calls.
Review URL: http://codereview.chromium.org/5846001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69357 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-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 |
3 files changed, 20 insertions, 7 deletions
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. |