2019-01-24 00:07:08 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_ChildProcessChannelListener_h
|
|
|
|
#define mozilla_dom_ChildProcessChannelListener_h
|
|
|
|
|
|
|
|
#include <functional>
|
2019-11-29 18:14:07 +03:00
|
|
|
|
|
|
|
#include "mozilla/net/NeckoChannelParams.h"
|
2019-01-24 00:07:08 +03:00
|
|
|
#include "nsDataHashtable.h"
|
2019-12-20 02:56:55 +03:00
|
|
|
#include "nsIChildChannel.h"
|
2019-01-24 00:07:08 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2019-11-29 18:14:07 +03:00
|
|
|
class ChildProcessChannelListener final {
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(ChildProcessChannelListener)
|
|
|
|
|
2019-11-28 09:09:54 +03:00
|
|
|
using Callback = std::function<void(
|
2019-12-20 02:56:55 +03:00
|
|
|
nsIChildChannel*, nsTArray<net::DocumentChannelRedirect>&&, uint32_t)>;
|
2019-01-24 00:07:08 +03:00
|
|
|
|
|
|
|
void RegisterCallback(uint64_t aIdentifier, Callback&& aCallback);
|
|
|
|
|
2019-12-20 02:56:55 +03:00
|
|
|
void OnChannelReady(nsIChildChannel* aChannel, uint64_t aIdentifier,
|
2019-12-12 05:32:29 +03:00
|
|
|
nsTArray<net::DocumentChannelRedirect>&& aRedirects,
|
|
|
|
uint32_t aLoadStateLoadFlags);
|
2019-11-29 18:14:07 +03:00
|
|
|
|
2019-01-24 00:07:08 +03:00
|
|
|
static already_AddRefed<ChildProcessChannelListener> GetSingleton();
|
|
|
|
|
|
|
|
private:
|
2019-11-29 18:14:07 +03:00
|
|
|
ChildProcessChannelListener() = default;
|
|
|
|
~ChildProcessChannelListener() = default;
|
|
|
|
struct CallbackArgs {
|
2019-12-20 02:56:55 +03:00
|
|
|
nsCOMPtr<nsIChildChannel> mChannel;
|
2019-11-29 18:14:07 +03:00
|
|
|
nsTArray<net::DocumentChannelRedirect> mRedirects;
|
2019-12-12 05:32:29 +03:00
|
|
|
uint32_t mLoadStateLoadFlags;
|
2019-11-29 18:14:07 +03:00
|
|
|
};
|
2019-01-24 00:07:08 +03:00
|
|
|
|
2019-11-28 09:09:54 +03:00
|
|
|
// TODO Backtrack.
|
2019-01-24 00:07:08 +03:00
|
|
|
nsDataHashtable<nsUint64HashKey, Callback> mCallbacks;
|
2019-11-28 09:09:54 +03:00
|
|
|
nsDataHashtable<nsUint64HashKey, CallbackArgs> mChannelArgs;
|
2019-01-24 00:07:08 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // !defined(mozilla_dom_ChildProcessChannelListener_h)
|