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

Unified Diff: printing/pdf_ps_metafile_linux.cc

Issue 203062: Linux: print page to file rather than using shared memory to send it to the b... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: style Created 11 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
« no previous file with comments | « printing/pdf_ps_metafile_linux.h ('k') | printing/pdf_ps_metafile_linux_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/pdf_ps_metafile_linux.cc
===================================================================
--- printing/pdf_ps_metafile_linux.cc (revision 26282)
+++ printing/pdf_ps_metafile_linux.cc (working copy)
@@ -16,6 +16,8 @@
#include <map>
+#include "base/eintr_wrapper.h"
+#include "base/file_descriptor_posix.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/singleton.h"
@@ -471,7 +473,7 @@
return true;
}
-bool PdfPsMetafile::SaveTo(const FilePath& filename) const {
+bool PdfPsMetafile::SaveTo(const base::FileDescriptor& fd) const {
// We need to check at least these two members to ensure that either Init()
// has been called to initialize |all_pages_|, or metafile has been closed.
// Passing these two checks also implies that surface_, page_surface_, and
@@ -479,15 +481,21 @@
DCHECK(!context_);
DCHECK(!all_pages_.empty());
- const unsigned int data_size = GetDataSize();
- const unsigned int bytes_written =
- file_util::WriteFile(filename, all_pages_.data(), data_size);
- if (bytes_written != data_size) {
- DLOG(ERROR) << "Failed to save file: " << filename.value();
+ if (fd.fd < 0) {
+ DLOG(ERROR) << "Invalid file descriptor!";
return false;
}
- return true;
+ bool success = true;
+ if (file_util::WriteFileDescriptor(fd.fd, all_pages_.data(),
+ GetDataSize()) < 0) {
+ DLOG(ERROR) << "Failed to save file with fd " << fd.fd;
+ success = false;
+ }
+
+ if (fd.auto_close)
+ HANDLE_EINTR(close(fd.fd));
+ return success;
}
void PdfPsMetafile::CleanUpAll() {
« no previous file with comments | « printing/pdf_ps_metafile_linux.h ('k') | printing/pdf_ps_metafile_linux_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698