summaryrefslogtreecommitdiffstats
path: root/printing/pdf_ps_metafile_linux.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-16 00:29:22 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-16 00:29:22 +0000
commitfbea02332ae95f590c8a84019b582fa35e788a7c (patch)
treeeeff857a083663f3d5556fcff304b5fd05e32eb2 /printing/pdf_ps_metafile_linux.cc
parent0018067c7afbdf516d1845b35a3a245d96910f66 (diff)
downloadchromium_src-fbea02332ae95f590c8a84019b582fa35e788a7c.zip
chromium_src-fbea02332ae95f590c8a84019b582fa35e788a7c.tar.gz
chromium_src-fbea02332ae95f590c8a84019b582fa35e788a7c.tar.bz2
Linux: print page to file rather than using shared memory to send it to the browser.
BUG=9847 adapted from patch by <minyu.huang [at] gmail> Review URL: http://codereview.chromium.org/203062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26308 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/pdf_ps_metafile_linux.cc')
-rw-r--r--printing/pdf_ps_metafile_linux.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/printing/pdf_ps_metafile_linux.cc b/printing/pdf_ps_metafile_linux.cc
index d55795c..d5fe5fb 100644
--- a/printing/pdf_ps_metafile_linux.cc
+++ b/printing/pdf_ps_metafile_linux.cc
@@ -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 @@ bool PdfPsMetafile::GetData(void* dst_buffer, size_t dst_buffer_size) const {
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 @@ bool PdfPsMetafile::SaveTo(const FilePath& filename) const {
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() {