Snap for 12525705 from 28a9db229491d2017c2ab54a3358dc523a43da53 to 25Q2-release
Change-Id: I08a0e29f0a4453d4304f070f7960d499145d94e1
diff --git a/aosp/hardware_android.h b/aosp/hardware_android.h
index d20e8df..cb655c9 100644
--- a/aosp/hardware_android.h
+++ b/aosp/hardware_android.h
@@ -20,7 +20,7 @@
#include <string>
#include <string_view>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <base/time/time.h>
#include "update_engine/common/error_code.h"
diff --git a/aosp/network_selector_android.h b/aosp/network_selector_android.h
index b79d1b3..2a3cb2e 100644
--- a/aosp/network_selector_android.h
+++ b/aosp/network_selector_android.h
@@ -17,7 +17,7 @@
#ifndef UPDATE_ENGINE_AOSP_NETWORK_SELECTOR_ANDROID_H_
#define UPDATE_ENGINE_AOSP_NETWORK_SELECTOR_ANDROID_H_
-#include <base/macros.h>
+#include <android-base/macros.h>
#include "update_engine/common/network_selector_interface.h"
diff --git a/certificate_checker.h b/certificate_checker.h
index 5d0b5ba..0dc61b2 100644
--- a/certificate_checker.h
+++ b/certificate_checker.h
@@ -22,7 +22,7 @@
#include <string>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <gtest/gtest_prod.h> // for FRIEND_TEST
namespace chromeos_update_engine {
diff --git a/common/action.h b/common/action.h
index d32322c..e9b5bd4 100644
--- a/common/action.h
+++ b/common/action.h
@@ -23,7 +23,7 @@
#include <string>
#include <base/logging.h>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include "update_engine/common/action_pipe.h"
#include "update_engine/common/action_processor.h"
diff --git a/common/action_pipe.h b/common/action_pipe.h
index 4c56812..f1498b1 100644
--- a/common/action_pipe.h
+++ b/common/action_pipe.h
@@ -24,7 +24,7 @@
#include <string>
#include <base/logging.h>
-#include <base/macros.h>
+#include <android-base/macros.h>
// The structure of these classes (Action, ActionPipe, ActionProcessor, etc.)
// is based on the KSAction* classes from the Google Update Engine code at
diff --git a/common/action_processor.h b/common/action_processor.h
index 5a4286f..ee7e51c 100644
--- a/common/action_processor.h
+++ b/common/action_processor.h
@@ -21,7 +21,7 @@
#include <memory>
#include <vector>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include "update_engine/common/error_code.h"
diff --git a/common/boot_control_interface.h b/common/boot_control_interface.h
index 2de21a1..045236a 100644
--- a/common/boot_control_interface.h
+++ b/common/boot_control_interface.h
@@ -23,7 +23,7 @@
#include <vector>
#include <base/callback.h>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include "update_engine/common/dynamic_partition_control_interface.h"
#include "update_engine/update_metadata.pb.h"
diff --git a/common/dlcservice_interface.h b/common/dlcservice_interface.h
index 7b57710..a075092 100644
--- a/common/dlcservice_interface.h
+++ b/common/dlcservice_interface.h
@@ -21,7 +21,7 @@
#include <string>
#include <vector>
-#include <base/macros.h>
+#include <android-base/macros.h>
namespace chromeos_update_engine {
diff --git a/common/excluder_interface.h b/common/excluder_interface.h
index 1dfd227..81a0c37 100644
--- a/common/excluder_interface.h
+++ b/common/excluder_interface.h
@@ -20,7 +20,7 @@
#include <memory>
#include <string>
-#include <base/macros.h>
+#include <android-base/macros.h>
namespace chromeos_update_engine {
diff --git a/common/fake_prefs.h b/common/fake_prefs.h
index 721cf24..c87c57c 100644
--- a/common/fake_prefs.h
+++ b/common/fake_prefs.h
@@ -23,7 +23,7 @@
#include <string_view>
#include <vector>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include "update_engine/common/prefs_interface.h"
diff --git a/common/file_fetcher.h b/common/file_fetcher.h
index cc0e880..997d487 100644
--- a/common/file_fetcher.h
+++ b/common/file_fetcher.h
@@ -22,7 +22,7 @@
#include <utility>
#include <base/logging.h>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <brillo/streams/stream.h>
#include "update_engine/common/http_fetcher.h"
diff --git a/common/hash_calculator.h b/common/hash_calculator.h
index 36bfcc8..e0a08e3 100644
--- a/common/hash_calculator.h
+++ b/common/hash_calculator.h
@@ -24,7 +24,7 @@
#include <vector>
#include <base/logging.h>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <brillo/secure_blob.h>
// This class provides a simple wrapper around OpenSSL providing a hash of data
diff --git a/common/http_common.cc b/common/http_common.cc
index c8bac47..f05c594 100644
--- a/common/http_common.cc
+++ b/common/http_common.cc
@@ -20,7 +20,7 @@
#include <cstdlib>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <base/stl_util.h>
namespace chromeos_update_engine {
diff --git a/common/http_fetcher.h b/common/http_fetcher.h
index f32c01d..58ee99e 100644
--- a/common/http_fetcher.h
+++ b/common/http_fetcher.h
@@ -24,7 +24,7 @@
#include <base/callback.h>
#include <base/logging.h>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <brillo/message_loops/message_loop.h>
#include <brillo/secure_blob.h>
@@ -47,7 +47,7 @@
// |proxy_resolver| is the resolver that will be consulted for proxy
// settings. It may be null, in which case direct connections will
// be used. Does not take ownership of the resolver.
- explicit HttpFetcher()
+ HttpFetcher()
: post_data_set_(false),
http_response_code_(0),
delegate_(nullptr),
diff --git a/common/http_fetcher_unittest.cc b/common/http_fetcher_unittest.cc
index b229660..d5b319a 100644
--- a/common/http_fetcher_unittest.cc
+++ b/common/http_fetcher_unittest.cc
@@ -1031,7 +1031,7 @@
unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
- for (size_t c = 0; c < base::size(kRedirectCodes); ++c) {
+ for (size_t c = 0; c < std::size(kRedirectCodes); ++c) {
const string url = base::StringPrintf(
"/redirect/%d/download/%d", kRedirectCodes[c], kMediumLength);
RedirectTest(server.get(), true, url, this->test_.NewLargeFetcher());
@@ -1048,7 +1048,7 @@
string url;
for (int r = 0; r < kDownloadMaxRedirects; r++) {
url += base::StringPrintf("/redirect/%d",
- kRedirectCodes[r % base::size(kRedirectCodes)]);
+ kRedirectCodes[r % std::size(kRedirectCodes)]);
}
url += base::StringPrintf("/download/%d", kMediumLength);
RedirectTest(server.get(), true, url, this->test_.NewLargeFetcher());
@@ -1064,7 +1064,7 @@
string url;
for (int r = 0; r < kDownloadMaxRedirects + 1; r++) {
url += base::StringPrintf("/redirect/%d",
- kRedirectCodes[r % base::size(kRedirectCodes)]);
+ kRedirectCodes[r % std::size(kRedirectCodes)]);
}
url += base::StringPrintf("/download/%d", kMediumLength);
RedirectTest(server.get(), false, url, this->test_.NewLargeFetcher());
diff --git a/common/hwid_override.h b/common/hwid_override.h
index d39b572..438993a 100644
--- a/common/hwid_override.h
+++ b/common/hwid_override.h
@@ -21,7 +21,7 @@
#include <string>
#include <base/files/file_path.h>
-#include <base/macros.h>
+#include <android-base/macros.h>
namespace chromeos_update_engine {
diff --git a/common/network_selector_stub.h b/common/network_selector_stub.h
index b32df91..668a66c 100644
--- a/common/network_selector_stub.h
+++ b/common/network_selector_stub.h
@@ -17,7 +17,7 @@
#ifndef UPDATE_ENGINE_COMMON_NETWORK_SELECTOR_STUB_H_
#define UPDATE_ENGINE_COMMON_NETWORK_SELECTOR_STUB_H_
-#include <base/macros.h>
+#include <android-base/macros.h>
#include "update_engine/common/network_selector_interface.h"
diff --git a/common/prefs_unittest.cc b/common/prefs_unittest.cc
index cef6d44..77c746d 100644
--- a/common/prefs_unittest.cc
+++ b/common/prefs_unittest.cc
@@ -24,7 +24,7 @@
#include <base/files/file_util.h>
#include <base/files/scoped_temp_dir.h>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
#include <gmock/gmock.h>
diff --git a/common/subprocess.cc b/common/subprocess.cc
index 9e53d6d..03ec22a 100644
--- a/common/subprocess.cc
+++ b/common/subprocess.cc
@@ -30,7 +30,6 @@
#include <base/bind.h>
#include <base/logging.h>
#include <base/posix/eintr_wrapper.h>
-#include <base/stl_util.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
#include <brillo/secure_blob.h>
@@ -128,7 +127,7 @@
bytes_read = 0;
bool eof;
bool ok = utils::ReadAll(
- record->stdout_fd, buf, base::size(buf), &bytes_read, &eof);
+ record->stdout_fd, buf, std::size(buf), &bytes_read, &eof);
record->stdout_str.append(buf, bytes_read);
if (!ok || eof) {
// There was either an error or an EOF condition, so we are done watching
diff --git a/common/subprocess.h b/common/subprocess.h
index e59776a..d4edcc9 100644
--- a/common/subprocess.h
+++ b/common/subprocess.h
@@ -27,7 +27,7 @@
#include <base/callback.h>
#include <base/files/file_descriptor_watcher_posix.h>
#include <base/logging.h>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <brillo/asynchronous_signal_handler_interface.h>
#include <brillo/message_loops/message_loop.h>
#ifdef __CHROMEOS__
diff --git a/fake_file_writer.h b/fake_file_writer.h
index 75507ea..68765d8 100644
--- a/fake_file_writer.h
+++ b/fake_file_writer.h
@@ -19,7 +19,7 @@
#include <vector>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <brillo/secure_blob.h>
#include "update_engine/payload_consumer/file_writer.h"
diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc
index b8d11f5..2e5a520 100644
--- a/libcurl_http_fetcher.cc
+++ b/libcurl_http_fetcher.cc
@@ -83,7 +83,7 @@
LibcurlHttpFetcher* fetcher = static_cast<LibcurlHttpFetcher*>(clientp);
// Stop watching the socket before closing it.
- for (size_t t = 0; t < base::size(fetcher->fd_controller_maps_); ++t) {
+ for (size_t t = 0; t < std::size(fetcher->fd_controller_maps_); ++t) {
fetcher->fd_controller_maps_[t].erase(item);
}
@@ -683,7 +683,7 @@
// We should iterate through all file descriptors up to libcurl's fd_max or
// the highest one we're tracking, whichever is larger.
- for (size_t t = 0; t < base::size(fd_controller_maps_); ++t) {
+ for (size_t t = 0; t < std::size(fd_controller_maps_); ++t) {
if (!fd_controller_maps_[t].empty())
fd_max = max(fd_max, fd_controller_maps_[t].rbegin()->first);
}
@@ -701,7 +701,7 @@
is_exc || (FD_ISSET(fd, &fd_write) != 0) // track 1 -- write
};
- for (size_t t = 0; t < base::size(fd_controller_maps_); ++t) {
+ for (size_t t = 0; t < std::size(fd_controller_maps_); ++t) {
bool tracked =
fd_controller_maps_[t].find(fd) != fd_controller_maps_[t].end();
@@ -782,7 +782,7 @@
MessageLoop::current()->CancelTask(timeout_id_);
timeout_id_ = MessageLoop::kTaskIdNull;
- for (size_t t = 0; t < base::size(fd_controller_maps_); ++t) {
+ for (size_t t = 0; t < std::size(fd_controller_maps_); ++t) {
fd_controller_maps_[t].clear();
}
diff --git a/libcurl_http_fetcher.h b/libcurl_http_fetcher.h
index 0e34f9d..b21cdca 100644
--- a/libcurl_http_fetcher.h
+++ b/libcurl_http_fetcher.h
@@ -26,7 +26,7 @@
#include <base/files/file_descriptor_watcher_posix.h>
#include <base/logging.h>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <brillo/message_loops/message_loop.h>
#include "update_engine/certificate_checker.h"
diff --git a/payload_consumer/certificate_parser_android.h b/payload_consumer/certificate_parser_android.h
index ccb9293..e2a3921 100644
--- a/payload_consumer/certificate_parser_android.h
+++ b/payload_consumer/certificate_parser_android.h
@@ -21,7 +21,7 @@
#include <string>
#include <vector>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include "payload_consumer/certificate_parser_interface.h"
diff --git a/payload_consumer/certificate_parser_stub.h b/payload_consumer/certificate_parser_stub.h
index a51c2c6..4f78efe 100644
--- a/payload_consumer/certificate_parser_stub.h
+++ b/payload_consumer/certificate_parser_stub.h
@@ -21,7 +21,7 @@
#include <string>
#include <vector>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include "update_engine/payload_consumer/certificate_parser_interface.h"
diff --git a/payload_consumer/delta_performer_integration_test.cc b/payload_consumer/delta_performer_integration_test.cc
index bffee8d..ffc753a 100644
--- a/payload_consumer/delta_performer_integration_test.cc
+++ b/payload_consumer/delta_performer_integration_test.cc
@@ -20,12 +20,12 @@
#include <sys/mount.h>
#include <algorithm>
+#include <list>
#include <string>
#include <vector>
#include <base/files/file_path.h>
#include <base/files/file_util.h>
-#include <base/stl_util.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
#include <gmock/gmock-matchers.h>
@@ -914,7 +914,7 @@
brillo::Blob updated_kernel_partition;
ASSERT_TRUE(
utils::ReadFile(state->result_kernel->path(), &updated_kernel_partition));
- ASSERT_GE(updated_kernel_partition.size(), base::size(kNewData));
+ ASSERT_GE(updated_kernel_partition.size(), std::size(kNewData));
ASSERT_TRUE(std::equal(std::begin(kNewData),
std::end(kNewData),
updated_kernel_partition.begin()));
diff --git a/payload_consumer/delta_performer_unittest.cc b/payload_consumer/delta_performer_unittest.cc
index 04cfaad..443bef6 100644
--- a/payload_consumer/delta_performer_unittest.cc
+++ b/payload_consumer/delta_performer_unittest.cc
@@ -28,7 +28,6 @@
#include <base/files/file_path.h>
#include <base/files/file_util.h>
#include <base/files/scoped_temp_dir.h>
-#include <base/stl_util.h>
#include <base/strings/string_number_conversions.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
@@ -657,12 +656,12 @@
TEST_F(DeltaPerformerTest, ExtentsToByteStringTest) {
uint64_t test[] = {1, 1, 4, 2, 0, 1};
- static_assert(base::size(test) % 2 == 0, "Array size uneven");
+ static_assert(std::size(test) % 2 == 0, "Array size uneven");
const uint64_t block_size = 4096;
const uint64_t file_length = 4 * block_size - 13;
google::protobuf::RepeatedPtrField<Extent> extents;
- for (size_t i = 0; i < base::size(test); i += 2) {
+ for (size_t i = 0; i < std::size(test); i += 2) {
*(extents.Add()) = ExtentForRange(test[i], test[i + 1]);
}
diff --git a/payload_consumer/install_plan.h b/payload_consumer/install_plan.h
index 097c6ce..04f6667 100644
--- a/payload_consumer/install_plan.h
+++ b/payload_consumer/install_plan.h
@@ -20,7 +20,7 @@
#include <string>
#include <vector>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <brillo/secure_blob.h>
#include "update_engine/common/action.h"
diff --git a/payload_consumer/payload_metadata.h b/payload_consumer/payload_metadata.h
index a38405d..4d2d5b0 100644
--- a/payload_consumer/payload_metadata.h
+++ b/payload_consumer/payload_metadata.h
@@ -22,7 +22,7 @@
#include <string>
#include <vector>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <brillo/secure_blob.h>
#include "update_engine/common/error_code.h"
diff --git a/payload_consumer/postinstall_runner_action.cc b/payload_consumer/postinstall_runner_action.cc
index 4de75aa..aaa8a43 100644
--- a/payload_consumer/postinstall_runner_action.cc
+++ b/payload_consumer/postinstall_runner_action.cc
@@ -30,7 +30,6 @@
#include <base/files/file_path.h>
#include <base/files/file_util.h>
#include <base/logging.h>
-#include <base/stl_util.h>
#include <base/strings/string_split.h>
#include <base/strings/string_util.h>
@@ -327,7 +326,7 @@
bytes_read = 0;
bool eof;
bool ok =
- utils::ReadAll(progress_fd_, buf, base::size(buf), &bytes_read, &eof);
+ utils::ReadAll(progress_fd_, buf, std::size(buf), &bytes_read, &eof);
progress_buffer_.append(buf, bytes_read);
// Process every line.
vector<string> lines = base::SplitString(
diff --git a/payload_consumer/verity_writer_interface.h b/payload_consumer/verity_writer_interface.h
index 3ebe768..fee31ee 100644
--- a/payload_consumer/verity_writer_interface.h
+++ b/payload_consumer/verity_writer_interface.h
@@ -20,7 +20,7 @@
#include <cstdint>
#include <memory>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include "common/utils.h"
#include "payload_consumer/file_descriptor.h"
diff --git a/payload_generator/blob_file_writer.h b/payload_generator/blob_file_writer.h
index bdd4c08..cd33df6 100644
--- a/payload_generator/blob_file_writer.h
+++ b/payload_generator/blob_file_writer.h
@@ -17,7 +17,7 @@
#ifndef UPDATE_ENGINE_PAYLOAD_GENERATOR_BLOB_FILE_WRITER_H_
#define UPDATE_ENGINE_PAYLOAD_GENERATOR_BLOB_FILE_WRITER_H_
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <base/synchronization/lock.h>
#include <brillo/secure_blob.h>
diff --git a/payload_generator/extent_ranges.h b/payload_generator/extent_ranges.h
index bd468a1..61a4167 100644
--- a/payload_generator/extent_ranges.h
+++ b/payload_generator/extent_ranges.h
@@ -20,7 +20,7 @@
#include <set>
#include <vector>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include "update_engine/common/utils.h"
#include "update_engine/payload_generator/extent_utils.h"
diff --git a/payload_generator/extent_ranges_unittest.cc b/payload_generator/extent_ranges_unittest.cc
index 5f36aa3..28a9d93 100644
--- a/payload_generator/extent_ranges_unittest.cc
+++ b/payload_generator/extent_ranges_unittest.cc
@@ -18,11 +18,10 @@
#include <vector>
-#include <base/stl_util.h>
#include <gtest/gtest.h>
-#include "update_engine/payload_generator/extent_utils.h"
#include "update_engine/payload_consumer/payload_constants.h"
+#include "update_engine/payload_generator/extent_utils.h"
using std::vector;
using chromeos_update_engine::operator==;
@@ -53,7 +52,7 @@
}
#define ASSERT_RANGE_EQ(ranges, var) \
- ASSERT_NO_FATAL_FAILURE(ExpectRangeEq(ranges, var, base::size(var), __LINE__))
+ ASSERT_NO_FATAL_FAILURE(ExpectRangeEq(ranges, var, std::size(var), __LINE__))
void ExpectRangesOverlapOrTouch(uint64_t a_start,
uint64_t a_num,
diff --git a/payload_generator/extent_utils.cc b/payload_generator/extent_utils.cc
index 851db8a..d318fd2 100644
--- a/payload_generator/extent_utils.cc
+++ b/payload_generator/extent_utils.cc
@@ -18,11 +18,12 @@
#include <inttypes.h>
+#include <set>
#include <string>
#include <vector>
#include <base/logging.h>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <base/strings/stringprintf.h>
#include "update_engine/payload_consumer/payload_constants.h"
diff --git a/payload_generator/payload_generation_config.cc b/payload_generator/payload_generation_config.cc
index 839960e..20c5e04 100644
--- a/payload_generator/payload_generation_config.cc
+++ b/payload_generator/payload_generation_config.cc
@@ -22,7 +22,6 @@
#include <android-base/parseint.h>
#include <base/logging.h>
-#include <base/strings/string_number_conversions.h>
#include <brillo/strings/string_utils.h>
#include <libsnapshot/cow_format.h>
@@ -176,7 +175,7 @@
}
uint64_t max_size{};
- if (!base::StringToUint64(buf, &max_size)) {
+ if (!android::base::ParseUint<uint64_t>(buf, &max_size)) {
LOG(ERROR) << "Group size for " << group_name << " = " << buf
<< " is not an integer.";
return false;
diff --git a/payload_generator/payload_signer.cc b/payload_generator/payload_signer.cc
index 11e136f..b661a92 100644
--- a/payload_generator/payload_signer.cc
+++ b/payload_generator/payload_signer.cc
@@ -23,8 +23,6 @@
#include <base/logging.h>
#include <base/strings/string_number_conversions.h>
-#include <base/strings/string_split.h>
-#include <base/strings/string_util.h>
#include <brillo/data_encoding.h>
#include <openssl/err.h>
#include <openssl/pem.h>
diff --git a/payload_generator/payload_signer.h b/payload_generator/payload_signer.h
index 9676b71..297a54e 100644
--- a/payload_generator/payload_signer.h
+++ b/payload_generator/payload_signer.h
@@ -20,7 +20,7 @@
#include <string>
#include <vector>
-#include <base/macros.h>
+#include <android-base/macros.h>
#include <brillo/key_value_store.h>
#include <brillo/secure_blob.h>
diff --git a/payload_generator/payload_signer_unittest.cc b/payload_generator/payload_signer_unittest.cc
index 96e4431..ac11fcf 100644
--- a/payload_generator/payload_signer_unittest.cc
+++ b/payload_generator/payload_signer_unittest.cc
@@ -20,7 +20,6 @@
#include <vector>
#include <base/logging.h>
-#include <base/stl_util.h>
#include <gtest/gtest.h>
#include "update_engine/common/hash_calculator.h"
@@ -111,8 +110,8 @@
EXPECT_EQ(1, signatures.signatures_size());
const Signatures::Signature& sig = signatures.signatures(0);
const string& sig_data = sig.data();
- ASSERT_EQ(base::size(kDataSignature), sig_data.size());
- for (size_t i = 0; i < base::size(kDataSignature); i++) {
+ ASSERT_EQ(std::size(kDataSignature), sig_data.size());
+ for (size_t i = 0; i < std::size(kDataSignature); i++) {
EXPECT_EQ(kDataSignature[i], static_cast<uint8_t>(sig_data[i]));
}
}
diff --git a/payload_generator/xz_chromeos.cc b/payload_generator/xz_chromeos.cc
deleted file mode 100644
index 2ff9458..0000000
--- a/payload_generator/xz_chromeos.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-//
-// Copyright (C) 2016 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#include "update_engine/payload_generator/xz.h"
-
-#include <base/logging.h>
-#include <lzma.h>
-
-namespace chromeos_update_engine {
-
-void XzCompressInit() {}
-
-bool XzCompress(const brillo::Blob& in, brillo::Blob* out) {
- out->clear();
- if (in.empty())
- return true;
-
- // Resize the output buffer to get enough memory for writing the compressed
- // data.
- out->resize(lzma_stream_buffer_bound(in.size()));
-
- const uint32_t kLzmaPreset = 6;
- size_t out_pos = 0;
- int rc = lzma_easy_buffer_encode(kLzmaPreset,
- LZMA_CHECK_NONE, // We do not need CRC.
- nullptr,
- in.data(),
- in.size(),
- out->data(),
- &out_pos,
- out->size());
- if (rc != LZMA_OK) {
- LOG(ERROR) << "Failed to compress data to LZMA stream with return code: "
- << rc;
- return false;
- }
- out->resize(out_pos);
- return true;
-}
-
-} // namespace chromeos_update_engine