OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "printing/backend/print_backend.h" | 5 #include "printing/backend/print_backend.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <dlfcn.h> | 9 #include <dlfcn.h> |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } else { | 255 } else { |
256 HttpConnectionCUPS http(print_server_url_); | 256 HttpConnectionCUPS http(print_server_url_); |
257 http.SetBlocking(blocking_); | 257 http.SetBlocking(blocking_); |
258 return cupsGetDests2(http.http(), dests); | 258 return cupsGetDests2(http.http(), dests); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 FilePath PrintBackendCUPS::GetPPD(const char* name) { | 262 FilePath PrintBackendCUPS::GetPPD(const char* name) { |
263 // cupsGetPPD returns a filename stored in a static buffer in CUPS. | 263 // cupsGetPPD returns a filename stored in a static buffer in CUPS. |
264 // Protect this code with lock. | 264 // Protect this code with lock. |
265 static base::Lock ppd_lock; | 265 CR_DEFINE_STATIC_LOCAL(base::Lock, ppd_lock, ()); |
266 base::AutoLock ppd_autolock(ppd_lock); | 266 base::AutoLock ppd_autolock(ppd_lock); |
267 FilePath ppd_path; | 267 FilePath ppd_path; |
268 const char* ppd_file_path = NULL; | 268 const char* ppd_file_path = NULL; |
269 if (print_server_url_.is_empty()) { // Use default (local) print server. | 269 if (print_server_url_.is_empty()) { // Use default (local) print server. |
270 ppd_file_path = cupsGetPPD(name); | 270 ppd_file_path = cupsGetPPD(name); |
271 if (ppd_file_path) | 271 if (ppd_file_path) |
272 ppd_path = FilePath(ppd_file_path); | 272 ppd_path = FilePath(ppd_file_path); |
273 } else { | 273 } else { |
274 // cupsGetPPD2 gets stuck sometimes in an infinite time due to network | 274 // cupsGetPPD2 gets stuck sometimes in an infinite time due to network |
275 // configuration/issues. To prevent that, use non-blocking http connection | 275 // configuration/issues. To prevent that, use non-blocking http connection |
(...skipping 25 matching lines...) Expand all Loading... |
301 << ", HTTP error: " << http_error; | 301 << ", HTTP error: " << http_error; |
302 file_util::Delete(ppd_path, false); | 302 file_util::Delete(ppd_path, false); |
303 ppd_path.clear(); | 303 ppd_path.clear(); |
304 } | 304 } |
305 } | 305 } |
306 } | 306 } |
307 return ppd_path; | 307 return ppd_path; |
308 } | 308 } |
309 | 309 |
310 } // namespace printing | 310 } // namespace printing |
OLD | NEW |