summaryrefslogtreecommitdiffstats
path: root/base/file_util_posix.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 /base/file_util_posix.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 'base/file_util_posix.cc')
-rw-r--r--base/file_util_posix.cc25
1 files changed, 14 insertions, 11 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index bd18a83..7c212c0 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -513,20 +513,23 @@ int WriteFile(const FilePath& filename, const char* data, int size) {
if (fd < 0)
return -1;
- // Allow for partial writes
+ int rv = WriteFileDescriptor(fd, data, size);
+ HANDLE_EINTR(close(fd));
+ return rv;
+}
+
+int WriteFileDescriptor(const int fd, const char* data, int size) {
+ // Allow for partial writes.
ssize_t bytes_written_total = 0;
- do {
- ssize_t bytes_written_partial =
- HANDLE_EINTR(write(fd, data + bytes_written_total,
- size - bytes_written_total));
- if (bytes_written_partial < 0) {
- HANDLE_EINTR(close(fd));
+ for (ssize_t bytes_written_partial = 0; bytes_written_total < size;
+ bytes_written_total += bytes_written_partial) {
+ bytes_written_partial =
+ HANDLE_EINTR(write(fd, data + bytes_written_total,
+ size - bytes_written_total));
+ if (bytes_written_partial < 0)
return -1;
- }
- bytes_written_total += bytes_written_partial;
- } while (bytes_written_total < size);
+ }
- HANDLE_EINTR(close(fd));
return bytes_written_total;
}