chromium/chrome/browser/devtools/serialize_host_descriptions.cc

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

#include "chrome/browser/devtools/serialize_host_descriptions.h"

#include <map>
#include <string_view>
#include <unordered_set>
#include <utility>

namespace {

// Returns the serialization of |root|. It expects |children[x]| to be the
// vector of child nodes for all descendants |x| of |root|. The serialization
// consists of taking the |representation| value of each node, starting in
// leaves, and injecting children's representations into a list under the
// key |child_key| in the parent's |representation|. This is destructive to the
// representation stored with the nodes (which gets moved out of them).
base::Value Serialize(
    std::string_view child_key,
    base::Value* root,
    const std::map<base::Value*, std::vector<base::Value*>>& children) {}

// Takes a vector of host description and converts it into:
// |children|: a map from a host's representation to representations of its
//             children,
// |roots|: a set of representations of hosts with no parents, and
// |representations|: a vector actually storing all those representations to
//                    which the rest just points.
void CreateDictionaryForest(
    std::vector<HostDescriptionNode> hosts,
    std::map<base::Value*, std::vector<base::Value*>>* children,
    std::unordered_set<base::Value*>* roots,
    base::Value::List* representations) {}

}  // namespace

base::Value::List SerializeHostDescriptions(
    std::vector<HostDescriptionNode> hosts,
    std::string_view child_key) {}