Closed Bug 783451 Opened 12 years ago Closed 11 years ago

Protocol passed through arguments should be a friend class

Categories

(Core :: IPC, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: kanru, Unassigned)

Details

Attachments

(2 files)

In case like

struct SurfaceDescriptorGralloc {
  PGrallocBuffer buffer;
};

union SurfaceDescriptor {
  SurfaceDescriptorGralloc;
};

union SharedImage {
  SurfaceDescriptor;
};

sync protocol PImageContainer
{
  manager PImageBridge;
child:
  async ReturnImage(SharedImage image);
};

The generated code for |ReturnImage| needs to access PGrallocBuffer's mId field which is private, this forces us to mark PImageContainer as managing seemingly unrelated PGrallocBuffer.

Error:

../../ipc/ipdl/_ipdlheaders/mozilla/layers/PGrallocBufferParent.h: In member function 'void mozilla::layers::PImageContainerParent::Write(mozilla::layers::PGrallocBufferParent*, IPC::Message*, bool)':
../../ipc/ipdl/_ipdlheaders/mozilla/layers/PGrallocBufferParent.h:228: error: 'int32 mozilla::layers::PGrallocBufferParent::mId' is private
objdir-gecko/ipc/ipdl/PImageContainerParent.cpp:845: error: within this context
objdir-gecko/ipc/ipdl/PImageContainerParent.cpp: In member function 'bool mozilla::layers::PImageContainerParent::Read(mozilla::layers::PGrallocBufferParent**, const IPC::Message*, void**, bool)':
objdir-gecko/ipc/ipdl/PImageContainerParent.cpp:875: error: 'mozilla::ipc::RPCChannel::RPCListener' is an inaccessible base of 'mozilla::layers::PGrallocBufferParent'
To fix this we might need to eitehr

1. Run two pass parsing to know that PGrallocBuffer needs to be a friend of PImageContainer

or

2. Introduce a new syntax that indicates PGrallocBuffer is a friend of PImageContainer like

 protocol PGrallocBuffer {
   friend PImageContainer;
 child:
   Msg();
 };
What is the manager of PGrallocBuffer in this case? Adding friend marking is definitely incorrect here. Perhaps asking the common manager ancestor for the ID is the correct behavior.
PGrallocBuffer has many managers because we used to create it from different protocols.
That doesn't matter. We know at compile time which manager applies in this particular case.
It turns out the bug has been fixed in bug 825928. See bug 852734 comment 82.
Attachment #754760 - Flags: review?(ncameron)
Attachment #754760 - Flags: review?(bent.mozilla)
TODO: Add a testcase for it.
Attachment #754760 - Flags: review?(ncameron) → review+
Attachment #754760 - Flags: review?(bent.mozilla) → review+
Attached patch Add test caseSplinter Review
I'll file the FIXME bug if this test case make sense.
Attachment #761939 - Flags: review?(benjamin)
Attachment #761939 - Flags: review?(benjamin) → review?(bent.mozilla)
Comment on attachment 761939 [details] [diff] [review]
Add test case

Review of attachment 761939 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good! Though splinter says these files have windows line endings which you should remove before checkin.

Here's one thing that needs fixing:

::: ipc/ipdl/test/cxx/PTestIndirectProtocolParamFirst.ipdl
@@ +1,3 @@
> +include protocol PTestIndirectProtocolParamManage;
> +// FIXME/bug xxxxxx protocol PTestIndirectProtocolParamSecond is
> +// already included in PTestIndirectProtocolParam.ipdlh

Please actually file a bug or remove this comment.
Attachment #761939 - Flags: review?(bent.mozilla) → review+
(In reply to ben turner [:bent] from comment #8)
> ::: ipc/ipdl/test/cxx/PTestIndirectProtocolParamFirst.ipdl
> @@ +1,3 @@
> > +include protocol PTestIndirectProtocolParamManage;
> > +// FIXME/bug xxxxxx protocol PTestIndirectProtocolParamSecond is
> > +// already included in PTestIndirectProtocolParam.ipdlh
> 
> Please actually file a bug or remove this comment.

Actually there is already one, bug 792908, I'll fill that.
https://hg.mozilla.org/mozilla-central/rev/5fae2a068802
https://hg.mozilla.org/mozilla-central/rev/5c902b055c44
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: