<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>27337</bug_id>
          
          <creation_ts>2009-07-16 01:23:30 -0700</creation_ts>
          <short_desc>Add a getter in MessagePortChannel for the PlatformMessagePortChannel</short_desc>
          <delta_ts>2009-07-16 23:45:56 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="John Abd-El-Malek">jam</reporter>
          <assigned_to name="David Levin">levin</assigned_to>
          <cc>atwilson</cc>
    
    <cc>fishd</cc>
    
    <cc>levin</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>132193</commentid>
    <comment_count>0</comment_count>
    <who name="John Abd-El-Malek">jam</who>
    <bug_when>2009-07-16 01:23:30 -0700</bug_when>
    <thetext>Platform code might need to get access to its PlatformMessagePortChannel object from a MessagePortChannel.  i.e. Chromium&apos;s port needs it when sending a message port, so it can get the unique identifier for that port.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>132197</commentid>
    <comment_count>1</comment_count>
      <attachid>32843</attachid>
    <who name="John Abd-El-Malek">jam</who>
    <bug_when>2009-07-16 01:28:27 -0700</bug_when>
    <thetext>Created attachment 32843
Proposed patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>132201</commentid>
    <comment_count>2</comment_count>
      <attachid>32843</attachid>
    <who name="David Levin">levin</who>
    <bug_when>2009-07-16 01:46:52 -0700</bug_when>
    <thetext>Comment on attachment 32843
Proposed patch

It would be nice to mention in the bug why this is useful.

&gt; Index: WebCore/dom/MessagePortChannel.h
&gt; +        // Getter for m_channel.

I&apos;d remove this comment as it doesn&apos;t really seem to add any information.

&gt; +        PassRefPtr&lt;PlatformMessagePortChannel&gt; channel();

Since this method isn&apos;t really passing the ref count to the caller (it retains the ref counted pointer), just return PlatformMessagePortChannel* (instead of a PassRefPtr).

Also, why not just define this inline?
     return m_channel.get();</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>132288</commentid>
    <comment_count>3</comment_count>
    <who name="Andrew Wilson">atwilson</who>
    <bug_when>2009-07-16 09:50:57 -0700</bug_when>
    <thetext>I&apos;m also curious about why this is necessary. The whole point behind MessagePortChannel is to create a wrapper around PlatformMessagePortChannel to make sure that you never have a raw PlatformMessagePortChannel floating around that might not get close()&apos;d.

Exposing a getter for PlatformMessagePortChannel seems dangerous (it&apos;s too easy to inadvertently create leaks) and violates the encapsulation that MessagePortChannel is intended to provide.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>132309</commentid>
    <comment_count>4</comment_count>
    <who name="John Abd-El-Malek">jam</who>
    <bug_when>2009-07-16 12:06:13 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; (From update of attachment 32843 [details])
&gt; It would be nice to mention in the bug why this is useful.

I wrote a small description above (i..e re unique identifier), is that not enough?

&gt; 
&gt; &gt; Index: WebCore/dom/MessagePortChannel.h
&gt; &gt; +        // Getter for m_channel.
&gt; 
&gt; I&apos;d remove this comment as it doesn&apos;t really seem to add any information.

ah, I thought it was necessary if the implementation was in a different file (which was necessary if I was returning a PassRefPtr, but as you point out below, that&apos;s not necessary).

&gt; 
&gt; &gt; +        PassRefPtr&lt;PlatformMessagePortChannel&gt; channel();
&gt; 
&gt; Since this method isn&apos;t really passing the ref count to the caller (it retains
&gt; the ref counted pointer), just return PlatformMessagePortChannel* (instead of a
&gt; PassRefPtr).

ah, I still get confused sometimes with all the RefPtr objects.  Thanks, I only need a pointer.  I wasn&apos;t sure if it&apos;s ok to pass around raw pointers of ref counted objects.
&gt; 
&gt; Also, why not just define this inline?
&gt;      return m_channel.get();

this is now possible once there are PassRefPtr (since the PlatformMessagePortChannel header isn&apos;t included here).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>132313</commentid>
    <comment_count>5</comment_count>
    <who name="John Abd-El-Malek">jam</who>
    <bug_when>2009-07-16 12:10:24 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; I&apos;m also curious about why this is necessary. The whole point behind
&gt; MessagePortChannel is to create a wrapper around PlatformMessagePortChannel to
&gt; make sure that you never have a raw PlatformMessagePortChannel floating around
&gt; that might not get close()&apos;d.
&gt; 
&gt; Exposing a getter for PlatformMessagePortChannel seems dangerous (it&apos;s too easy
&gt; to inadvertently create leaks) and violates the encapsulation that
&gt; MessagePortChannel is intended to provide.

I&apos;m going to upload the chromium port changes soon, which will make things clearer.

The reason this is needed, which I hinted to above, is that when sending a message port in a postMessage call, PlatformMessagePortChannel   just gets a MessagePortChannel::EventData that contains a MessagePortChannel object.  In the single process case, that&apos;s enough.  However for Chrome, when the object needs to be recreated in a different process, more information from the platform implementation is needed (namely, the unique identifier for this message port channel that will be sent to a different process).

Checking in this patch isn&apos;t time critical (thanks for the quick review though David!), so committing it can wait until you guys see the chromium platform implementation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>132314</commentid>
    <comment_count>6</comment_count>
      <attachid>32886</attachid>
    <who name="John Abd-El-Malek">jam</who>
    <bug_when>2009-07-16 12:10:49 -0700</bug_when>
    <thetext>Created attachment 32886
new patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>132315</commentid>
    <comment_count>7</comment_count>
    <who name="Andrew Wilson">atwilson</who>
    <bug_when>2009-07-16 12:21:13 -0700</bug_when>
    <thetext>Ah, that makes sense. 

Sorry I missed your earlier comment in the bug - I was rushing off to an interview and wanted to get my two cents in before going.

And on further consideration, it&apos;s not that dangerous to have a bare reference to a PMPC, since the PMPC will get closed whenever the MPC is freed so there&apos;s no danger of lingering refs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>132326</commentid>
    <comment_count>8</comment_count>
      <attachid>32886</attachid>
    <who name="David Levin">levin</who>
    <bug_when>2009-07-16 13:08:31 -0700</bug_when>
    <thetext>Comment on attachment 32886
new patch

I missed your earlier comment too.

&gt; ah, I still get confused sometimes with all the RefPtr objects.  Thanks, I only
&gt; need a pointer.  I wasn&apos;t sure if it&apos;s ok to pass around raw pointers of ref
&gt; counted objects.

Actually, I wasn&apos;t aware of this guideline until recently, but it is stated well here: http://webkit.org/coding/RefPtr.html

&quot;If a function’s result is an object, but ownership is not being transferred, the result should be a raw pointer. This includes most getter functions.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>132330</commentid>
    <comment_count>9</comment_count>
    <who name="David Levin">levin</who>
    <bug_when>2009-07-16 13:19:11 -0700</bug_when>
    <thetext>Assigned to levin for landing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>132425</commentid>
    <comment_count>10</comment_count>
    <who name="David Levin">levin</who>
    <bug_when>2009-07-16 17:38:58 -0700</bug_when>
    <thetext>Committed as http://trac.webkit.org/changeset/45996</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>132496</commentid>
    <comment_count>11</comment_count>
    <who name="John Abd-El-Malek">jam</who>
    <bug_when>2009-07-16 23:45:56 -0700</bug_when>
    <thetext>(In reply to comment #10)
&gt; Committed as http://trac.webkit.org/changeset/45996

Thanks!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>32843</attachid>
            <date>2009-07-16 01:28:27 -0700</date>
            <delta_ts>2009-07-16 12:10:49 -0700</delta_ts>
            <desc>Proposed patch</desc>
            <filename>mp_getter.txt</filename>
            <type>text/plain</type>
            <size>1889</size>
            <attacher name="John Abd-El-Malek">jam</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiA0NTk2OCkKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMTUgQEAKKzIwMDktMDctMTYgIEpvaG4gQWJkLUVsLU1hbGVrICA8amFtQGNocm9t
aXVtLm9yZz4KKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAg
ICBBZGQgYSBnZXR0ZXIgaW4gTWVzc2FnZVBvcnRDaGFubmVsIGZvciB0aGUgUGxhdGZvcm1NZXNz
YWdlUG9ydENoYW5uZWwuCisKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19i
dWcuY2dpP2lkPTI3MzM3CisKKyAgICAgICAgKiBkb20vTWVzc2FnZVBvcnRDaGFubmVsLmg6Cisg
ICAgICAgICogZG9tL2RlZmF1bHQvUGxhdGZvcm1NZXNzYWdlUG9ydENoYW5uZWwuY3BwOgorICAg
ICAgICAoV2ViQ29yZTo6TWVzc2FnZVBvcnRDaGFubmVsOjpjaGFubmVsKToKKwogMjAwOS0wNy0x
NSAgU2hpbmljaGlybyBIYW1hamkgIDxoYW1hamlAY2hyb21pdW0ub3JnPgogCiAgICAgICAgIFJl
dmlld2VkIGJ5IEVyaWMgU2VpZGVsLgpJbmRleDogV2ViQ29yZS9kb20vTWVzc2FnZVBvcnRDaGFu
bmVsLmgKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09P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XNzUmVmUHRyPFBsYXRmb3JtTWVzc2FnZVBvcnRDaGFubmVs
PiBNZXNzYWdlUG9ydENoYW5uZWw6OmNoYW5uZWwoKQoreworICAgIHJldHVybiBtX2NoYW5uZWw7
Cit9CisKIFBhc3NSZWZQdHI8UGxhdGZvcm1NZXNzYWdlUG9ydENoYW5uZWw+IFBsYXRmb3JtTWVz
c2FnZVBvcnRDaGFubmVsOjpjcmVhdGUoUGFzc1JlZlB0cjxNZXNzYWdlUG9ydFF1ZXVlPiBpbmNv
bWluZywgUGFzc1JlZlB0cjxNZXNzYWdlUG9ydFF1ZXVlPiBvdXRnb2luZykKIHsKICAgICByZXR1
cm4gYWRvcHRSZWYobmV3IFBsYXRmb3JtTWVzc2FnZVBvcnRDaGFubmVsKGluY29taW5nLCBvdXRn
b2luZykpOwo=
</data>
<flag name="review"
          id="17200"
          type_id="1"
          status="-"
          setter="levin"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>32886</attachid>
            <date>2009-07-16 12:10:49 -0700</date>
            <delta_ts>2009-07-16 13:08:31 -0700</delta_ts>
            <desc>new patch</desc>
            <filename>mp_getter2.txt</filename>
            <type>text/plain</type>
            <size>0</size>
            <attacher name="John Abd-El-Malek">jam</attacher>
            
              <data encoding="base64"></data>
<flag name="review"
          id="17236"
          type_id="1"
          status="+"
          setter="levin"
    />
          </attachment>
      

    </bug>

</bugzilla>