Backed out changeset 1d9301697aa0 (bug 1887752) for causing failures on browser_all_f...
[gecko.git] / netwerk / ipc / ParentChannelWrapper.cpp
blob3b89e3e38fef5c64795ca1a061a0b0a02f747ef0
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=8 et tw=80 : */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "ParentChannelWrapper.h"
9 #include "mozilla/net/HttpBaseChannel.h"
10 #include "mozilla/net/UrlClassifierCommon.h"
11 #include "mozilla/net/RedirectChannelRegistrar.h"
12 #include "nsIViewSourceChannel.h"
13 #include "nsNetUtil.h"
14 #include "nsQueryObject.h"
15 #include "mozilla/dom/RemoteType.h"
17 namespace mozilla {
18 namespace net {
20 NS_IMPL_ISUPPORTS(ParentChannelWrapper, nsIParentChannel, nsIStreamListener,
21 nsIRequestObserver);
23 void ParentChannelWrapper::Register(uint64_t aRegistrarId) {
24 nsCOMPtr<nsIRedirectChannelRegistrar> registrar =
25 RedirectChannelRegistrar::GetOrCreate();
26 nsCOMPtr<nsIChannel> dummy;
27 MOZ_ALWAYS_SUCCEEDS(
28 NS_LinkRedirectChannels(aRegistrarId, this, getter_AddRefs(dummy)));
30 #ifdef DEBUG
31 // The channel registered with the RedirectChannelRegistrar will be the inner
32 // channel when dealing with view-source loads.
33 if (nsCOMPtr<nsIViewSourceChannel> viewSource = do_QueryInterface(mChannel)) {
34 MOZ_ASSERT(dummy == viewSource->GetInnerChannel());
35 } else {
36 MOZ_ASSERT(dummy == mChannel);
38 #endif
41 ////////////////////////////////////////////////////////////////////////////////
42 // nsIParentChannel
43 ////////////////////////////////////////////////////////////////////////////////
45 NS_IMETHODIMP
46 ParentChannelWrapper::SetParentListener(
47 mozilla::net::ParentChannelListener* listener) {
48 return NS_OK;
51 NS_IMETHODIMP
52 ParentChannelWrapper::SetClassifierMatchedInfo(const nsACString& aList,
53 const nsACString& aProvider,
54 const nsACString& aFullHash) {
55 nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
56 do_QueryInterface(mChannel);
57 if (classifiedChannel) {
58 classifiedChannel->SetMatchedInfo(aList, aProvider, aFullHash);
60 return NS_OK;
63 NS_IMETHODIMP
64 ParentChannelWrapper::SetClassifierMatchedTrackingInfo(
65 const nsACString& aLists, const nsACString& aFullHash) {
66 nsCOMPtr<nsIClassifiedChannel> classifiedChannel =
67 do_QueryInterface(mChannel);
68 if (classifiedChannel) {
69 nsTArray<nsCString> lists, fullhashes;
70 for (const nsACString& token : aLists.Split(',')) {
71 lists.AppendElement(token);
73 for (const nsACString& token : aFullHash.Split(',')) {
74 fullhashes.AppendElement(token);
76 classifiedChannel->SetMatchedTrackingInfo(lists, fullhashes);
78 return NS_OK;
81 NS_IMETHODIMP
82 ParentChannelWrapper::NotifyClassificationFlags(uint32_t aClassificationFlags,
83 bool aIsThirdParty) {
84 UrlClassifierCommon::SetClassificationFlagsHelper(
85 mChannel, aClassificationFlags, aIsThirdParty);
86 return NS_OK;
89 NS_IMETHODIMP
90 ParentChannelWrapper::Delete() { return NS_OK; }
92 NS_IMETHODIMP
93 ParentChannelWrapper::GetRemoteType(nsACString& aRemoteType) {
94 aRemoteType = NOT_REMOTE_TYPE;
95 return NS_OK;
98 } // namespace net
99 } // namespace mozilla
101 #undef LOG