chromium/components/subresource_filter/tools/ruleset_converter/rule_stream.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/subresource_filter/tools/ruleset_converter/rule_stream.h"

#include <memory>
#include <utility>

#include "base/check_op.h"
#include "base/logging.h"
#include "components/subresource_filter/core/common/unindexed_ruleset.h"
#include "components/subresource_filter/tools/rule_parser/rule.h"
#include "components/subresource_filter/tools/rule_parser/rule_parser.h"
#include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h"

namespace subresource_filter {

namespace {

std::string ReadStreamToString(std::istream* input) {}

bool IsTrivialParseError(const RuleParser::ParseError& error) {}

// A helper class used by rule input streams for converting a FilteringRules
// message into a stream.
class ProtobufRuleInputStreamImpl {};

// FilterList streams ---------------------------------------------------------

// Reads rules from a text |file| of the FilterList format.
class FilterListRuleInputStream : public RuleInputStream {};

// Writes rules to |output| in FilterList format.
class FilterListRuleOutputStream : public RuleOutputStream {};

// Protobuf streams ------------------------------------------------------------

// Reads rules from a |file| with a serialized FilteredRules message.
class ProtobufRuleInputStream : public RuleInputStream {};

// Writes rules to |output| as a single url_pattern_index::proto::FilteringRules
// message in binary format.
class ProtobufRuleOutputStream : public RuleOutputStream {};

// UnindexedRuleset streams ----------------------------------------------------

// Reads rules stored in |input| in UnindexedRuleset format.
class UnindexedRulesetRuleInputStream : public RuleInputStream {};

// Writes the rules to |output| in UnindexedRuleset format. Discards CSS rules.
class UnindexedRulesetRuleOutputStream : public RuleOutputStream {};

}  // namespace

// static
std::unique_ptr<RuleInputStream> RuleInputStream::Create(
    std::unique_ptr<std::istream> input,
    RulesetFormat format) {}

// static
std::unique_ptr<RuleOutputStream> RuleOutputStream::Create(
    std::unique_ptr<std::ostream> output,
    RulesetFormat format) {}

// TransferRules helpers and implementation. -----------------------------------

namespace {

// Up to M58 subresource_filter supported only these types.
constexpr int kChrome54To58ElementTypes =;

static_assert;
static_assert;
static_assert;
static_assert;
static_assert;
static_assert;

}  // namespace

bool TransferRules(RuleInputStream* input,
                   RuleOutputStream* url_rules_output,
                   RuleOutputStream* css_rules_output,
                   int chrome_version) {}

bool DeleteUrlRuleOrAmend(url_pattern_index::proto::UrlRule* rule,
                          int lowest_chrome_version) {}

}  // namespace subresource_filter