log_decoder.cc 829 B

1234567891011121314151617181920212223242526
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/metrics/log_decoder.h"
  5. #include "third_party/protobuf/src/google/protobuf/message_lite.h"
  6. #include "third_party/zlib/google/compression_utils.h"
  7. namespace metrics {
  8. bool DecodeLogData(const std::string& compressed_log_data,
  9. std::string* log_data) {
  10. return compression::GzipUncompress(compressed_log_data, log_data);
  11. }
  12. bool DecodeLogDataToProto(const std::string& compressed_log_data,
  13. google::protobuf::MessageLite* proto) {
  14. std::string log_data;
  15. if (!DecodeLogData(compressed_log_data, &log_data))
  16. return false;
  17. return proto->ParseFromString(log_data);
  18. }
  19. } // namespace metrics