1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "SocketProcessChild.h"
#include "SocketProcessLogging.h"
#include "base/task.h"
#include "InputChannelThrottleQueueChild.h"
#include "HttpInfo.h"
#include "HttpTransactionChild.h"
#include "HttpConnectionMgrChild.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/MemoryReportRequest.h"
#include "mozilla/ipc/CrashReporterClient.h"
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/BackgroundParent.h"
#include "mozilla/ipc/FileDescriptorSetChild.h"
#include "mozilla/ipc/IPCStreamAlloc.h"
#include "mozilla/ipc/ProcessChild.h"
#include "mozilla/net/AltSvcTransactionChild.h"
#include "mozilla/net/BackgroundDataBridgeParent.h"
#include "mozilla/net/DNSRequestChild.h"
#include "mozilla/net/DNSRequestParent.h"
#include "mozilla/net/NativeDNSResolverOverrideChild.h"
#include "mozilla/net/TRRServiceChild.h"
#include "mozilla/ipc/PChildToParentStreamChild.h"
#include "mozilla/ipc/PParentToChildStreamChild.h"
#include "mozilla/Preferences.h"
#include "mozilla/RemoteLazyInputStreamChild.h"
#include "mozilla/Telemetry.h"
#include "nsDebugImpl.h"
#include "nsHttpConnectionInfo.h"
#include "nsHttpHandler.h"
#include "nsIDNSService.h"
#include "nsIHttpActivityObserver.h"
#include "nsNetUtil.h"
#include "nsNSSComponent.h"
#include "nsSocketTransportService2.h"
#include "nsThreadManager.h"
#include "ProcessUtils.h"
#include "SocketProcessBridgeParent.h"
#if defined(XP_WIN)
# include <process.h>
#else
# include <unistd.h>
#endif
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
# include "mozilla/Sandbox.h"
#endif
#ifdef MOZ_GECKO_PROFILER
# include "ChildProfilerController.h"
#endif
#ifdef MOZ_WEBRTC
# include "mozilla/net/WebrtcTCPSocketChild.h"
#endif
namespace mozilla {
namespace net {
using namespace ipc;
SocketProcessChild* sSocketProcessChild;
SocketProcessChild::SocketProcessChild()
: mShuttingDown(false), mMutex("SocketProcessChild::mMutex") {
LOG(("CONSTRUCT SocketProcessChild::SocketProcessChild\n"));
nsDebugImpl::SetMultiprocessMode("Socket");
MOZ_COUNT_CTOR(SocketProcessChild);
sSocketProcessChild = this;
}
SocketProcessChild::~SocketProcessChild() {
LOG(("DESTRUCT SocketProcessChild::SocketProcessChild\n"));
MOZ_COUNT_DTOR(SocketProcessChild);
sSocketProcessChild = nullptr;
}
/* static */
SocketProcessChild* SocketProcessChild::GetSingleton() {
return sSocketProcessChild;
}
#if defined(XP_MACOSX)
extern "C" {
void CGSShutdownServerConnections();
};
#endif
bool SocketProcessChild::Init(base::ProcessId aParentPid,
const char* aParentBuildID, MessageLoop* aIOLoop,
UniquePtr<IPC::Channel> aChannel) {
if (NS_WARN_IF(NS_FAILED(nsThreadManager::get().Init()))) {
return false;
}
if (NS_WARN_IF(!Open(std::move(aChannel), aParentPid, aIOLoop))) {
return false;
}
// This must be sent before any IPDL message, which may hit sentinel
// errors due to parent and content processes having different
// versions.
MessageChannel* channel = GetIPCChannel();
if (channel && !channel->SendBuildIDsMatchMessage(aParentBuildID)) {
// We need to quit this process if the buildID doesn't match the parent's.
// This can occur when an update occurred in the background.
ProcessChild::QuickExit();
}
// Init crash reporter support.
CrashReporterClient::InitSingleton(this);
if (NS_FAILED(NS_InitMinimalXPCOM())) {
return false;
}
BackgroundChild::Startup();
SetThisProcessName("Socket Process");
#if defined(XP_MACOSX)
// Close all current connections to the WindowServer. This ensures that the
// Activity Monitor will not label the socket process as "Not responding"
// because it's not running a native event loop. See bug 1384336.
CGSShutdownServerConnections();
#endif // XP_MACOSX
nsresult rv;
nsCOMPtr<nsIIOService> ios = do_GetIOService(&rv);
if (NS_FAILED(rv)) {
return false;
}
nsCOMPtr<nsIProtocolHandler> handler;
rv = ios->GetProtocolHandler("http", getter_AddRefs(handler));
if (NS_FAILED(rv)) {
return false;
}
// Initialize DNS Service here, since it needs to be done in main thread.
nsCOMPtr<nsIDNSService> dns =
do_GetService("@mozilla.org/network/dns-service;1", &rv);
if (NS_FAILED(rv)) {
return false;
}
return true;
}
void SocketProcessChild::ActorDestroy(ActorDestroyReason aWhy) {
LOG(("SocketProcessChild::ActorDestroy\n"));
mShuttingDown = true;
if (AbnormalShutdown == aWhy) {
NS_WARNING("Shutting down Socket process early due to a crash!");
ProcessChild::QuickExit();
}
#ifdef MOZ_GECKO_PROFILER
if (mProfilerController) {
mProfilerController->Shutdown();
mProfilerController = nullptr;
}
#endif
CrashReporterClient::DestroySingleton();
XRE_ShutdownChildProcess();
}
void SocketProcessChild::CleanUp() {
LOG(("SocketProcessChild::CleanUp\n"));
for (auto iter = mSocketProcessBridgeParentMap.Iter(); !iter.Done();
iter.Next()) {
if (!iter.Data()->Closed()) {
iter.Data()->Close();
}
}
{
MutexAutoLock lock(mMutex);
mBackgroundDataBridgeMap.Clear();
}
NS_ShutdownXPCOM(nullptr);
}
mozilla::ipc::IPCResult SocketProcessChild::RecvInit(
const SocketPorcessInitAttributes& aAttributes) {
Unused << RecvSetOffline(aAttributes.mOffline());
Unused << RecvSetConnectivity(aAttributes.mConnectivity());
if (aAttributes.mInitSandbox()) {
Unused << RecvInitLinuxSandbox(aAttributes.mSandboxBroker());
}
return IPC_OK();
}
IPCResult SocketProcessChild::RecvPreferenceUpdate(const Pref& aPref) {
Preferences::SetPreference(aPref);
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvRequestMemoryReport(
const uint32_t& aGeneration, const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const Maybe<ipc::FileDescriptor>& aDMDFile,
const RequestMemoryReportResolver& aResolver) {
nsPrintfCString processName("Socket (pid %u)", (unsigned)getpid());
mozilla::dom::MemoryReportRequestClient::Start(
aGeneration, aAnonymize, aMinimizeMemoryUsage, aDMDFile, processName,
[&](const MemoryReport& aReport) {
Unused << GetSingleton()->SendAddMemoryReport(aReport);
},
aResolver);
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvSetOffline(
const bool& aOffline) {
LOG(("SocketProcessChild::RecvSetOffline aOffline=%d\n", aOffline));
nsCOMPtr<nsIIOService> io(do_GetIOService());
NS_ASSERTION(io, "IO Service can not be null");
io->SetOffline(aOffline);
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvSetConnectivity(
const bool& aConnectivity) {
nsCOMPtr<nsIIOService> io(do_GetIOService());
nsCOMPtr<nsIIOServiceInternal> ioInternal(do_QueryInterface(io));
NS_ASSERTION(ioInternal, "IO Service can not be null");
ioInternal->SetConnectivity(aConnectivity);
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvInitLinuxSandbox(
const Maybe<ipc::FileDescriptor>& aBrokerFd) {
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
int fd = -1;
if (aBrokerFd.isSome()) {
fd = aBrokerFd.value().ClonePlatformHandle().release();
}
SetSocketProcessSandbox(fd);
#endif // XP_LINUX && MOZ_SANDBOX
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvInitSocketProcessBridgeParent(
const ProcessId& aContentProcessId,
Endpoint<mozilla::net::PSocketProcessBridgeParent>&& aEndpoint) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mSocketProcessBridgeParentMap.Get(aContentProcessId, nullptr));
mSocketProcessBridgeParentMap.Put(
aContentProcessId, MakeRefPtr<SocketProcessBridgeParent>(
aContentProcessId, std::move(aEndpoint)));
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvInitProfiler(
Endpoint<PProfilerChild>&& aEndpoint) {
#ifdef MOZ_GECKO_PROFILER
mProfilerController =
mozilla::ChildProfilerController::Create(std::move(aEndpoint));
#endif
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvSocketProcessTelemetryPing() {
const uint32_t kExpectedUintValue = 42;
Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_SOCKET_ONLY_UINT,
kExpectedUintValue);
return IPC_OK();
}
void SocketProcessChild::DestroySocketProcessBridgeParent(ProcessId aId) {
MOZ_ASSERT(NS_IsMainThread());
mSocketProcessBridgeParentMap.Remove(aId);
}
PWebrtcTCPSocketChild* SocketProcessChild::AllocPWebrtcTCPSocketChild(
const Maybe<TabId>& tabId) {
// We don't allocate here: instead we always use IPDL constructor that takes
// an existing object
MOZ_ASSERT_UNREACHABLE(
"AllocPWebrtcTCPSocketChild should not be called on"
" socket child");
return nullptr;
}
bool SocketProcessChild::DeallocPWebrtcTCPSocketChild(
PWebrtcTCPSocketChild* aActor) {
#ifdef MOZ_WEBRTC
WebrtcTCPSocketChild* child = static_cast<WebrtcTCPSocketChild*>(aActor);
child->ReleaseIPDLReference();
#endif
return true;
}
already_AddRefed<PHttpTransactionChild>
SocketProcessChild::AllocPHttpTransactionChild() {
RefPtr<HttpTransactionChild> actor = new HttpTransactionChild();
return actor.forget();
}
PFileDescriptorSetChild* SocketProcessChild::AllocPFileDescriptorSetChild(
const FileDescriptor& aFD) {
return new FileDescriptorSetChild(aFD);
}
bool SocketProcessChild::DeallocPFileDescriptorSetChild(
PFileDescriptorSetChild* aActor) {
delete aActor;
return true;
}
PChildToParentStreamChild*
SocketProcessChild::AllocPChildToParentStreamChild() {
MOZ_CRASH("PChildToParentStreamChild actors should be manually constructed!");
}
bool SocketProcessChild::DeallocPChildToParentStreamChild(
PChildToParentStreamChild* aActor) {
delete aActor;
return true;
}
PParentToChildStreamChild*
SocketProcessChild::AllocPParentToChildStreamChild() {
return mozilla::ipc::AllocPParentToChildStreamChild();
}
bool SocketProcessChild::DeallocPParentToChildStreamChild(
PParentToChildStreamChild* aActor) {
delete aActor;
return true;
}
PChildToParentStreamChild*
SocketProcessChild::SendPChildToParentStreamConstructor(
PChildToParentStreamChild* aActor) {
MOZ_ASSERT(NS_IsMainThread());
return PSocketProcessChild::SendPChildToParentStreamConstructor(aActor);
}
PFileDescriptorSetChild* SocketProcessChild::SendPFileDescriptorSetConstructor(
const FileDescriptor& aFD) {
MOZ_ASSERT(NS_IsMainThread());
return PSocketProcessChild::SendPFileDescriptorSetConstructor(aFD);
}
already_AddRefed<PHttpConnectionMgrChild>
SocketProcessChild::AllocPHttpConnectionMgrChild(
const HttpHandlerInitArgs& aArgs) {
LOG(("SocketProcessChild::AllocPHttpConnectionMgrChild \n"));
MOZ_ASSERT(gHttpHandler);
gHttpHandler->SetHttpHandlerInitArgs(aArgs);
RefPtr<HttpConnectionMgrChild> actor = new HttpConnectionMgrChild();
return actor.forget();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvUpdateDeviceModelId(
const nsCString& aModelId) {
MOZ_ASSERT(gHttpHandler);
gHttpHandler->SetDeviceModelId(aModelId);
return IPC_OK();
}
mozilla::ipc::IPCResult
SocketProcessChild::RecvOnHttpActivityDistributorActivated(
const bool& aIsActivated) {
if (nsCOMPtr<nsIHttpActivityObserver> distributor =
services::GetHttpActivityDistributor()) {
distributor->SetIsActive(aIsActivated);
}
return IPC_OK();
}
already_AddRefed<PInputChannelThrottleQueueChild>
SocketProcessChild::AllocPInputChannelThrottleQueueChild(
const uint32_t& aMeanBytesPerSecond, const uint32_t& aMaxBytesPerSecond) {
RefPtr<InputChannelThrottleQueueChild> p =
new InputChannelThrottleQueueChild();
p->Init(aMeanBytesPerSecond, aMaxBytesPerSecond);
return p.forget();
}
already_AddRefed<PAltSvcTransactionChild>
SocketProcessChild::AllocPAltSvcTransactionChild(
const HttpConnectionInfoCloneArgs& aConnInfo, const uint32_t& aCaps) {
RefPtr<nsHttpConnectionInfo> cinfo =
nsHttpConnectionInfo::DeserializeHttpConnectionInfoCloneArgs(aConnInfo);
RefPtr<AltSvcTransactionChild> child =
new AltSvcTransactionChild(cinfo, aCaps);
return child.forget();
}
already_AddRefed<PDNSRequestChild> SocketProcessChild::AllocPDNSRequestChild(
const nsCString& aHost, const nsCString& aTrrServer, const uint16_t& aType,
const OriginAttributes& aOriginAttributes, const uint32_t& aFlags) {
RefPtr<DNSRequestHandler> handler = new DNSRequestHandler();
RefPtr<DNSRequestChild> actor = new DNSRequestChild(handler);
return actor.forget();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvPDNSRequestConstructor(
PDNSRequestChild* aActor, const nsCString& aHost,
const nsCString& aTrrServer, const uint16_t& aType,
const OriginAttributes& aOriginAttributes, const uint32_t& aFlags) {
RefPtr<DNSRequestChild> actor = static_cast<DNSRequestChild*>(aActor);
RefPtr<DNSRequestHandler> handler =
actor->GetDNSRequest()->AsDNSRequestHandler();
handler->DoAsyncResolve(aHost, aTrrServer, aType, aOriginAttributes, aFlags);
return IPC_OK();
}
void SocketProcessChild::AddDataBridgeToMap(
uint64_t aChannelId, BackgroundDataBridgeParent* aActor) {
ipc::AssertIsOnBackgroundThread();
MutexAutoLock lock(mMutex);
mBackgroundDataBridgeMap.Put(aChannelId, aActor);
}
void SocketProcessChild::RemoveDataBridgeFromMap(uint64_t aChannelId) {
ipc::AssertIsOnBackgroundThread();
MutexAutoLock lock(mMutex);
mBackgroundDataBridgeMap.Remove(aChannelId);
}
Maybe<RefPtr<BackgroundDataBridgeParent>>
SocketProcessChild::GetAndRemoveDataBridge(uint64_t aChannelId) {
MutexAutoLock lock(mMutex);
return mBackgroundDataBridgeMap.GetAndRemove(aChannelId);
}
mozilla::ipc::IPCResult SocketProcessChild::RecvClearSessionCache() {
if (EnsureNSSInitializedChromeOrContent()) {
nsNSSComponent::DoClearSSLExternalAndInternalSessionCache();
}
return IPC_OK();
}
already_AddRefed<PTRRServiceChild> SocketProcessChild::AllocPTRRServiceChild(
const bool& aCaptiveIsPassed, const bool& aParentalControlEnabled,
const nsTArray<nsCString>& aDNSSuffixList) {
RefPtr<TRRServiceChild> actor = new TRRServiceChild();
return actor.forget();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvPTRRServiceConstructor(
PTRRServiceChild* aActor, const bool& aCaptiveIsPassed,
const bool& aParentalControlEnabled, nsTArray<nsCString>&& aDNSSuffixList) {
static_cast<TRRServiceChild*>(aActor)->Init(
aCaptiveIsPassed, aParentalControlEnabled, std::move(aDNSSuffixList));
return IPC_OK();
}
already_AddRefed<PNativeDNSResolverOverrideChild>
SocketProcessChild::AllocPNativeDNSResolverOverrideChild() {
RefPtr<NativeDNSResolverOverrideChild> actor =
new NativeDNSResolverOverrideChild();
return actor.forget();
}
mozilla::ipc::IPCResult
SocketProcessChild::RecvPNativeDNSResolverOverrideConstructor(
PNativeDNSResolverOverrideChild* aActor) {
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvNotifyObserver(
const nsCString& aTopic, const nsString& aData) {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->NotifyObservers(nullptr, aTopic.get(), aData.get());
}
return IPC_OK();
}
already_AddRefed<PRemoteLazyInputStreamChild>
SocketProcessChild::AllocPRemoteLazyInputStreamChild(const nsID& aID,
const uint64_t& aSize) {
RefPtr<RemoteLazyInputStreamChild> actor =
new RemoteLazyInputStreamChild(aID, aSize);
return actor.forget();
}
namespace {
class DataResolverBase {
public:
// This type is threadsafe-refcounted, as it's referenced on the socket
// thread, but must be destroyed on the main thread.
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_DELETE_ON_MAIN_THREAD(
DataResolverBase)
DataResolverBase() = default;
protected:
virtual ~DataResolverBase() = default;
};
template <typename DataType, typename ResolverType>
class DataResolver final : public DataResolverBase {
public:
explicit DataResolver(ResolverType&& aResolve)
: mResolve(std::move(aResolve)) {}
void OnResolve(DataType&& aData) {
MOZ_ASSERT(OnSocketThread());
RefPtr<DataResolver<DataType, ResolverType>> self = this;
mData = std::move(aData);
NS_DispatchToMainThread(NS_NewRunnableFunction(
"net::DataResolver::OnResolve",
[self{std::move(self)}]() { self->mResolve(std::move(self->mData)); }));
}
private:
virtual ~DataResolver() = default;
ResolverType mResolve;
DataType mData;
};
} // anonymous namespace
mozilla::ipc::IPCResult SocketProcessChild::RecvGetSocketData(
GetSocketDataResolver&& aResolve) {
if (!gSocketTransportService) {
aResolve(SocketDataArgs());
return IPC_OK();
}
RefPtr<
DataResolver<SocketDataArgs, SocketProcessChild::GetSocketDataResolver>>
resolver = new DataResolver<SocketDataArgs,
SocketProcessChild::GetSocketDataResolver>(
std::move(aResolve));
gSocketTransportService->Dispatch(
NS_NewRunnableFunction(
"net::SocketProcessChild::RecvGetSocketData",
[resolver{std::move(resolver)}]() {
SocketDataArgs args;
gSocketTransportService->GetSocketConnections(&args.info());
args.totalSent() = gSocketTransportService->GetSentBytes();
args.totalRecv() = gSocketTransportService->GetReceivedBytes();
resolver->OnResolve(std::move(args));
}),
NS_DISPATCH_NORMAL);
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvGetDNSCacheEntries(
GetDNSCacheEntriesResolver&& aResolve) {
nsresult rv = NS_OK;
nsCOMPtr<nsIDNSService> dns =
do_GetService("@mozilla.org/network/dns-service;1", &rv);
if (NS_FAILED(rv)) {
aResolve(nsTArray<DNSCacheEntries>());
return IPC_OK();
}
RefPtr<DataResolver<nsTArray<DNSCacheEntries>,
SocketProcessChild::GetDNSCacheEntriesResolver>>
resolver =
new DataResolver<nsTArray<DNSCacheEntries>,
SocketProcessChild::GetDNSCacheEntriesResolver>(
std::move(aResolve));
gSocketTransportService->Dispatch(
NS_NewRunnableFunction(
"net::SocketProcessChild::RecvGetDNSCacheEntries",
[resolver{std::move(resolver)}, dns{std::move(dns)}]() {
nsTArray<DNSCacheEntries> entries;
dns->GetDNSCacheEntries(&entries);
resolver->OnResolve(std::move(entries));
}),
NS_DISPATCH_NORMAL);
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessChild::RecvGetHttpConnectionData(
GetHttpConnectionDataResolver&& aResolve) {
if (!gSocketTransportService) {
aResolve(nsTArray<HttpRetParams>());
return IPC_OK();
}
RefPtr<DataResolver<nsTArray<HttpRetParams>,
SocketProcessChild::GetHttpConnectionDataResolver>>
resolver =
new DataResolver<nsTArray<HttpRetParams>,
SocketProcessChild::GetHttpConnectionDataResolver>(
std::move(aResolve));
gSocketTransportService->Dispatch(
NS_NewRunnableFunction(
"net::SocketProcessChild::RecvGetHttpConnectionData",
[resolver{std::move(resolver)}]() {
nsTArray<HttpRetParams> data;
HttpInfo::GetHttpConnectionData(&data);
resolver->OnResolve(std::move(data));
}),
NS_DISPATCH_NORMAL);
return IPC_OK();
}
} // namespace net
} // namespace mozilla
|