diff options
author | chirantan <chirantan@chromium.org> | 2014-10-07 16:15:30 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-07 23:15:48 +0000 |
commit | 75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e (patch) | |
tree | 45416a4fcb4d264015b23e835e39ee1dab82c722 /components/metrics | |
parent | b247579e8a2339c59884aa4b5ef3dcb00d9aa9f8 (diff) | |
download | chromium_src-75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e.zip chromium_src-75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e.tar.gz chromium_src-75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e.tar.bz2 |
Refactor AppendToFile and WriteFileDescriptor
- Unify the behavior of the windows and posix implementations of these
functions.
- Simplify the interface by having them just indicate success or failure
instead of making callers deal with partial writes.
BUG=418837
Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
Review URL: https://codereview.chromium.org/614893004
Cr-Commit-Position: refs/heads/master@{#298604}
Diffstat (limited to 'components/metrics')
-rw-r--r-- | components/metrics/serialization/serialization_utils.cc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/components/metrics/serialization/serialization_utils.cc b/components/metrics/serialization/serialization_utils.cc index 0eca24b..30c2675 100644 --- a/components/metrics/serialization/serialization_utils.cc +++ b/components/metrics/serialization/serialization_utils.cc @@ -196,17 +196,16 @@ bool SerializationUtils::WriteMetricToFile(const MetricSample& sample, // The file containing the metrics samples will only be read by programs on // the same device so we do not check endianness. - if (base::WriteFileDescriptor(file_descriptor.get(), - reinterpret_cast<char*>(&size), - sizeof(size)) != sizeof(size)) { - DLOG(ERROR) << "error writing message length " << errno; + if (!base::WriteFileDescriptor(file_descriptor.get(), + reinterpret_cast<char*>(&size), + sizeof(size))) { + DPLOG(ERROR) << "error writing message length"; return false; } - if (base::WriteFileDescriptor( - file_descriptor.get(), msg.c_str(), msg.length()) != - static_cast<int>(msg.length())) { - DLOG(ERROR) << "error writing message" << errno; + if (!base::WriteFileDescriptor( + file_descriptor.get(), msg.c_str(), msg.size())) { + DPLOG(ERROR) << "error writing message"; return false; } |