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

Side by Side Diff: chrome/service/cloud_print/print_system_cups.cc

Issue 5846001: Making CUPS calls non-blocking.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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
« no previous file with comments | « no previous file | printing/backend/print_backend_consts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/service/cloud_print/print_system.h" 5 #include "chrome/service/cloud_print/print_system.h"
6 6
7 #include <cups/cups.h> 7 #include <cups/cups.h>
8 #include <dlfcn.h> 8 #include <dlfcn.h>
9 #include <errno.h> 9 #include <errno.h>
10 #include <pthread.h> 10 #include <pthread.h>
(...skipping 13 matching lines...) Expand all
24 #include "base/string_number_conversions.h" 24 #include "base/string_number_conversions.h"
25 #include "base/string_util.h" 25 #include "base/string_util.h"
26 #include "base/task.h" 26 #include "base/task.h"
27 #include "base/values.h" 27 #include "base/values.h"
28 #include "base/utf_string_conversions.h" 28 #include "base/utf_string_conversions.h"
29 #include "chrome/service/cloud_print/cloud_print_consts.h" 29 #include "chrome/service/cloud_print/cloud_print_consts.h"
30 #include "chrome/service/cloud_print/cloud_print_helpers.h" 30 #include "chrome/service/cloud_print/cloud_print_helpers.h"
31 #include "googleurl/src/gurl.h" 31 #include "googleurl/src/gurl.h"
32 #include "printing/backend/cups_helper.h" 32 #include "printing/backend/cups_helper.h"
33 #include "printing/backend/print_backend.h" 33 #include "printing/backend/print_backend.h"
34 #include "printing/backend/print_backend_consts.h"
34 35
35 namespace { 36 namespace {
36 static const char kCUPSPrinterInfoOpt[] = "printer-info"; 37 static const char kCUPSPrinterInfoOpt[] = "printer-info";
37 static const char kCUPSPrinterStateOpt[] = "printer-state"; 38 static const char kCUPSPrinterStateOpt[] = "printer-state";
38 static const char kCUPSPrintServerURLs[] = "print_server_urls"; 39 static const char kCUPSPrintServerURLs[] = "print_server_urls";
39 static const char kCUPSUpdateTimeoutMs[] = "update_timeout_ms"; 40 static const char kCUPSUpdateTimeoutMs[] = "update_timeout_ms";
40 static const char kCUPSPrintBackendServerURL[] = "print_server_url";
41 41
42 // Default port for IPP print servers. 42 // Default port for IPP print servers.
43 static const int kDefaultIPPServerPort = 631; 43 static const int kDefaultIPPServerPort = 631;
44 44
45 // Time interval to check for printer's updates. 45 // Time interval to check for printer's updates.
46 const int kCheckForPrinterUpdatesMs = 6*60*60*1000; 46 const int kCheckForPrinterUpdatesMs = 6*60*60*1000;
47 47
48 // Job update timeput 48 // Job update timeput
49 const int kJobUpdateTimeoutMs = 5000; 49 const int kJobUpdateTimeoutMs = 5000;
50 50
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 if (print_servers_.empty()) 373 if (print_servers_.empty())
374 AddPrintServer(std::string()); 374 AddPrintServer(std::string());
375 } 375 }
376 376
377 void PrintSystemCUPS::AddPrintServer(const std::string& url) { 377 void PrintSystemCUPS::AddPrintServer(const std::string& url) {
378 if (url.empty()) 378 if (url.empty())
379 LOG(WARNING) << "No print server specified. Using default print server."; 379 LOG(WARNING) << "No print server specified. Using default print server.";
380 380
381 // Get Print backend for the specific print server. 381 // Get Print backend for the specific print server.
382 DictionaryValue backend_settings; 382 DictionaryValue backend_settings;
383 backend_settings.SetString(kCUPSPrintBackendServerURL, url); 383 backend_settings.SetString(kCUPSPrintServerURL, url);
384
385 // Make CUPS requests non-blocking.
386 backend_settings.SetString(kCUPSBlocking, kValueFalse);
384 387
385 PrintServerInfoCUPS print_server; 388 PrintServerInfoCUPS print_server;
386 print_server.backend = 389 print_server.backend =
387 printing::PrintBackend::CreateInstance(&backend_settings); 390 printing::PrintBackend::CreateInstance(&backend_settings);
388 print_server.url = GURL(url.c_str()); 391 print_server.url = GURL(url.c_str());
389 392
390 print_servers_.push_back(print_server); 393 print_servers_.push_back(print_server);
391 } 394 }
392 395
393 void PrintSystemCUPS::Init() { 396 void PrintSystemCUPS::Init() {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 return new PrintSystemCUPS(print_system_settings); 618 return new PrintSystemCUPS(print_system_settings);
616 } 619 }
617 620
618 int PrintSystemCUPS::PrintFile(const GURL& url, const char* name, 621 int PrintSystemCUPS::PrintFile(const GURL& url, const char* name,
619 const char* filename, const char* title, 622 const char* filename, const char* title,
620 int num_options, cups_option_t* options) { 623 int num_options, cups_option_t* options) {
621 if (url.is_empty()) { // Use default (local) print server. 624 if (url.is_empty()) { // Use default (local) print server.
622 return cupsPrintFile(name, filename, title, num_options, options); 625 return cupsPrintFile(name, filename, title, num_options, options);
623 } else { 626 } else {
624 printing::HttpConnectionCUPS http(url); 627 printing::HttpConnectionCUPS http(url);
628 http.SetBlocking(false);
625 return cupsPrintFile2(http.http(), name, filename, 629 return cupsPrintFile2(http.http(), name, filename,
626 title, num_options, options); 630 title, num_options, options);
627 } 631 }
628 } 632 }
629 633
630 int PrintSystemCUPS::GetJobs(cups_job_t** jobs, const GURL& url, 634 int PrintSystemCUPS::GetJobs(cups_job_t** jobs, const GURL& url,
631 const char* name, int myjobs, int whichjobs) { 635 const char* name, int myjobs, int whichjobs) {
632 if (url.is_empty()) { // Use default (local) print server. 636 if (url.is_empty()) { // Use default (local) print server.
633 return cupsGetJobs(jobs, name, myjobs, whichjobs); 637 return cupsGetJobs(jobs, name, myjobs, whichjobs);
634 } else { 638 } else {
635 printing::HttpConnectionCUPS http(url); 639 printing::HttpConnectionCUPS http(url);
640 http.SetBlocking(false);
636 return cupsGetJobs2(http.http(), jobs, name, myjobs, whichjobs); 641 return cupsGetJobs2(http.http(), jobs, name, myjobs, whichjobs);
637 } 642 }
638 } 643 }
639 644
640 PlatformJobId PrintSystemCUPS::SpoolPrintJob( 645 PlatformJobId PrintSystemCUPS::SpoolPrintJob(
641 const std::string& print_ticket, 646 const std::string& print_ticket,
642 const FilePath& print_data_file_path, 647 const FilePath& print_data_file_path,
643 const std::string& print_data_mime_type, 648 const std::string& print_data_mime_type,
644 const std::string& printer_name, 649 const std::string& printer_name,
645 const std::string& job_title, 650 const std::string& job_title,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 *short_printer_name = full_printer_name.substr(separator + 1); 731 *short_printer_name = full_printer_name.substr(separator + 1);
727 return &(*it); 732 return &(*it);
728 } 733 }
729 } 734 }
730 735
731 LOG(WARNING) << "Server not found for printer: " << full_printer_name; 736 LOG(WARNING) << "Server not found for printer: " << full_printer_name;
732 return NULL; 737 return NULL;
733 } 738 }
734 739
735 } // namespace cloud_print 740 } // namespace cloud_print
OLDNEW
« no previous file with comments | « no previous file | printing/backend/print_backend_consts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698