summaryrefslogtreecommitdiffstats
path: root/chromium/components/metrics/log_decoder.cc
blob: c92e2a6f2af1e0208aec4c25b613e234e136dd57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/metrics/log_decoder.h"

#include "third_party/protobuf/src/google/protobuf/message_lite.h"
#include "third_party/zlib/google/compression_utils.h"

namespace metrics {

bool DecodeLogData(const std::string& compressed_log_data,
                   std::string* log_data) {
  return compression::GzipUncompress(compressed_log_data, log_data);
}

bool DecodeLogDataToProto(const std::string& compressed_log_data,
                          google::protobuf::MessageLite* proto) {
  std::string log_data;
  if (!DecodeLogData(compressed_log_data, &log_data))
    return false;

  return proto->ParseFromString(log_data);
}

}  // namespace metrics