chromium/third_party/blink/public/platform/tracked_child_url_loader_factory_bundle.h

// 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.

#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_TRACKED_CHILD_URL_LOADER_FACTORY_BUNDLE_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_TRACKED_CHILD_URL_LOADER_FACTORY_BUNDLE_H_

#include <stdint.h>

#include <memory>
#include <unordered_map>
#include <utility>

#include "base/memory/weak_ptr.h"
#include "base/task/sequenced_task_runner.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "third_party/blink/public/platform/child_url_loader_factory_bundle.h"
#include "third_party/blink/public/platform/web_common.h"

namespace blink {

// Identifier for a `TrackedChildURLLoaderFactoryBundle` to key entries in the
// list of observers. `ObserverKey` is derived from
// `TrackedChildURLLoaderFactoryBundle*`, used in comparison only, and are
// never deferenced.
ObserverKey;

class HostChildURLLoaderFactoryBundle;

// Holds the internal state of a |TrackedChildURLLoaderFactoryBundle| in a form
// that is safe to pass across sequences.
class BLINK_PLATFORM_EXPORT TrackedChildPendingURLLoaderFactoryBundle
    : public ChildPendingURLLoaderFactoryBundle {};

// This class extends |ChildURLLoaderFactoryBundle| to support a
// host/observer tracking logic. There will be a single
// |HostChildURLLoaderFactoryBundle| owned by |RenderFrameImpl| which lives on
// the main thread, and multiple |TrackedChildURLLoaderFactoryBundle| on the
// worker thread (for Workers) or the main thread (for frames from
// 'window.open()'). Both |Host/TrackedChildURLLoaderFactoryBundle::Clone()| can
// be used to create a tracked bundle to the original host bundle. These two
// classes are required to bring bundles back online in the event of Network
// Service crash.
class BLINK_PLATFORM_EXPORT TrackedChildURLLoaderFactoryBundle final
    : public ChildURLLoaderFactoryBundle {};

// |HostChildURLLoaderFactoryBundle| lives entirely on the main thread, and all
// methods should be invoked on the main thread or through PostTask. See
// comments in |TrackedChildURLLoaderFactoryBundle| for details about the
// tracking logic.
class BLINK_PLATFORM_EXPORT HostChildURLLoaderFactoryBundle final
    : public ChildURLLoaderFactoryBundle {};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_TRACKED_CHILD_URL_LOADER_FACTORY_BUNDLE_H_