Skip to content

Commit 2557f2f

Browse files
committed
Bug 1968644 - Part 2: Intorduce the ClassificationFlags to nsIClassifiedChannel.idl. r=dimi,necko-reviewers,valentin
This newly introduced struct is to easily represent firstPartyClassificationFlags and thirdPartyClassificationFlags. We will use this struct in IPC, so we add the IPC traits implementation in this patch. Differential Revision: https://phabricator.services.mozilla.com/D252842
1 parent 8ed546c commit 2557f2f

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

netwerk/base/nsIClassifiedChannel.idl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55

66
#include "nsISupports.idl"
77

8+
%{C++
9+
namespace mozilla::net {
10+
// This struct is used to hold classification flags for both
11+
// firstPartyClassificationFlags and thirdPartyClassificationFlags.
12+
struct ClassificationFlags {
13+
uint32_t firstPartyFlags;
14+
uint32_t thirdPartyFlags;
15+
};
16+
}
17+
%}
18+
819
/**
920
* nsIClassifiedChannel
1021
*

toolkit/components/url-classifier/URLClassifierIPCUtils.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "ipc/EnumSerializer.h"
1111
#include "nsIUrlClassifierFeature.h"
12+
#include "nsIClassifiedChannel.h"
1213

1314
namespace IPC {
1415

@@ -19,6 +20,28 @@ struct ParamTraits<nsIUrlClassifierFeature::listType>
1920
nsIUrlClassifierFeature::listType::blocklist,
2021
nsIUrlClassifierFeature::listType::entitylist> {};
2122

23+
template <>
24+
struct ParamTraits<mozilla::net::ClassificationFlags> {
25+
static void Write(MessageWriter* aWriter,
26+
const mozilla::net::ClassificationFlags& aParam) {
27+
WriteParam(aWriter, aParam.firstPartyFlags);
28+
WriteParam(aWriter, aParam.thirdPartyFlags);
29+
}
30+
31+
static bool Read(MessageReader* aReader,
32+
mozilla::net::ClassificationFlags* aResult) {
33+
uint32_t firstPartyFlags;
34+
uint32_t thirdPartyFlags;
35+
if (!ReadParam(aReader, &firstPartyFlags) ||
36+
!ReadParam(aReader, &thirdPartyFlags)) {
37+
return false;
38+
}
39+
aResult->firstPartyFlags = firstPartyFlags;
40+
aResult->thirdPartyFlags = thirdPartyFlags;
41+
return true;
42+
}
43+
};
44+
2245
} // namespace IPC
2346

2447
#endif // mozilla_urlclassiferipcutils_h

0 commit comments

Comments
 (0)