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

Unified Diff: chrome/browser/ui/libgtk2ui/print_dialog_gtk2.cc

Issue 568633002: Extracted MetafilePlayer interface from printing::MetafilePlayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_expose
Patch Set: Thu Sep 11 16:10:13 PDT 2014 Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/libgtk2ui/print_dialog_gtk2.cc
diff --git a/chrome/browser/ui/libgtk2ui/print_dialog_gtk2.cc b/chrome/browser/ui/libgtk2ui/print_dialog_gtk2.cc
index 8f1cdb50ffc83d1b72af38c9bbe6cf98dc9990da..e050372a1954e93c440cd1e3973dd1c589eddb82 100644
--- a/chrome/browser/ui/libgtk2ui/print_dialog_gtk2.cc
+++ b/chrome/browser/ui/libgtk2ui/print_dialog_gtk2.cc
@@ -361,8 +361,8 @@ void PrintDialogGtk2::ShowDialog(
gtk_window_present_with_time(GTK_WINDOW(dialog_), time);
}
-void PrintDialogGtk2::PrintDocument(const printing::Metafile* metafile,
- const base::string16& document_name) {
+void PrintDialogGtk2::PrintDocument(const printing::MetafilePlayer& metafile,
+ const base::string16& document_name) {
// This runs on the print worker thread, does not block the UI thread.
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -370,28 +370,30 @@ void PrintDialogGtk2::PrintDocument(const printing::Metafile* metafile,
// this dialog.
AddRef();
- bool error = false;
- if (!base::CreateTemporaryFile(&path_to_pdf_)) {
- LOG(ERROR) << "Creating temporary file failed";
- error = true;
- }
+ bool success = base::CreateTemporaryFile(&path_to_pdf_);
- if (!error && !metafile->SaveTo(path_to_pdf_)) {
- LOG(ERROR) << "Saving metafile failed";
- base::DeleteFile(path_to_pdf_, false);
- error = true;
+ if (success) {
+ base::File file;
+ file.Initialize(path_to_pdf_,
+ base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
+ success = metafile.SaveTo(&file);
+ file.Close();
+ if (!success)
+ base::DeleteFile(path_to_pdf_, false);
}
- if (error) {
+ if (!success) {
+ LOG(ERROR) << "Saving metafile failed";
// Matches AddRef() above.
Release();
- } else {
- // No errors, continue printing.
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&PrintDialogGtk2::SendDocumentToPrinter, this,
- document_name));
+ return;
}
+
+ // No errors, continue printing.
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&PrintDialogGtk2::SendDocumentToPrinter, this, document_name));
}
void PrintDialogGtk2::AddRefToDialog() {

Powered by Google App Engine
This is Rietveld 408576698