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

Side by Side Diff: printing/backend/print_backend_cups.cc

Issue 321223004: Print Preview: Enable tests disabled on ASAN once again. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix test Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 const std::string& printer_name, 158 const std::string& printer_name,
159 PrinterCapsAndDefaults* printer_info) { 159 PrinterCapsAndDefaults* printer_info) {
160 DCHECK(printer_info); 160 DCHECK(printer_info);
161 161
162 VLOG(1) << "CUPS: Getting caps and defaults" 162 VLOG(1) << "CUPS: Getting caps and defaults"
163 << ", printer name: " << printer_name; 163 << ", printer name: " << printer_name;
164 164
165 base::FilePath ppd_path(GetPPD(printer_name.c_str())); 165 base::FilePath ppd_path(GetPPD(printer_name.c_str()));
166 // In some cases CUPS failed to get ppd file. 166 // In some cases CUPS failed to get ppd file.
167 if (ppd_path.empty()) { 167 if (ppd_path.empty()) {
168 LOG(ERROR) << "CUPS: Failed to get PPD" 168 LOG(ERROR) << "CUPS: Failed to get PPD, printer name: " << printer_name;
169 << ", printer name: " << printer_name;
170 return false; 169 return false;
171 } 170 }
172 171
173 std::string content; 172 std::string content;
174 bool res = base::ReadFileToString(ppd_path, &content); 173 bool res = base::ReadFileToString(ppd_path, &content);
175 174
176 base::DeleteFile(ppd_path, false); 175 base::DeleteFile(ppd_path, false);
177 176
178 if (res) { 177 if (res) {
179 printer_info->printer_capabilities.swap(content); 178 printer_info->printer_capabilities.swap(content);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 print_backend_settings->GetInteger(kCUPSEncryption, &encryption); 233 print_backend_settings->GetInteger(kCUPSEncryption, &encryption);
235 } 234 }
236 GURL print_server_url(print_server_url_str.c_str()); 235 GURL print_server_url(print_server_url_str.c_str());
237 return new PrintBackendCUPS(print_server_url, 236 return new PrintBackendCUPS(print_server_url,
238 static_cast<http_encryption_t>(encryption), 237 static_cast<http_encryption_t>(encryption),
239 cups_blocking == kValueTrue); 238 cups_blocking == kValueTrue);
240 } 239 }
241 240
242 int PrintBackendCUPS::GetDests(cups_dest_t** dests) { 241 int PrintBackendCUPS::GetDests(cups_dest_t** dests) {
243 if (print_server_url_.is_empty()) { // Use default (local) print server. 242 if (print_server_url_.is_empty()) { // Use default (local) print server.
243 // GnuTLS has a genuine small memory leak that is easier to annotate
244 // than suppress. See http://crbug.com/176888#c7
245 // In theory any CUPS function can trigger this leak, but in
246 // PrintBackendCUPS, this is the most likely spot.
247 // TODO(earthdok): remove this once the leak is fixed.
248 ANNOTATE_SCOPED_MEMORY_LEAK;
244 return cupsGetDests(dests); 249 return cupsGetDests(dests);
245 } else { 250 } else {
246 HttpConnectionCUPS http(print_server_url_, cups_encryption_); 251 HttpConnectionCUPS http(print_server_url_, cups_encryption_);
247 http.SetBlocking(blocking_); 252 http.SetBlocking(blocking_);
248 return cupsGetDests2(http.http(), dests); 253 return cupsGetDests2(http.http(), dests);
249 } 254 }
250 } 255 }
251 256
252 base::FilePath PrintBackendCUPS::GetPPD(const char* name) { 257 base::FilePath PrintBackendCUPS::GetPPD(const char* name) {
253 // cupsGetPPD returns a filename stored in a static buffer in CUPS. 258 // cupsGetPPD returns a filename stored in a static buffer in CUPS.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 << ", HTTP error: " << http_error; 297 << ", HTTP error: " << http_error;
293 base::DeleteFile(ppd_path, false); 298 base::DeleteFile(ppd_path, false);
294 ppd_path.clear(); 299 ppd_path.clear();
295 } 300 }
296 } 301 }
297 } 302 }
298 return ppd_path; 303 return ppd_path;
299 } 304 }
300 305
301 } // namespace printing 306 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698