diff options
author | Alex Vakulenko <avakulenko@chromium.org> | 2015-02-09 12:53:18 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-02-11 06:00:18 +0000 |
commit | f68bbbc952aa9a71898e4939b5f36187fa564a50 (patch) | |
tree | 3927ffc053db9275a052ba2a370cbae62b5c236a /utils.h | |
parent | 981a9fb68ec5fe56f57b3ecb117a0dc681bf5e83 (diff) |
update_engine: replace std::vector<char> with chromeos::Blob
To make update engine consistent with the rest of platform2 code
replaced std::vector<char> as the container of binary data with
chromeos::Blob.
BUG=None
TEST=`FEATURES=test emerge-link update_engine`
Change-Id: I6385fd2257d15aa24bfa74ac35512c2a06c33012
Reviewed-on: https://chromium-review.googlesource.com/247793
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Diffstat (limited to 'utils.h')
-rw-r--r-- | utils.h | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -18,6 +18,7 @@ #include <base/files/file_path.h> #include <base/posix/eintr_wrapper.h> #include <base/time/time.h> +#include <chromeos/secure_blob.h> #include <glib.h> #include "metrics/metrics_library.h" @@ -63,7 +64,7 @@ const std::string KernelDeviceOfBootDevice(const std::string& boot_device); // Writes the data passed to path. The file at path will be overwritten if it // exists. Returns true on success, false otherwise. -bool WriteFile(const char* path, const char* data, int data_len); +bool WriteFile(const char* path, const void* data, int data_len); // Calls write() or pwrite() repeatedly until all count bytes at buf are // written to fd or an error occurs. Returns true on success. @@ -89,10 +90,10 @@ bool PReadAll(FileDescriptorPtr fd, void* buf, size_t count, off_t offset, // file's content, false otherwise, in which case the state of the output // container is unknown. ReadFileChunk starts reading the file from |offset|; if // |size| is not -1, only up to |size| bytes are read in. -bool ReadFile(const std::string& path, std::vector<char>* out_p); +bool ReadFile(const std::string& path, chromeos::Blob* out_p); bool ReadFile(const std::string& path, std::string* out_p); bool ReadFileChunk(const std::string& path, off_t offset, off_t size, - std::vector<char>* out_p); + chromeos::Blob* out_p); // Invokes |cmd| in a pipe and appends its stdout to the container pointed to by // |out_p|. Returns true upon successfully reading all of the output, false @@ -254,12 +255,12 @@ void ScheduleCrashReporterUpload(); int FuzzInt(int value, unsigned int range); // Log a string in hex to LOG(INFO). Useful for debugging. -void HexDumpArray(const unsigned char* const arr, const size_t length); +void HexDumpArray(const uint8_t* const arr, const size_t length); inline void HexDumpString(const std::string& str) { - HexDumpArray(reinterpret_cast<const unsigned char*>(str.data()), str.size()); + HexDumpArray(reinterpret_cast<const uint8_t*>(str.data()), str.size()); } -inline void HexDumpVector(const std::vector<char>& vect) { - HexDumpArray(reinterpret_cast<const unsigned char*>(&vect[0]), vect.size()); +inline void HexDumpVector(const chromeos::Blob& vect) { + HexDumpArray(vect.data(), vect.size()); } template<typename KeyType, typename ValueType> |