Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/clients/manager/ClientManagerOpParent.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "ClientManagerOpParent.h"
8
9
#include "ClientManagerService.h"
10
#include "mozilla/ipc/BackgroundParent.h"
11
12
namespace mozilla {
13
namespace dom {
14
15
using mozilla::ipc::BackgroundParent;
16
17
template <typename Method, typename... Args>
18
void
19
ClientManagerOpParent::DoServiceOp(Method aMethod, Args&&... aArgs)
20
0
{
21
0
  // Note, we need perfect forarding of the template type in order
22
0
  // to allow already_AddRefed<> to be passed as an arg.
23
0
  RefPtr<ClientOpPromise> p = (mService->*aMethod)(std::forward<Args>(aArgs)...);
24
0
25
0
  // Capturing `this` is safe here because we disconnect the promise in
26
0
  // ActorDestroy() which ensures neither lambda is called if the actor
27
0
  // is destroyed before the source operation completes.
28
0
  p->Then(GetCurrentThreadSerialEventTarget(), __func__,
29
0
    [this] (const mozilla::dom::ClientOpResult& aResult) {
30
0
      mPromiseRequestHolder.Complete();
31
0
      Unused << PClientManagerOpParent::Send__delete__(this, aResult);
32
0
    }, [this] (nsresult aRv) {
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientNavigateArgs const&), mozilla::dom::ClientNavigateArgs const&>(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientNavigateArgs const&), mozilla::dom::ClientNavigateArgs const&)::{lambda(mozilla::dom::ClientOpResult const&)#1}::operator()(mozilla::dom::ClientOpResult const&) const
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientMatchAllArgs const&), mozilla::dom::ClientMatchAllArgs const&>(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientMatchAllArgs const&), mozilla::dom::ClientMatchAllArgs const&)::{lambda(mozilla::dom::ClientOpResult const&)#1}::operator()(mozilla::dom::ClientOpResult const&) const
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientClaimArgs const&), mozilla::dom::ClientClaimArgs const&>(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientClaimArgs const&), mozilla::dom::ClientClaimArgs const&)::{lambda(mozilla::dom::ClientOpResult const&)#1}::operator()(mozilla::dom::ClientOpResult const&) const
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientGetInfoAndStateArgs const&), mozilla::dom::ClientGetInfoAndStateArgs const&>(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientGetInfoAndStateArgs const&), mozilla::dom::ClientGetInfoAndStateArgs const&)::{lambda(mozilla::dom::ClientOpResult const&)#1}::operator()(mozilla::dom::ClientOpResult const&) const
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientOpenWindowArgs const&, already_AddRefed<mozilla::dom::ContentParent>), mozilla::dom::ClientOpenWindowArgs const&, already_AddRefed<mozilla::dom::ContentParent> >(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientOpenWindowArgs const&, already_AddRefed<mozilla::dom::ContentParent>), mozilla::dom::ClientOpenWindowArgs const&, already_AddRefed<mozilla::dom::ContentParent>&&)::{lambda(mozilla::dom::ClientOpResult const&)#1}::operator()(mozilla::dom::ClientOpResult const&) const
33
0
      mPromiseRequestHolder.Complete();
34
0
      Unused << PClientManagerOpParent::Send__delete__(this, aRv);
35
0
    })->Track(mPromiseRequestHolder);
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientNavigateArgs const&), mozilla::dom::ClientNavigateArgs const&>(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientNavigateArgs const&), mozilla::dom::ClientNavigateArgs const&)::{lambda(nsresult)#1}::operator()(nsresult) const
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientMatchAllArgs const&), mozilla::dom::ClientMatchAllArgs const&>(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientMatchAllArgs const&), mozilla::dom::ClientMatchAllArgs const&)::{lambda(nsresult)#1}::operator()(nsresult) const
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientClaimArgs const&), mozilla::dom::ClientClaimArgs const&>(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientClaimArgs const&), mozilla::dom::ClientClaimArgs const&)::{lambda(nsresult)#1}::operator()(nsresult) const
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientGetInfoAndStateArgs const&), mozilla::dom::ClientGetInfoAndStateArgs const&>(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientGetInfoAndStateArgs const&), mozilla::dom::ClientGetInfoAndStateArgs const&)::{lambda(nsresult)#1}::operator()(nsresult) const
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientOpenWindowArgs const&, already_AddRefed<mozilla::dom::ContentParent>), mozilla::dom::ClientOpenWindowArgs const&, already_AddRefed<mozilla::dom::ContentParent> >(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientOpenWindowArgs const&, already_AddRefed<mozilla::dom::ContentParent>), mozilla::dom::ClientOpenWindowArgs const&, already_AddRefed<mozilla::dom::ContentParent>&&)::{lambda(nsresult)#1}::operator()(nsresult) const
36
0
}
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientNavigateArgs const&), mozilla::dom::ClientNavigateArgs const&>(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientNavigateArgs const&), mozilla::dom::ClientNavigateArgs const&)
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientMatchAllArgs const&), mozilla::dom::ClientMatchAllArgs const&>(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientMatchAllArgs const&), mozilla::dom::ClientMatchAllArgs const&)
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientClaimArgs const&), mozilla::dom::ClientClaimArgs const&>(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientClaimArgs const&), mozilla::dom::ClientClaimArgs const&)
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientGetInfoAndStateArgs const&), mozilla::dom::ClientGetInfoAndStateArgs const&>(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientGetInfoAndStateArgs const&), mozilla::dom::ClientGetInfoAndStateArgs const&)
Unexecuted instantiation: void mozilla::dom::ClientManagerOpParent::DoServiceOp<RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientOpenWindowArgs const&, already_AddRefed<mozilla::dom::ContentParent>), mozilla::dom::ClientOpenWindowArgs const&, already_AddRefed<mozilla::dom::ContentParent> >(RefPtr<mozilla::MozPromise<mozilla::dom::ClientOpResult, nsresult, false> > (mozilla::dom::ClientManagerService::*)(mozilla::dom::ClientOpenWindowArgs const&, already_AddRefed<mozilla::dom::ContentParent>), mozilla::dom::ClientOpenWindowArgs const&, already_AddRefed<mozilla::dom::ContentParent>&&)
37
38
void
39
ClientManagerOpParent::ActorDestroy(ActorDestroyReason aReason)
40
0
{
41
0
  mPromiseRequestHolder.DisconnectIfExists();
42
0
}
43
44
ClientManagerOpParent::ClientManagerOpParent(ClientManagerService* aService)
45
  : mService(aService)
46
0
{
47
0
  MOZ_DIAGNOSTIC_ASSERT(mService);
48
0
}
49
50
void
51
ClientManagerOpParent::Init(const ClientOpConstructorArgs& aArgs)
52
0
{
53
0
  switch (aArgs.type()) {
54
0
    case ClientOpConstructorArgs::TClientNavigateArgs:
55
0
    {
56
0
      DoServiceOp(&ClientManagerService::Navigate,
57
0
                  aArgs.get_ClientNavigateArgs());
58
0
      break;
59
0
    }
60
0
    case ClientOpConstructorArgs::TClientMatchAllArgs:
61
0
    {
62
0
      DoServiceOp(&ClientManagerService::MatchAll,
63
0
                  aArgs.get_ClientMatchAllArgs());
64
0
      break;
65
0
    }
66
0
    case ClientOpConstructorArgs::TClientClaimArgs:
67
0
    {
68
0
      DoServiceOp(&ClientManagerService::Claim, aArgs.get_ClientClaimArgs());
69
0
      break;
70
0
    }
71
0
    case ClientOpConstructorArgs::TClientGetInfoAndStateArgs:
72
0
    {
73
0
      DoServiceOp(&ClientManagerService::GetInfoAndState,
74
0
                  aArgs.get_ClientGetInfoAndStateArgs());
75
0
      break;
76
0
    }
77
0
    case ClientOpConstructorArgs::TClientOpenWindowArgs:
78
0
    {
79
0
      RefPtr<ContentParent> contentParent =
80
0
        BackgroundParent::GetContentParent(Manager()->Manager());
81
0
      DoServiceOp(&ClientManagerService::OpenWindow,
82
0
                  aArgs.get_ClientOpenWindowArgs(), contentParent.forget());
83
0
      break;
84
0
    }
85
0
    default:
86
0
    {
87
0
      MOZ_ASSERT_UNREACHABLE("Unknown Client operation!");
88
0
      break;
89
0
    }
90
0
  }
91
0
}
92
93
} // namespace dom
94
} // namespace mozilla