|
|
Created:
7 years, 9 months ago by teravest Modified:
7 years, 8 months ago CC:
chromium-reviews, yusukes+watch_chromium.org, tzik+watch_chromium.org, jam, yzshen+watch_chromium.org, joi+watch-content_chromium.org, darin-cc_chromium.org, raymes+watch_chromium.org, piman+watch_chromium.org, kinuko+watch, ihf+watch_chromium.org Base URL:
https://chromium.googlesource.com/chromium/src.git@master Visibility:
Public. |
DescriptionAdd Query() support to FileRef.
This change brings Query() support back to FileRef for in-process and out-of-process plugins.
I've added testing for a file that exists and one that doesn't.
BUG=170721
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=191805
Patch Set 1 #Patch Set 2 : #
Total comments: 13
Patch Set 3 : #
Total comments: 18
Patch Set 4 : Fix yuzhu's concerns, fix tests #
Total comments: 2
Patch Set 5 : Fix memory leak #
Total comments: 2
Patch Set 6 : Fix method signature for Owned() #Patch Set 7 : callback type, PP_FileInfo initialization #
Total comments: 1
Patch Set 8 : Support Query() for external filesystems. #Patch Set 9 : Use the newest interface for every cpp FileRef call. #
Total comments: 11
Patch Set 10 : Don't leak file handles, fix nits #
Total comments: 12
Patch Set 11 : nits, blocking completion callback test broken. #Patch Set 12 : Fix test for blocking callbacks #Patch Set 13 : Take ref on PPB_FileRef_Impl instead of PluginInstance. #
Total comments: 6
Patch Set 14 : nits, more callback ref shuffling. #
Total comments: 2
Patch Set 15 : Changed MessageLoopProxy to TaskRunner. #Patch Set 16 : Rebased onto origin/master #Patch Set 17 : Fix for test_file_io #Patch Set 18 : Merged onto origin/master yet again #
Messages
Total messages: 54 (0 generated)
https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h File ppapi/cpp/file_ref.h (right): https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h#newco... ppapi/cpp/file_ref.h:157: int32_t Query(PP_FileInfo* info, const CompletionCallback& callback); Please use "CompletionCallbackWithOutput<PP_FileInfo>" instead https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages.h File ppapi/proxy/ppapi_messages.h (right): https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages... ppapi/proxy/ppapi_messages.h:813: PP_FileInfo /* info */) It doesn't look like you're using this message https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... File ppapi/proxy/ppb_file_ref_proxy.cc (right): https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... ppapi/proxy/ppb_file_ref_proxy.cc:10: #include "base/debug/stack_trace.h" ^^ leftover from debugging https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, PP_FileInfo*> PendingFileInfoMap; It looks like you're using |int| instead of |unsigned int| for the callback id elsewhere. https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... ppapi/proxy/ppb_file_ref_proxy.cc:183: PP_FileInfo *target_info = found->second; nit: '*' should be with PP_FileInfo https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, sizeof(tmp_info)); Shouldn't this just be done in PPB_FileRef_Impl? It seems like you shouldn't need to special case this here
Thanks for the work! drive-by non-codereview comment: I tested the new API with my PPAPI plugin, and found that pp::FileRef::Query() was more than 2 times slower than pp::FileIO::Query(). On my Z620, FileRef::Query is about 3.8ms/call and FileIO::Query is about 1.5ms/call. chrome://tracing shows that pp::FileRef::Query() is implemented in Chrome_FileThread (in the browser process) while pp::FileIO::Query() is in Renderer::FILE. I know almost nothing about PPAPI internals, but would it be possible to do it in a renderer (or to send the IPC directly from the plugin to the browser) so that we can eliminate the additional renderer-browser IPC cost? On 2013/03/18 23:16:16, dmichael wrote: > https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h > File ppapi/cpp/file_ref.h (right): > > https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h#newco... > ppapi/cpp/file_ref.h:157: int32_t Query(PP_FileInfo* info, const > CompletionCallback& callback); > Please use "CompletionCallbackWithOutput<PP_FileInfo>" instead > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages.h > File ppapi/proxy/ppapi_messages.h (right): > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages... > ppapi/proxy/ppapi_messages.h:813: PP_FileInfo /* info */) > It doesn't look like you're using this message > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > File ppapi/proxy/ppb_file_ref_proxy.cc (right): > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > ppapi/proxy/ppb_file_ref_proxy.cc:10: #include "base/debug/stack_trace.h" > ^^ leftover from debugging > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, > PP_FileInfo*> PendingFileInfoMap; > It looks like you're using |int| instead of |unsigned int| for the callback id > elsewhere. > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > ppapi/proxy/ppb_file_ref_proxy.cc:183: PP_FileInfo *target_info = found->second; > nit: '*' should be with PP_FileInfo > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, sizeof(tmp_info)); > Shouldn't this just be done in PPB_FileRef_Impl? It seems like you shouldn't > need to special case this here
On Mon, Mar 18, 2013 at 6:01 PM, <yusukes@chromium.org> wrote: > Thanks for the work! drive-by non-codereview comment: > > I tested the new API with my PPAPI plugin, and found that > pp::FileRef::Query() > was more than 2 times slower than pp::FileIO::Query(). On my Z620, > FileRef::Query is about 3.8ms/call and FileIO::Query is about 1.5ms/call. > > chrome://tracing shows that pp::FileRef::Query() is implemented in > Chrome_FileThread (in the browser process) while pp::FileIO::Query() is in > Renderer::FILE. I know almost nothing about PPAPI internals, but would it be > possible to do it in a renderer (or to send the IPC directly from the plugin > to > the browser) so that we can eliminate the additional renderer-browser IPC > cost? I'll take a look at sending the request directly to the browser. It seems like this should be possible, but I don't know how ugly the code will look yet. > > > > On 2013/03/18 23:16:16, dmichael wrote: >> >> https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h >> File ppapi/cpp/file_ref.h (right): > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h#newco... >> >> ppapi/cpp/file_ref.h:157: int32_t Query(PP_FileInfo* info, const >> CompletionCallback& callback); >> Please use "CompletionCallbackWithOutput<PP_FileInfo>" instead > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages.h >> >> File ppapi/proxy/ppapi_messages.h (right): > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages... >> >> ppapi/proxy/ppapi_messages.h:813: PP_FileInfo /* info */) >> It doesn't look like you're using this message > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> File ppapi/proxy/ppb_file_ref_proxy.cc (right): > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> ppapi/proxy/ppb_file_ref_proxy.cc:10: #include "base/debug/stack_trace.h" >> ^^ leftover from debugging > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, >> PP_FileInfo*> PendingFileInfoMap; >> It looks like you're using |int| instead of |unsigned int| for the >> callback id >> elsewhere. > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> ppapi/proxy/ppb_file_ref_proxy.cc:183: PP_FileInfo *target_info = > > found->second; >> >> nit: '*' should be with PP_FileInfo > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, >> sizeof(tmp_info)); >> Shouldn't this just be done in PPB_FileRef_Impl? It seems like you >> shouldn't >> need to special case this here > > > > > https://codereview.chromium.org/12817009/
> I'll take a look at sending the request directly to the browser. It > seems like this should be possible, but I don't know how ugly the code > will look yet. This will probably require some ugly hacks until we move file ref to the new proxy model. (just something to keep in mind - if it's a very urgent performance requirement please go ahead otherwise let's consider doing the refactor first). On Tue, Mar 19, 2013 at 7:41 AM, Justin TerAvest <teravest@google.com> wrote: > > On Mon, Mar 18, 2013 at 6:01 PM, <yusukes@chromium.org> wrote: > > Thanks for the work! drive-by non-codereview comment: > > > > I tested the new API with my PPAPI plugin, and found that > > pp::FileRef::Query() > > was more than 2 times slower than pp::FileIO::Query(). On my Z620, > > FileRef::Query is about 3.8ms/call and FileIO::Query is about 1.5ms/call. > > > > chrome://tracing shows that pp::FileRef::Query() is implemented in > > Chrome_FileThread (in the browser process) while pp::FileIO::Query() is in > > Renderer::FILE. I know almost nothing about PPAPI internals, but would it be > > possible to do it in a renderer (or to send the IPC directly from the plugin > > to > > the browser) so that we can eliminate the additional renderer-browser IPC > > cost? > > I'll take a look at sending the request directly to the browser. It > seems like this should be possible, but I don't know how ugly the code > will look yet. > > > > > > > > > On 2013/03/18 23:16:16, dmichael wrote: > >> > >> https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h > >> File ppapi/cpp/file_ref.h (right): > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h#newco... > >> > >> ppapi/cpp/file_ref.h:157: int32_t Query(PP_FileInfo* info, const > >> CompletionCallback& callback); > >> Please use "CompletionCallbackWithOutput<PP_FileInfo>" instead > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages.h > >> > >> File ppapi/proxy/ppapi_messages.h (right): > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages... > >> > >> ppapi/proxy/ppapi_messages.h:813: PP_FileInfo /* info */) > >> It doesn't look like you're using this message > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> > >> File ppapi/proxy/ppb_file_ref_proxy.cc (right): > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> > >> ppapi/proxy/ppb_file_ref_proxy.cc:10: #include "base/debug/stack_trace.h" > >> ^^ leftover from debugging > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> > >> ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, > >> PP_FileInfo*> PendingFileInfoMap; > >> It looks like you're using |int| instead of |unsigned int| for the > >> callback id > >> elsewhere. > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> > >> ppapi/proxy/ppb_file_ref_proxy.cc:183: PP_FileInfo *target_info = > > > > found->second; > >> > >> nit: '*' should be with PP_FileInfo > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> > >> ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, > >> sizeof(tmp_info)); > >> Shouldn't this just be done in PPB_FileRef_Impl? It seems like you > >> shouldn't > >> need to special case this here > > > > > > > > > > https://codereview.chromium.org/12817009/
On Tue, Mar 19, 2013 at 10:30 AM, Raymes Khoury <raymes@google.com> wrote: >> I'll take a look at sending the request directly to the browser. It >> seems like this should be possible, but I don't know how ugly the code >> will look yet. > > This will probably require some ugly hacks until we move file ref to > the new proxy model. (just something to keep in mind - if it's a very > urgent performance requirement please go ahead otherwise let's > consider doing the refactor first). I talked with Dave a little about this earlier this morning. In addition to refactoring to the new proxy model, there have been some discussions about changing how FileIO works, potentially sending file desciptors to the plugin process so it can read or write directly. It looks like the discussion is at http://code.google.com/p/chromium/issues/detail?id=194304 I think it makes sense to get this resolved before implementing FileRef::Query. I'm going to do some reading up today to make sure I understand what direction we're headed. > > On Tue, Mar 19, 2013 at 7:41 AM, Justin TerAvest <teravest@google.com> wrote: >> >> On Mon, Mar 18, 2013 at 6:01 PM, <yusukes@chromium.org> wrote: >> > Thanks for the work! drive-by non-codereview comment: >> > >> > I tested the new API with my PPAPI plugin, and found that >> > pp::FileRef::Query() >> > was more than 2 times slower than pp::FileIO::Query(). On my Z620, >> > FileRef::Query is about 3.8ms/call and FileIO::Query is about 1.5ms/call. >> > >> > chrome://tracing shows that pp::FileRef::Query() is implemented in >> > Chrome_FileThread (in the browser process) while pp::FileIO::Query() is in >> > Renderer::FILE. I know almost nothing about PPAPI internals, but would it be >> > possible to do it in a renderer (or to send the IPC directly from the plugin >> > to >> > the browser) so that we can eliminate the additional renderer-browser IPC >> > cost? >> >> I'll take a look at sending the request directly to the browser. It >> seems like this should be possible, but I don't know how ugly the code >> will look yet. >> >> > >> > >> > >> > On 2013/03/18 23:16:16, dmichael wrote: >> >> >> >> https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h >> >> File ppapi/cpp/file_ref.h (right): >> > >> > >> > >> > https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h#newco... >> >> >> >> ppapi/cpp/file_ref.h:157: int32_t Query(PP_FileInfo* info, const >> >> CompletionCallback& callback); >> >> Please use "CompletionCallbackWithOutput<PP_FileInfo>" instead >> > >> > >> > >> > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages.h >> >> >> >> File ppapi/proxy/ppapi_messages.h (right): >> > >> > >> > >> > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages... >> >> >> >> ppapi/proxy/ppapi_messages.h:813: PP_FileInfo /* info */) >> >> It doesn't look like you're using this message >> > >> > >> > >> > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> File ppapi/proxy/ppb_file_ref_proxy.cc (right): >> > >> > >> > >> > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:10: #include "base/debug/stack_trace.h" >> >> ^^ leftover from debugging >> > >> > >> > >> > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, >> >> PP_FileInfo*> PendingFileInfoMap; >> >> It looks like you're using |int| instead of |unsigned int| for the >> >> callback id >> >> elsewhere. >> > >> > >> > >> > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:183: PP_FileInfo *target_info = >> > >> > found->second; >> >> >> >> nit: '*' should be with PP_FileInfo >> > >> > >> > >> > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, >> >> sizeof(tmp_info)); >> >> Shouldn't this just be done in PPB_FileRef_Impl? It seems like you >> >> shouldn't >> >> need to special case this here >> > >> > >> > >> > >> > https://codereview.chromium.org/12817009/
Hi, Justin. I have a question: It looks like this change will directly go to stable. I thought we usually put new interfaces in dev first. Have we considered it thoroughly before doing so? Thanks! On Tue, Mar 19, 2013 at 9:34 AM, Justin TerAvest <teravest@google.com>wrote: > On Tue, Mar 19, 2013 at 10:30 AM, Raymes Khoury <raymes@google.com> wrote: > >> I'll take a look at sending the request directly to the browser. It > >> seems like this should be possible, but I don't know how ugly the code > >> will look yet. > > > > This will probably require some ugly hacks until we move file ref to > > the new proxy model. (just something to keep in mind - if it's a very > > urgent performance requirement please go ahead otherwise let's > > consider doing the refactor first). > > I talked with Dave a little about this earlier this morning. > In addition to refactoring to the new proxy model, there have been > some discussions about changing how FileIO works, potentially sending > file desciptors to the plugin process so it can read or write > directly. It looks like the discussion is at > http://code.google.com/p/chromium/issues/detail?id=194304 > > I think it makes sense to get this resolved before implementing > FileRef::Query. I'm going to do some reading up today to make sure I > understand what direction we're headed. > > > > > On Tue, Mar 19, 2013 at 7:41 AM, Justin TerAvest <teravest@google.com> > wrote: > >> > >> On Mon, Mar 18, 2013 at 6:01 PM, <yusukes@chromium.org> wrote: > >> > Thanks for the work! drive-by non-codereview comment: > >> > > >> > I tested the new API with my PPAPI plugin, and found that > >> > pp::FileRef::Query() > >> > was more than 2 times slower than pp::FileIO::Query(). On my Z620, > >> > FileRef::Query is about 3.8ms/call and FileIO::Query is about > 1.5ms/call. > >> > > >> > chrome://tracing shows that pp::FileRef::Query() is implemented in > >> > Chrome_FileThread (in the browser process) while pp::FileIO::Query() > is in > >> > Renderer::FILE. I know almost nothing about PPAPI internals, but > would it be > >> > possible to do it in a renderer (or to send the IPC directly from the > plugin > >> > to > >> > the browser) so that we can eliminate the additional renderer-browser > IPC > >> > cost? > >> > >> I'll take a look at sending the request directly to the browser. It > >> seems like this should be possible, but I don't know how ugly the code > >> will look yet. > >> > >> > > >> > > >> > > >> > On 2013/03/18 23:16:16, dmichael wrote: > >> >> > >> >> > https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h > >> >> File ppapi/cpp/file_ref.h (right): > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h#newco... > >> >> > >> >> ppapi/cpp/file_ref.h:157: int32_t Query(PP_FileInfo* info, const > >> >> CompletionCallback& callback); > >> >> Please use "CompletionCallbackWithOutput<PP_FileInfo>" instead > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages.h > >> >> > >> >> File ppapi/proxy/ppapi_messages.h (right): > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages... > >> >> > >> >> ppapi/proxy/ppapi_messages.h:813: PP_FileInfo /* info */) > >> >> It doesn't look like you're using this message > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> >> > >> >> File ppapi/proxy/ppb_file_ref_proxy.cc (right): > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> >> > >> >> ppapi/proxy/ppb_file_ref_proxy.cc:10: #include > "base/debug/stack_trace.h" > >> >> ^^ leftover from debugging > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> >> > >> >> ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, > >> >> PP_FileInfo*> PendingFileInfoMap; > >> >> It looks like you're using |int| instead of |unsigned int| for the > >> >> callback id > >> >> elsewhere. > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> >> > >> >> ppapi/proxy/ppb_file_ref_proxy.cc:183: PP_FileInfo *target_info = > >> > > >> > found->second; > >> >> > >> >> nit: '*' should be with PP_FileInfo > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> >> > >> >> ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, > >> >> sizeof(tmp_info)); > >> >> Shouldn't this just be done in PPB_FileRef_Impl? It seems like you > >> >> shouldn't > >> >> need to special case this here > >> > > >> > > >> > > >> > > >> > https://codereview.chromium.org/12817009/ > -- Best regards, Yuzhu Shen.
On Tue, Mar 19, 2013 at 10:41 AM, Yuzhu Shen <yzshen@google.com> wrote: > Hi, Justin. > > I have a question: It looks like this change will directly go to stable. I > thought we usually put new interfaces in dev first. Have we considered > it thoroughly before doing so? > This isn't a new interface, just a new function. We don't really have a good process for adding a function in "Dev" to a stable interface. I guess we could have a parallel Dev interface that works with the same PP_Resource? But we don't normally do that. For justification, see discussion on the bug: https://code.google.com/p/chromium/issues/detail?id=170721 and in this pepper-team thread (internal only, sorry): https://groups.google.com/a/google.com/d/msg/pepper-team/vbTKXZJ0zec/JxEu_VqO... We want it for two reasons: 1) So you can query a Directory, which is currently not possible AFAIK 2) To be able to query faster, since you don't have to create a FileIO to do it. It sounds like this doesn't really solve 2 yet. So we should probably work towards refactoring this interface and doing the FileIO implementation changes we talked about before adding this API. > > Thanks! > > > On Tue, Mar 19, 2013 at 9:34 AM, Justin TerAvest <teravest@google.com>wrote: > >> On Tue, Mar 19, 2013 at 10:30 AM, Raymes Khoury <raymes@google.com> >> wrote: >> >> I'll take a look at sending the request directly to the browser. It >> >> seems like this should be possible, but I don't know how ugly the code >> >> will look yet. >> > >> > This will probably require some ugly hacks until we move file ref to >> > the new proxy model. (just something to keep in mind - if it's a very >> > urgent performance requirement please go ahead otherwise let's >> > consider doing the refactor first). >> >> I talked with Dave a little about this earlier this morning. >> In addition to refactoring to the new proxy model, there have been >> some discussions about changing how FileIO works, potentially sending >> file desciptors to the plugin process so it can read or write >> directly. It looks like the discussion is at >> http://code.google.com/p/chromium/issues/detail?id=194304 >> >> I think it makes sense to get this resolved before implementing >> FileRef::Query. I'm going to do some reading up today to make sure I >> understand what direction we're headed. >> >> > >> > On Tue, Mar 19, 2013 at 7:41 AM, Justin TerAvest <teravest@google.com> >> wrote: >> >> >> >> On Mon, Mar 18, 2013 at 6:01 PM, <yusukes@chromium.org> wrote: >> >> > Thanks for the work! drive-by non-codereview comment: >> >> > >> >> > I tested the new API with my PPAPI plugin, and found that >> >> > pp::FileRef::Query() >> >> > was more than 2 times slower than pp::FileIO::Query(). On my Z620, >> >> > FileRef::Query is about 3.8ms/call and FileIO::Query is about >> 1.5ms/call. >> >> > >> >> > chrome://tracing shows that pp::FileRef::Query() is implemented in >> >> > Chrome_FileThread (in the browser process) while pp::FileIO::Query() >> is in >> >> > Renderer::FILE. I know almost nothing about PPAPI internals, but >> would it be >> >> > possible to do it in a renderer (or to send the IPC directly from >> the plugin >> >> > to >> >> > the browser) so that we can eliminate the additional >> renderer-browser IPC >> >> > cost? >> >> >> >> I'll take a look at sending the request directly to the browser. It >> >> seems like this should be possible, but I don't know how ugly the code >> >> will look yet. >> >> >> >> > >> >> > >> >> > >> >> > On 2013/03/18 23:16:16, dmichael wrote: >> >> >> >> >> >> >> https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h >> >> >> File ppapi/cpp/file_ref.h (right): >> >> > >> >> > >> >> > >> >> > >> https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h#newco... >> >> >> >> >> >> ppapi/cpp/file_ref.h:157: int32_t Query(PP_FileInfo* info, const >> >> >> CompletionCallback& callback); >> >> >> Please use "CompletionCallbackWithOutput<PP_FileInfo>" instead >> >> > >> >> > >> >> > >> >> > >> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages.h >> >> >> >> >> >> File ppapi/proxy/ppapi_messages.h (right): >> >> > >> >> > >> >> > >> >> > >> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages... >> >> >> >> >> >> ppapi/proxy/ppapi_messages.h:813: PP_FileInfo /* info */) >> >> >> It doesn't look like you're using this message >> >> > >> >> > >> >> > >> >> > >> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> >> >> File ppapi/proxy/ppb_file_ref_proxy.cc (right): >> >> > >> >> > >> >> > >> >> > >> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:10: #include >> "base/debug/stack_trace.h" >> >> >> ^^ leftover from debugging >> >> > >> >> > >> >> > >> >> > >> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, >> >> >> PP_FileInfo*> PendingFileInfoMap; >> >> >> It looks like you're using |int| instead of |unsigned int| for the >> >> >> callback id >> >> >> elsewhere. >> >> > >> >> > >> >> > >> >> > >> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:183: PP_FileInfo *target_info = >> >> > >> >> > found->second; >> >> >> >> >> >> nit: '*' should be with PP_FileInfo >> >> > >> >> > >> >> > >> >> > >> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, >> >> >> sizeof(tmp_info)); >> >> >> Shouldn't this just be done in PPB_FileRef_Impl? It seems like you >> >> >> shouldn't >> >> >> need to special case this here >> >> > >> >> > >> >> > >> >> > >> >> > https://codereview.chromium.org/12817009/ >> > > > > -- > Best regards, > Yuzhu Shen. >
On Tue, Mar 19, 2013 at 9:51 AM, David Michael <dmichael@chromium.org>wrote: > > > > On Tue, Mar 19, 2013 at 10:41 AM, Yuzhu Shen <yzshen@google.com> wrote: > >> Hi, Justin. >> >> I have a question: It looks like this change will directly go to stable. >> I thought we usually put new interfaces in dev first. Have we considered >> it thoroughly before doing so? >> > This isn't a new interface, just a new function. We don't really have a > good process for adding a function in "Dev" to a stable interface. I guess > we could have a parallel Dev interface that works with the same > PP_Resource? But we don't normally do that. > Yes. I think it is easy to have a parallel PPB_FileRef_Dev v1.1 that works with the same PP_Resource (if we want to). > > For justification, see discussion on the bug: > https://code.google.com/p/chromium/issues/detail?id=170721 > and in this pepper-team thread (internal only, sorry): > > https://groups.google.com/a/google.com/d/msg/pepper-team/vbTKXZJ0zec/JxEu_VqO... > > We want it for two reasons: > 1) So you can query a Directory, which is currently not possible AFAIK > 2) To be able to query faster, since you don't have to create a FileIO to > do it. > > It sounds like this doesn't really solve 2 yet. So we should probably work > towards refactoring this interface and doing the FileIO implementation > changes we talked about before adding this API. > > Thanks for explaining! I am fine with this change if it has been considered carefully. I just want to make sure people have thought about it. Not all changes to stable interfaces are 'stable' automatically. We should put them in dev if they need some time to stabilize. > > >> >> Thanks! >> >> >> On Tue, Mar 19, 2013 at 9:34 AM, Justin TerAvest <teravest@google.com>wrote: >> >>> On Tue, Mar 19, 2013 at 10:30 AM, Raymes Khoury <raymes@google.com> >>> wrote: >>> >> I'll take a look at sending the request directly to the browser. It >>> >> seems like this should be possible, but I don't know how ugly the code >>> >> will look yet. >>> > >>> > This will probably require some ugly hacks until we move file ref to >>> > the new proxy model. (just something to keep in mind - if it's a very >>> > urgent performance requirement please go ahead otherwise let's >>> > consider doing the refactor first). >>> >>> I talked with Dave a little about this earlier this morning. >>> In addition to refactoring to the new proxy model, there have been >>> some discussions about changing how FileIO works, potentially sending >>> file desciptors to the plugin process so it can read or write >>> directly. It looks like the discussion is at >>> http://code.google.com/p/chromium/issues/detail?id=194304 >>> >>> I think it makes sense to get this resolved before implementing >>> FileRef::Query. I'm going to do some reading up today to make sure I >>> understand what direction we're headed. >>> >>> > >>> > On Tue, Mar 19, 2013 at 7:41 AM, Justin TerAvest <teravest@google.com> >>> wrote: >>> >> >>> >> On Mon, Mar 18, 2013 at 6:01 PM, <yusukes@chromium.org> wrote: >>> >> > Thanks for the work! drive-by non-codereview comment: >>> >> > >>> >> > I tested the new API with my PPAPI plugin, and found that >>> >> > pp::FileRef::Query() >>> >> > was more than 2 times slower than pp::FileIO::Query(). On my Z620, >>> >> > FileRef::Query is about 3.8ms/call and FileIO::Query is about >>> 1.5ms/call. >>> >> > >>> >> > chrome://tracing shows that pp::FileRef::Query() is implemented in >>> >> > Chrome_FileThread (in the browser process) while >>> pp::FileIO::Query() is in >>> >> > Renderer::FILE. I know almost nothing about PPAPI internals, but >>> would it be >>> >> > possible to do it in a renderer (or to send the IPC directly from >>> the plugin >>> >> > to >>> >> > the browser) so that we can eliminate the additional >>> renderer-browser IPC >>> >> > cost? >>> >> >>> >> I'll take a look at sending the request directly to the browser. It >>> >> seems like this should be possible, but I don't know how ugly the code >>> >> will look yet. >>> >> >>> >> > >>> >> > >>> >> > >>> >> > On 2013/03/18 23:16:16, dmichael wrote: >>> >> >> >>> >> >> >>> https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h >>> >> >> File ppapi/cpp/file_ref.h (right): >>> >> > >>> >> > >>> >> > >>> >> > >>> https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h#newco... >>> >> >> >>> >> >> ppapi/cpp/file_ref.h:157: int32_t Query(PP_FileInfo* info, const >>> >> >> CompletionCallback& callback); >>> >> >> Please use "CompletionCallbackWithOutput<PP_FileInfo>" instead >>> >> > >>> >> > >>> >> > >>> >> > >>> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages.h >>> >> >> >>> >> >> File ppapi/proxy/ppapi_messages.h (right): >>> >> > >>> >> > >>> >> > >>> >> > >>> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages... >>> >> >> >>> >> >> ppapi/proxy/ppapi_messages.h:813: PP_FileInfo /* info */) >>> >> >> It doesn't look like you're using this message >>> >> > >>> >> > >>> >> > >>> >> > >>> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >>> >> >> >>> >> >> File ppapi/proxy/ppb_file_ref_proxy.cc (right): >>> >> > >>> >> > >>> >> > >>> >> > >>> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >>> >> >> >>> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:10: #include >>> "base/debug/stack_trace.h" >>> >> >> ^^ leftover from debugging >>> >> > >>> >> > >>> >> > >>> >> > >>> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >>> >> >> >>> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned >>> int, >>> >> >> PP_FileInfo*> PendingFileInfoMap; >>> >> >> It looks like you're using |int| instead of |unsigned int| for the >>> >> >> callback id >>> >> >> elsewhere. >>> >> > >>> >> > >>> >> > >>> >> > >>> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >>> >> >> >>> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:183: PP_FileInfo *target_info = >>> >> > >>> >> > found->second; >>> >> >> >>> >> >> nit: '*' should be with PP_FileInfo >>> >> > >>> >> > >>> >> > >>> >> > >>> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >>> >> >> >>> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, >>> >> >> sizeof(tmp_info)); >>> >> >> Shouldn't this just be done in PPB_FileRef_Impl? It seems like you >>> >> >> shouldn't >>> >> >> need to special case this here >>> >> > >>> >> > >>> >> > >>> >> > >>> >> > https://codereview.chromium.org/12817009/ >>> >> >> >> >> -- >> Best regards, >> Yuzhu Shen. >> > > -- Best regards, Yuzhu Shen.
On 2013/03/19 16:35:18, teravest_google.com wrote: > On Tue, Mar 19, 2013 at 10:30 AM, Raymes Khoury <mailto:raymes@google.com> wrote: > >> I'll take a look at sending the request directly to the browser. It > >> seems like this should be possible, but I don't know how ugly the code > >> will look yet. > > > > This will probably require some ugly hacks until we move file ref to > > the new proxy model. (just something to keep in mind - if it's a very > > urgent performance requirement please go ahead otherwise let's > > consider doing the refactor first). I think our (internal) project, which is performance sensitive, would become the first user of the new API. > I talked with Dave a little about this earlier this morning. > In addition to refactoring to the new proxy model, there have been > some discussions about changing how FileIO works, potentially sending > file desciptors to the plugin process so it can read or write > directly. It looks like the discussion is at > http://code.google.com/p/chromium/issues/detail?id=194304 > > I think it makes sense to get this resolved before implementing > FileRef::Query. I'm going to do some reading up today to make sure I > understand what direction we're headed. It looks like improving pp::FileRef::Query performance more is not a trivial task... Then, if submitting this CL as-is wouldn't be difficult, and if the IPC refactoring discussed at crbug.com/194304 would take time, say >2 weeks, what about taking the following steps? This would be the best for our project. 1. Submit this change first to introduce pp::FileRef::Query() 2. Then refactor the IPC code to make FileIo::Open, FileRef::Delete, FileRef::Rename, FileRef::MakeDirectory, and FileRef::Query faster. We're working on a library which is similar to nacl_mount, and need an API to implement POSIX's access() and stat() in an efficient manner. Currently we have to call FileIO::Open and FileIO::Query to implement them and calling the two APIs takes ~8ms (6-7ms for FileIO::Open, 1-2ms for FileIO::Query). 8ms/call is not fast enough for us and the performance issue is actually blocking us right now. With your current pp::FileRef::Query implementation, the performance doubles (less than 4ms/call) and it would unblock us. Thanks! > > > > > On Tue, Mar 19, 2013 at 7:41 AM, Justin TerAvest <mailto:teravest@google.com> wrote: > >> > >> On Mon, Mar 18, 2013 at 6:01 PM, <mailto:yusukes@chromium.org> wrote: > >> > Thanks for the work! drive-by non-codereview comment: > >> > > >> > I tested the new API with my PPAPI plugin, and found that > >> > pp::FileRef::Query() > >> > was more than 2 times slower than pp::FileIO::Query(). On my Z620, > >> > FileRef::Query is about 3.8ms/call and FileIO::Query is about 1.5ms/call. > >> > > >> > chrome://tracing shows that pp::FileRef::Query() is implemented in > >> > Chrome_FileThread (in the browser process) while pp::FileIO::Query() is in > >> > Renderer::FILE. I know almost nothing about PPAPI internals, but would it > be > >> > possible to do it in a renderer (or to send the IPC directly from the > plugin > >> > to > >> > the browser) so that we can eliminate the additional renderer-browser IPC > >> > cost? > >> > >> I'll take a look at sending the request directly to the browser. It > >> seems like this should be possible, but I don't know how ugly the code > >> will look yet. > >> > >> > > >> > > >> > > >> > On 2013/03/18 23:16:16, dmichael wrote: > >> >> > >> >> https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h > >> >> File ppapi/cpp/file_ref.h (right): > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h#newco... > >> >> > >> >> ppapi/cpp/file_ref.h:157: int32_t Query(PP_FileInfo* info, const > >> >> CompletionCallback& callback); > >> >> Please use "CompletionCallbackWithOutput<PP_FileInfo>" instead > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages.h > >> >> > >> >> File ppapi/proxy/ppapi_messages.h (right): > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages... > >> >> > >> >> ppapi/proxy/ppapi_messages.h:813: PP_FileInfo /* info */) > >> >> It doesn't look like you're using this message > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> >> > >> >> File ppapi/proxy/ppb_file_ref_proxy.cc (right): > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> >> > >> >> ppapi/proxy/ppb_file_ref_proxy.cc:10: #include "base/debug/stack_trace.h" > >> >> ^^ leftover from debugging > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> >> > >> >> ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, > >> >> PP_FileInfo*> PendingFileInfoMap; > >> >> It looks like you're using |int| instead of |unsigned int| for the > >> >> callback id > >> >> elsewhere. > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> >> > >> >> ppapi/proxy/ppb_file_ref_proxy.cc:183: PP_FileInfo *target_info = > >> > > >> > found->second; > >> >> > >> >> nit: '*' should be with PP_FileInfo > >> > > >> > > >> > > >> > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> >> > >> >> ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, > >> >> sizeof(tmp_info)); > >> >> Shouldn't this just be done in PPB_FileRef_Impl? It seems like you > >> >> shouldn't > >> >> need to special case this here > >> > > >> > > >> > > >> > > >> > https://codereview.chromium.org/12817009/
Yusuke, Your plan sounds reasonable to me. I think the matter of using file desciptors in the plugin will take a while to be resolved, so here's what I'll to do: 1. Refactor FileRef to use the "new proxy" model. This will take a little while, as the FileRef code is a little complicated, and has a bunch of juggling through FileRef_Shared. 2. Implement FileRef::Query() in terms of a plugin->browser message. 3. Possibly move over other FileRef methods to make them faster, if it's helpful. I don't have an estimate for how long this will take (yet), because I don't know how much work (1) will take. I can submit this change as is, though I don't know if it's useful at all with the current performance. On Tue, Mar 19, 2013 at 3:44 PM, <yusukes@chromium.org> wrote: > On 2013/03/19 16:35:18, teravest_google.com wrote: >> >> On Tue, Mar 19, 2013 at 10:30 AM, Raymes Khoury <mailto:raymes@google.com> > > wrote: >> >> >> I'll take a look at sending the request directly to the browser. It >> >> seems like this should be possible, but I don't know how ugly the code >> >> will look yet. >> > >> > This will probably require some ugly hacks until we move file ref to >> > the new proxy model. (just something to keep in mind - if it's a very >> > urgent performance requirement please go ahead otherwise let's >> > consider doing the refactor first). > > > I think our (internal) project, which is performance sensitive, would become > the > first user of the new API. > > >> I talked with Dave a little about this earlier this morning. >> In addition to refactoring to the new proxy model, there have been >> some discussions about changing how FileIO works, potentially sending >> file desciptors to the plugin process so it can read or write >> directly. It looks like the discussion is at >> http://code.google.com/p/chromium/issues/detail?id=194304 > > >> I think it makes sense to get this resolved before implementing >> FileRef::Query. I'm going to do some reading up today to make sure I >> understand what direction we're headed. > > > It looks like improving pp::FileRef::Query performance more is not a trivial > task... Then, if submitting this CL as-is wouldn't be difficult, and if the > IPC > refactoring discussed at crbug.com/194304 would take time, say >2 weeks, > what > about taking the following steps? This would be the best for our project. > > 1. Submit this change first to introduce pp::FileRef::Query() > 2. Then refactor the IPC code to make FileIo::Open, FileRef::Delete, > FileRef::Rename, FileRef::MakeDirectory, and FileRef::Query faster. > > We're working on a library which is similar to nacl_mount, and need an API > to > implement POSIX's access() and stat() in an efficient manner. Currently we > have > to call FileIO::Open and FileIO::Query to implement them and calling the two > APIs takes ~8ms (6-7ms for FileIO::Open, 1-2ms for FileIO::Query). 8ms/call > is > not fast enough for us and the performance issue is actually blocking us > right > now. With your current pp::FileRef::Query implementation, the performance > doubles (less than 4ms/call) and it would unblock us. > > Thanks! > > >> > >> >> > On Tue, Mar 19, 2013 at 7:41 AM, Justin TerAvest > > <mailto:teravest@google.com> wrote: > >> >> >> >> On Mon, Mar 18, 2013 at 6:01 PM, <mailto:yusukes@chromium.org> wrote: >> >> > Thanks for the work! drive-by non-codereview comment: >> >> > >> >> > I tested the new API with my PPAPI plugin, and found that >> >> > pp::FileRef::Query() >> >> > was more than 2 times slower than pp::FileIO::Query(). On my Z620, >> >> > FileRef::Query is about 3.8ms/call and FileIO::Query is about >> >> > 1.5ms/call. >> >> > >> >> > chrome://tracing shows that pp::FileRef::Query() is implemented in >> >> > Chrome_FileThread (in the browser process) while pp::FileIO::Query() >> >> > is > > in >> >> >> > Renderer::FILE. I know almost nothing about PPAPI internals, but >> >> > would it >> be >> >> > possible to do it in a renderer (or to send the IPC directly from the >> plugin >> >> > to >> >> > the browser) so that we can eliminate the additional renderer-browser >> >> > IPC >> >> > cost? >> >> >> >> I'll take a look at sending the request directly to the browser. It >> >> seems like this should be possible, but I don't know how ugly the code >> >> will look yet. >> >> >> >> > >> >> > >> >> > >> >> > On 2013/03/18 23:16:16, dmichael wrote: >> >> >> >> >> >> >> >> >> https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h >> >> >> File ppapi/cpp/file_ref.h (right): >> >> > >> >> > >> >> > >> >> > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h#newco... >> >> >> >> >> >> >> ppapi/cpp/file_ref.h:157: int32_t Query(PP_FileInfo* info, const >> >> >> CompletionCallback& callback); >> >> >> Please use "CompletionCallbackWithOutput<PP_FileInfo>" instead >> >> > >> >> > >> >> > >> >> > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages.h >> >> >> >> >> >> >> File ppapi/proxy/ppapi_messages.h (right): >> >> > >> >> > >> >> > >> >> > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages... >> >> >> >> >> >> >> ppapi/proxy/ppapi_messages.h:813: PP_FileInfo /* info */) >> >> >> It doesn't look like you're using this message >> >> > >> >> > >> >> > >> >> > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> >> >> >> File ppapi/proxy/ppb_file_ref_proxy.cc (right): >> >> > >> >> > >> >> > >> >> > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:10: #include > > "base/debug/stack_trace.h" >> >> >> >> ^^ leftover from debugging >> >> > >> >> > >> >> > >> >> > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, >> >> >> PP_FileInfo*> PendingFileInfoMap; >> >> >> It looks like you're using |int| instead of |unsigned int| for the >> >> >> callback id >> >> >> elsewhere. >> >> > >> >> > >> >> > >> >> > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:183: PP_FileInfo *target_info = >> >> > >> >> > found->second; >> >> >> >> >> >> nit: '*' should be with PP_FileInfo >> >> > >> >> > >> >> > >> >> > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> >> >> >> >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, >> >> >> sizeof(tmp_info)); >> >> >> Shouldn't this just be done in PPB_FileRef_Impl? It seems like you >> >> >> shouldn't >> >> >> need to special case this here >> >> > >> >> > >> >> > >> >> > >> >> > https://codereview.chromium.org/12817009/ > > > > https://codereview.chromium.org/12817009/
On 2013/03/20 17:35:46, teravest wrote: > Yusuke, > Your plan sounds reasonable to me. > > I think the matter of using file desciptors in the plugin will take a > while to be resolved, so here's what I'll to do: > 1. Refactor FileRef to use the "new proxy" model. This will take a > little while, as the FileRef code is a little complicated, and has a > bunch of juggling through FileRef_Shared. > 2. Implement FileRef::Query() in terms of a plugin->browser message. > 3. Possibly move over other FileRef methods to make them faster, if > it's helpful. > > I don't have an estimate for how long this will take (yet), because I > don't know how much work (1) will take. > > I can submit this change as is, though I don't know if it's useful at > all with the current performance. The current performance (<4 ms/call on Z620) is still very useful at least for us. -Yusuke > > On Tue, Mar 19, 2013 at 3:44 PM, <mailto:yusukes@chromium.org> wrote: > > On 2013/03/19 16:35:18, http://teravest_google.com wrote: > >> > >> On Tue, Mar 19, 2013 at 10:30 AM, Raymes Khoury <mailto:raymes@google.com> > > > > wrote: > >> > >> >> I'll take a look at sending the request directly to the browser. It > >> >> seems like this should be possible, but I don't know how ugly the code > >> >> will look yet. > >> > > >> > This will probably require some ugly hacks until we move file ref to > >> > the new proxy model. (just something to keep in mind - if it's a very > >> > urgent performance requirement please go ahead otherwise let's > >> > consider doing the refactor first). > > > > > > I think our (internal) project, which is performance sensitive, would become > > the > > first user of the new API. > > > > > >> I talked with Dave a little about this earlier this morning. > >> In addition to refactoring to the new proxy model, there have been > >> some discussions about changing how FileIO works, potentially sending > >> file desciptors to the plugin process so it can read or write > >> directly. It looks like the discussion is at > >> http://code.google.com/p/chromium/issues/detail?id=194304 > > > > > >> I think it makes sense to get this resolved before implementing > >> FileRef::Query. I'm going to do some reading up today to make sure I > >> understand what direction we're headed. > > > > > > It looks like improving pp::FileRef::Query performance more is not a trivial > > task... Then, if submitting this CL as-is wouldn't be difficult, and if the > > IPC > > refactoring discussed at crbug.com/194304 would take time, say >2 weeks, > > what > > about taking the following steps? This would be the best for our project. > > > > 1. Submit this change first to introduce pp::FileRef::Query() > > 2. Then refactor the IPC code to make FileIo::Open, FileRef::Delete, > > FileRef::Rename, FileRef::MakeDirectory, and FileRef::Query faster. > > > > We're working on a library which is similar to nacl_mount, and need an API > > to > > implement POSIX's access() and stat() in an efficient manner. Currently we > > have > > to call FileIO::Open and FileIO::Query to implement them and calling the two > > APIs takes ~8ms (6-7ms for FileIO::Open, 1-2ms for FileIO::Query). 8ms/call > > is > > not fast enough for us and the performance issue is actually blocking us > > right > > now. With your current pp::FileRef::Query implementation, the performance > > doubles (less than 4ms/call) and it would unblock us. > > > > Thanks! > > > > > >> > > >> > >> > On Tue, Mar 19, 2013 at 7:41 AM, Justin TerAvest > > > > <mailto:teravest@google.com> wrote: > > > >> >> > >> >> On Mon, Mar 18, 2013 at 6:01 PM, <mailto:yusukes@chromium.org> wrote: > >> >> > Thanks for the work! drive-by non-codereview comment: > >> >> > > >> >> > I tested the new API with my PPAPI plugin, and found that > >> >> > pp::FileRef::Query() > >> >> > was more than 2 times slower than pp::FileIO::Query(). On my Z620, > >> >> > FileRef::Query is about 3.8ms/call and FileIO::Query is about > >> >> > 1.5ms/call. > >> >> > > >> >> > chrome://tracing shows that pp::FileRef::Query() is implemented in > >> >> > Chrome_FileThread (in the browser process) while pp::FileIO::Query() > >> >> > is > > > > in > >> > >> >> > Renderer::FILE. I know almost nothing about PPAPI internals, but > >> >> > would it > >> be > >> >> > possible to do it in a renderer (or to send the IPC directly from the > >> plugin > >> >> > to > >> >> > the browser) so that we can eliminate the additional renderer-browser > >> >> > IPC > >> >> > cost? > >> >> > >> >> I'll take a look at sending the request directly to the browser. It > >> >> seems like this should be possible, but I don't know how ugly the code > >> >> will look yet. > >> >> > >> >> > > >> >> > > >> >> > > >> >> > On 2013/03/18 23:16:16, dmichael wrote: > >> >> >> > >> >> >> > >> >> >> > https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h > >> >> >> File ppapi/cpp/file_ref.h (right): > >> >> > > >> >> > > >> >> > > >> >> > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h#newco... > >> > >> >> >> > >> >> >> ppapi/cpp/file_ref.h:157: int32_t Query(PP_FileInfo* info, const > >> >> >> CompletionCallback& callback); > >> >> >> Please use "CompletionCallbackWithOutput<PP_FileInfo>" instead > >> >> > > >> >> > > >> >> > > >> >> > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages.h > >> > >> >> >> > >> >> >> File ppapi/proxy/ppapi_messages.h (right): > >> >> > > >> >> > > >> >> > > >> >> > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages... > >> > >> >> >> > >> >> >> ppapi/proxy/ppapi_messages.h:813: PP_FileInfo /* info */) > >> >> >> It doesn't look like you're using this message > >> >> > > >> >> > > >> >> > > >> >> > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> > >> >> >> > >> >> >> File ppapi/proxy/ppb_file_ref_proxy.cc (right): > >> >> > > >> >> > > >> >> > > >> >> > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> > >> >> >> > >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:10: #include > > > > "base/debug/stack_trace.h" > >> > >> >> >> ^^ leftover from debugging > >> >> > > >> >> > > >> >> > > >> >> > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> > >> >> >> > >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, > >> >> >> PP_FileInfo*> PendingFileInfoMap; > >> >> >> It looks like you're using |int| instead of |unsigned int| for the > >> >> >> callback id > >> >> >> elsewhere. > >> >> > > >> >> > > >> >> > > >> >> > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> > >> >> >> > >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:183: PP_FileInfo *target_info = > >> >> > > >> >> > found->second; > >> >> >> > >> >> >> nit: '*' should be with PP_FileInfo > >> >> > > >> >> > > >> >> > > >> >> > > > > > > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > >> > >> >> >> > >> >> >> ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, > >> >> >> sizeof(tmp_info)); > >> >> >> Shouldn't this just be done in PPB_FileRef_Impl? It seems like you > >> >> >> shouldn't > >> >> >> need to special case this here > >> >> > > >> >> > > >> >> > > >> >> > > >> >> > https://codereview.chromium.org/12817009/ > > > > > > > > https://codereview.chromium.org/12817009/
https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h File ppapi/cpp/file_ref.h (right): https://codereview.chromium.org/12817009/diff/2001/ppapi/cpp/file_ref.h#newco... ppapi/cpp/file_ref.h:157: int32_t Query(PP_FileInfo* info, const CompletionCallback& callback); On 2013/03/18 23:16:16, dmichael wrote: > Please use "CompletionCallbackWithOutput<PP_FileInfo>" instead Done. https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages.h File ppapi/proxy/ppapi_messages.h (right): https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppapi_messages... ppapi/proxy/ppapi_messages.h:813: PP_FileInfo /* info */) On 2013/03/18 23:16:16, dmichael wrote: > It doesn't look like you're using this message Removed. https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... File ppapi/proxy/ppb_file_ref_proxy.cc (right): https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, PP_FileInfo*> PendingFileInfoMap; On 2013/03/18 23:16:16, dmichael wrote: > It looks like you're using |int| instead of |unsigned int| for the callback id > elsewhere. This is a little gross. PpapiMsg_PPBFileRef_CallbackComplete uses an int for the callback_id, but we're obviously using unsigned int internally here. Do you want me to clean this all up as part of this patch? https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... ppapi/proxy/ppb_file_ref_proxy.cc:183: PP_FileInfo *target_info = found->second; On 2013/03/18 23:16:16, dmichael wrote: > nit: '*' should be with PP_FileInfo Done. https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, sizeof(tmp_info)); On 2013/03/18 23:16:16, dmichael wrote: > Shouldn't this just be done in PPB_FileRef_Impl? It seems like you shouldn't > need to special case this here I'm special casing it in the proxy because we can't send uninitialized data over IPC. I don't think we need to zero-out the output parameter in every case.
https://codereview.chromium.org/12817009/diff/19001/ppapi/cpp/file_ref.h File ppapi/cpp/file_ref.h (right): https://codereview.chromium.org/12817009/diff/19001/ppapi/cpp/file_ref.h#newc... ppapi/cpp/file_ref.h:153: /// @param[out] info A pointer to a <code>PP_FileInfo</code> which will be Please update this comment. https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... File ppapi/proxy/ppb_file_ref_proxy.cc (right): https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.cc:50: virtual int32_t Query(PP_FileInfo *info, nit: '*' should be adjacent to PP_FileInfo https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.cc:56: void SetFileInfo(int callback_id, const PP_FileInfo &info); nit: '&' should be adjacent to PP_FileInfo https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.cc:82: PendingFileInfoMap pending_file_infos_; You should do cleanup like |pending_callbacks_| when the last plugin ref was deleted. When the last plugin ref is gone, the plugin doesn't need to keep the output buffers valid. https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.cc:178: void FileRef::SetFileInfo(int callback_id, const PP_FileInfo &info) { ditto. https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.cc:330: PP_FileInfo info; |info| is on the stack, it seems we rely on the fact that callback is called before Query() returns. https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... File ppapi/proxy/ppb_file_ref_proxy.h (right): https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.h:93: PP_FileInfo info, const & please. https://codereview.chromium.org/12817009/diff/19001/ppapi/thunk/ppb_file_ref_... File ppapi/thunk/ppb_file_ref_api.h (right): https://codereview.chromium.org/12817009/diff/19001/ppapi/thunk/ppb_file_ref_... ppapi/thunk/ppb_file_ref_api.h:35: virtual int32_t Query(PP_FileInfo *info, nit: wrong position of '*'. https://codereview.chromium.org/12817009/diff/19001/webkit/plugins/ppapi/ppb_... File webkit/plugins/ppapi/ppb_file_ref_impl.h (right): https://codereview.chromium.org/12817009/diff/19001/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.h:58: PP_FileInfo *info, nit: wrong position of '*'.
https://codereview.chromium.org/12817009/diff/19001/ppapi/cpp/file_ref.h File ppapi/cpp/file_ref.h (right): https://codereview.chromium.org/12817009/diff/19001/ppapi/cpp/file_ref.h#newc... ppapi/cpp/file_ref.h:153: /// @param[out] info A pointer to a <code>PP_FileInfo</code> which will be On 2013/03/21 17:18:11, yzshen1 wrote: > Please update this comment. Done. https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... File ppapi/proxy/ppb_file_ref_proxy.cc (right): https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.cc:50: virtual int32_t Query(PP_FileInfo *info, On 2013/03/21 17:18:11, yzshen1 wrote: > nit: '*' should be adjacent to PP_FileInfo Done. https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.cc:56: void SetFileInfo(int callback_id, const PP_FileInfo &info); On 2013/03/21 17:18:11, yzshen1 wrote: > nit: '&' should be adjacent to PP_FileInfo Done. https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.cc:82: PendingFileInfoMap pending_file_infos_; On 2013/03/21 17:18:11, yzshen1 wrote: > You should do cleanup like |pending_callbacks_| when the last plugin ref was > deleted. > When the last plugin ref is gone, the plugin doesn't need to keep the output > buffers valid. Done. https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.cc:178: void FileRef::SetFileInfo(int callback_id, const PP_FileInfo &info) { On 2013/03/21 17:18:11, yzshen1 wrote: > ditto. Done. https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.cc:330: PP_FileInfo info; On 2013/03/21 17:18:11, yzshen1 wrote: > |info| is on the stack, it seems we rely on the fact that callback is called > before Query() returns. info is on the heap now. https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... File ppapi/proxy/ppb_file_ref_proxy.h (right): https://codereview.chromium.org/12817009/diff/19001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.h:93: PP_FileInfo info, On 2013/03/21 17:18:11, yzshen1 wrote: > const & please. Done. https://codereview.chromium.org/12817009/diff/19001/ppapi/thunk/ppb_file_ref_... File ppapi/thunk/ppb_file_ref_api.h (right): https://codereview.chromium.org/12817009/diff/19001/ppapi/thunk/ppb_file_ref_... ppapi/thunk/ppb_file_ref_api.h:35: virtual int32_t Query(PP_FileInfo *info, On 2013/03/21 17:18:11, yzshen1 wrote: > nit: wrong position of '*'. Done. https://codereview.chromium.org/12817009/diff/19001/webkit/plugins/ppapi/ppb_... File webkit/plugins/ppapi/ppb_file_ref_impl.h (right): https://codereview.chromium.org/12817009/diff/19001/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.h:58: PP_FileInfo *info, On 2013/03/21 17:18:11, yzshen1 wrote: > nit: wrong position of '*'. Done.
https://codereview.chromium.org/12817009/diff/29001/ppapi/proxy/ppb_file_ref_... File ppapi/proxy/ppb_file_ref_proxy.cc (right): https://codereview.chromium.org/12817009/diff/29001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.cc:332: PP_FileInfo* info = new PP_FileInfo(); Unfortunately, this may be leaked. If the proxy object dies before the callback is called, OnQueryCallbackCompleteInHost() won't be run (because |callback_factory_| dies with the proxy object). I think |info| should be deleted when the proxy ojbect goes away, if OnQueryCallbackCompleteInHost() hasn't been called at that point. https://codereview.chromium.org/12817009/diff/29001/ppapi/tests/test_utils.h File ppapi/tests/test_utils.h (right): https://codereview.chromium.org/12817009/diff/29001/ppapi/tests/test_utils.h#... ppapi/tests/test_utils.h:193: OutputT output() { I think this should be OutputT&.
On Thu, Mar 21, 2013 at 3:06 PM, <yzshen@chromium.org> wrote: > > https://codereview.chromium.org/12817009/diff/29001/ppapi/proxy/ppb_file_ref_... > File ppapi/proxy/ppb_file_ref_proxy.cc (right): > > https://codereview.chromium.org/12817009/diff/29001/ppapi/proxy/ppb_file_ref_... > ppapi/proxy/ppb_file_ref_proxy.cc:332: PP_FileInfo* info = new > PP_FileInfo(); > Unfortunately, this may be leaked. If the proxy object dies before the > callback is called, OnQueryCallbackCompleteInHost() won't be run > (because |callback_factory_| dies with the proxy object). > > I think |info| should be deleted when the proxy ojbect goes away, if > OnQueryCallbackCompleteInHost() hasn't been called at that point. Good catch. I use base::Owned() to pass the allocated pointer to the callback now. Thanks to Dave for telling me this exists. > > https://codereview.chromium.org/12817009/diff/29001/ppapi/tests/test_utils.h > File ppapi/tests/test_utils.h (right): > > https://codereview.chromium.org/12817009/diff/29001/ppapi/tests/test_utils.h#... > ppapi/tests/test_utils.h:193: OutputT output() { > I think this should be OutputT&. The implementation can return OutputT instead of OutputT& for some types, so that isn't safe. (We'd return a reference to a temporary). > > https://codereview.chromium.org/12817009/
Thanks Justin! https://codereview.chromium.org/12817009/diff/43001/ppapi/proxy/ppb_file_ref_... File ppapi/proxy/ppb_file_ref_proxy.cc (right): https://codereview.chromium.org/12817009/diff/43001/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.cc:336: base::Owned(info), callback_id); I thought you will need to change your OnQueryCallbackCompleteInHost() signature?
On Thu, Mar 21, 2013 at 4:02 PM, <yzshen@chromium.org> wrote: > Thanks Justin! > > > https://codereview.chromium.org/12817009/diff/43001/ppapi/proxy/ppb_file_ref_... > File ppapi/proxy/ppb_file_ref_proxy.cc (right): > > https://codereview.chromium.org/12817009/diff/43001/ppapi/proxy/ppb_file_ref_... > ppapi/proxy/ppb_file_ref_proxy.cc:336: base::Owned(info), callback_id); > I thought you will need to change your OnQueryCallbackCompleteInHost() > signature? I don't believe so. Here's the example in base/bind_helpers.h: // EXAMPLE OF Owned(): // // void foo(int* arg) { cout << *arg << endl } // // int* pn = new int(1); // Closure foo_callback = Bind(&foo, Owned(pn)); // // foo_callback.Run(); // Prints "1" Am I misunderstanding what you suggest? > > https://codereview.chromium.org/12817009/
https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... File ppapi/proxy/ppb_file_ref_proxy.cc (right): https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, PP_FileInfo*> PendingFileInfoMap; On 2013/03/21 16:45:04, teravest wrote: > On 2013/03/18 23:16:16, dmichael wrote: > > It looks like you're using |int| instead of |unsigned int| for the callback id > > elsewhere. > > This is a little gross. PpapiMsg_PPBFileRef_CallbackComplete uses an int for the > callback_id, but we're obviously using unsigned int internally here. > > Do you want me to clean this all up as part of this patch? > Hmm, I guess you aren't making it worse, so you could do it separately if you want. But it should probably be changed. I'm guessing you could make them it uint32_t everywhere and be more consistent with what other messages do. https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, sizeof(tmp_info)); On 2013/03/21 16:45:04, teravest wrote: > On 2013/03/18 23:16:16, dmichael wrote: > > Shouldn't this just be done in PPB_FileRef_Impl? It seems like you shouldn't > > need to special case this here > > I'm special casing it in the proxy because we can't send uninitialized data over > IPC. I don't think we need to zero-out the output parameter in every case. What if you just implement the host side so that it's guaranteed not to modify the PP_FileInfo (it's probably that way anyway). I think that's consistent with what we do elsewhere. In that case, you can initialize PP_FileInfo to 0 before the call unconditionally, and get rid of the if. WDYT? https://codereview.chromium.org/12817009/diff/43001/webkit/plugins/ppapi/ppb_... File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): https://codereview.chromium.org/12817009/diff/43001/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:299: return PP_ERROR_NOACCESS; Don't we want to support Query for external file systems too? I think FileIO::Query does.
On Thu, Mar 21, 2013 at 4:11 PM, <dmichael@chromium.org> wrote: > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > File ppapi/proxy/ppb_file_ref_proxy.cc (right): > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, > PP_FileInfo*> PendingFileInfoMap; > On 2013/03/21 16:45:04, teravest wrote: >> >> On 2013/03/18 23:16:16, dmichael wrote: >> > It looks like you're using |int| instead of |unsigned int| for the > > callback id >> >> > elsewhere. > > >> This is a little gross. PpapiMsg_PPBFileRef_CallbackComplete uses an > > int for the >> >> callback_id, but we're obviously using unsigned int internally here. > > >> Do you want me to clean this all up as part of this patch? > > > Hmm, I guess you aren't making it worse, so you could do it separately > if you want. But it should probably be changed. I'm guessing you could > make them it uint32_t everywhere and be more consistent with what other > messages do. Fixed throughout. > > > https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... > ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, > sizeof(tmp_info)); > On 2013/03/21 16:45:04, teravest wrote: >> >> On 2013/03/18 23:16:16, dmichael wrote: >> > Shouldn't this just be done in PPB_FileRef_Impl? It seems like you > > shouldn't >> >> > need to special case this here > > >> I'm special casing it in the proxy because we can't send uninitialized > > data over >> >> IPC. I don't think we need to zero-out the output parameter in every > > case. > What if you just implement the host side so that it's guaranteed not to > modify the PP_FileInfo (it's probably that way anyway). I think that's > consistent with what we do elsewhere. In that case, you can initialize > PP_FileInfo to 0 before the call unconditionally, and get rid of the if. > > WDYT? Sounds good. Done. > > https://codereview.chromium.org/12817009/diff/43001/webkit/plugins/ppapi/ppb_... > File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): > > https://codereview.chromium.org/12817009/diff/43001/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:299: return PP_ERROR_NOACCESS; > Don't we want to support Query for external file systems too? I think > FileIO::Query does. I have no idea. This was from the original FileRef::Query code. I figure we can always relax this to work for external file systems later if it makes sense. > > https://codereview.chromium.org/12817009/
> I figure we can always relax this to work for external file systems later if it makes sense. The API behavior is also part of the contract between us and plugins. If we change the behavior later, we will have to increase the version number. Otherwise it causes confusion: the same function doesn't work with external file systems on some Chrome builds, but work on others. Since this is a stable interface, I think it is better to make sure the behavior is what we want from the beginning. On Thu, Mar 21, 2013 at 3:41 PM, Justin TerAvest <teravest@chromium.org> wrote: > On Thu, Mar 21, 2013 at 4:11 PM, <dmichael@chromium.org> wrote: >> >> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> File ppapi/proxy/ppb_file_ref_proxy.cc (right): >> >> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, >> PP_FileInfo*> PendingFileInfoMap; >> On 2013/03/21 16:45:04, teravest wrote: >>> >>> On 2013/03/18 23:16:16, dmichael wrote: >>> > It looks like you're using |int| instead of |unsigned int| for the >> >> callback id >>> >>> > elsewhere. >> >> >>> This is a little gross. PpapiMsg_PPBFileRef_CallbackComplete uses an >> >> int for the >>> >>> callback_id, but we're obviously using unsigned int internally here. >> >> >>> Do you want me to clean this all up as part of this patch? >> >> >> Hmm, I guess you aren't making it worse, so you could do it separately >> if you want. But it should probably be changed. I'm guessing you could >> make them it uint32_t everywhere and be more consistent with what other >> messages do. > > Fixed throughout. > >> >> >> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >> ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, >> sizeof(tmp_info)); >> On 2013/03/21 16:45:04, teravest wrote: >>> >>> On 2013/03/18 23:16:16, dmichael wrote: >>> > Shouldn't this just be done in PPB_FileRef_Impl? It seems like you >> >> shouldn't >>> >>> > need to special case this here >> >> >>> I'm special casing it in the proxy because we can't send uninitialized >> >> data over >>> >>> IPC. I don't think we need to zero-out the output parameter in every >> >> case. >> What if you just implement the host side so that it's guaranteed not to >> modify the PP_FileInfo (it's probably that way anyway). I think that's >> consistent with what we do elsewhere. In that case, you can initialize >> PP_FileInfo to 0 before the call unconditionally, and get rid of the if. >> >> WDYT? > > Sounds good. Done. > >> >> https://codereview.chromium.org/12817009/diff/43001/webkit/plugins/ppapi/ppb_... >> File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): >> >> https://codereview.chromium.org/12817009/diff/43001/webkit/plugins/ppapi/ppb_... >> webkit/plugins/ppapi/ppb_file_ref_impl.cc:299: return PP_ERROR_NOACCESS; >> Don't we want to support Query for external file systems too? I think >> FileIO::Query does. > > I have no idea. This was from the original FileRef::Query code. I > figure we can always relax this to work for external file systems > later if it makes sense. > >> >> https://codereview.chromium.org/12817009/ -- Best regards, Yuzhu Shen.
https://codereview.chromium.org/12817009/diff/45019/ppapi/cpp/file_ref.cc File ppapi/cpp/file_ref.cc (right): https://codereview.chromium.org/12817009/diff/45019/ppapi/cpp/file_ref.cc#new... ppapi/cpp/file_ref.cc:110: if (!has_interface<PPB_FileRef_1_0>()) I guess this (and all other v1.0 methods) should be like: if (has_interface<1_1>()) get_interface<1_1>()->Rename(...); else if (has_interface<1_0>()) get_interface<1_0>()->Rename(...); else return cc.MayForce(PP_ERROR_NOINTERFACE); http://src.chromium.org/viewvc/chrome/trunk/src/ppapi/cpp/file_io.cc?view=markup does that.
On Thu, Mar 21, 2013 at 5:33 PM, Yuzhu Shen <yzshen@google.com> wrote: >> I figure we can always relax this to work for external file systems later if it makes sense. > The API behavior is also part of the contract between us and plugins. > If we change the behavior later, we will have to increase the version > number. Otherwise it causes confusion: the same function doesn't work > with external file systems on some Chrome builds, but work on others. > > Since this is a stable interface, I think it is better to make sure > the behavior is what we want from the beginning. That makes sense. I added support this morning for Query() for external filesystems (and a supporting test case). > > > On Thu, Mar 21, 2013 at 3:41 PM, Justin TerAvest <teravest@chromium.org> wrote: >> On Thu, Mar 21, 2013 at 4:11 PM, <dmichael@chromium.org> wrote: >>> >>> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >>> File ppapi/proxy/ppb_file_ref_proxy.cc (right): >>> >>> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >>> ppapi/proxy/ppb_file_ref_proxy.cc:82: typedef std::map<unsigned int, >>> PP_FileInfo*> PendingFileInfoMap; >>> On 2013/03/21 16:45:04, teravest wrote: >>>> >>>> On 2013/03/18 23:16:16, dmichael wrote: >>>> > It looks like you're using |int| instead of |unsigned int| for the >>> >>> callback id >>>> >>>> > elsewhere. >>> >>> >>>> This is a little gross. PpapiMsg_PPBFileRef_CallbackComplete uses an >>> >>> int for the >>>> >>>> callback_id, but we're obviously using unsigned int internally here. >>> >>> >>>> Do you want me to clean this all up as part of this patch? >>> >>> >>> Hmm, I guess you aren't making it worse, so you could do it separately >>> if you want. But it should probably be changed. I'm guessing you could >>> make them it uint32_t everywhere and be more consistent with what other >>> messages do. >> >> Fixed throughout. >> >>> >>> >>> https://codereview.chromium.org/12817009/diff/2001/ppapi/proxy/ppb_file_ref_p... >>> ppapi/proxy/ppb_file_ref_proxy.cc:391: memset(&tmp_info, 0, >>> sizeof(tmp_info)); >>> On 2013/03/21 16:45:04, teravest wrote: >>>> >>>> On 2013/03/18 23:16:16, dmichael wrote: >>>> > Shouldn't this just be done in PPB_FileRef_Impl? It seems like you >>> >>> shouldn't >>>> >>>> > need to special case this here >>> >>> >>>> I'm special casing it in the proxy because we can't send uninitialized >>> >>> data over >>>> >>>> IPC. I don't think we need to zero-out the output parameter in every >>> >>> case. >>> What if you just implement the host side so that it's guaranteed not to >>> modify the PP_FileInfo (it's probably that way anyway). I think that's >>> consistent with what we do elsewhere. In that case, you can initialize >>> PP_FileInfo to 0 before the call unconditionally, and get rid of the if. >>> >>> WDYT? >> >> Sounds good. Done. >> >>> >>> https://codereview.chromium.org/12817009/diff/43001/webkit/plugins/ppapi/ppb_... >>> File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): >>> >>> https://codereview.chromium.org/12817009/diff/43001/webkit/plugins/ppapi/ppb_... >>> webkit/plugins/ppapi/ppb_file_ref_impl.cc:299: return PP_ERROR_NOACCESS; >>> Don't we want to support Query for external file systems too? I think >>> FileIO::Query does. >> >> I have no idea. This was from the original FileRef::Query code. I >> figure we can always relax this to work for external file systems >> later if it makes sense. >> >>> >>> https://codereview.chromium.org/12817009/ > > > > -- > Best regards, > Yuzhu Shen.
On Sun, Mar 24, 2013 at 2:00 AM, <yusukes@chromium.org> wrote: > > https://codereview.chromium.org/12817009/diff/45019/ppapi/cpp/file_ref.cc > File ppapi/cpp/file_ref.cc (right): > > https://codereview.chromium.org/12817009/diff/45019/ppapi/cpp/file_ref.cc#new... > ppapi/cpp/file_ref.cc:110: if (!has_interface<PPB_FileRef_1_0>()) > I guess this (and all other v1.0 methods) should be like: > > if (has_interface<1_1>()) > get_interface<1_1>()->Rename(...); > else if (has_interface<1_0>()) > get_interface<1_0>()->Rename(...); > else > return cc.MayForce(PP_ERROR_NOINTERFACE); > > http://src.chromium.org/viewvc/chrome/trunk/src/ppapi/cpp/file_io.cc?view=markup > does that. Hmm, you're right, and I see this pattern in other files too. Presumably the reason is so that the SDK will work properly if we deprecate and remove the 1.0 version of the interface? That seems like a bad thing to do-- we should keep around the old versions of the interface so that plugins built against older versions of the pepper SDK will continue to work. I'd advocate for removing this kind of logic throughout ppapi/cpp. Why are we doing this? > > https://codereview.chromium.org/12817009/
On 2013/03/26 20:12:20, teravest wrote: > On Sun, Mar 24, 2013 at 2:00 AM, <mailto:yusukes@chromium.org> wrote: > > > > https://codereview.chromium.org/12817009/diff/45019/ppapi/cpp/file_ref.cc > > File ppapi/cpp/file_ref.cc (right): > > > > > https://codereview.chromium.org/12817009/diff/45019/ppapi/cpp/file_ref.cc#new... > > ppapi/cpp/file_ref.cc:110: if (!has_interface<PPB_FileRef_1_0>()) > > I guess this (and all other v1.0 methods) should be like: > > > > if (has_interface<1_1>()) > > get_interface<1_1>()->Rename(...); > > else if (has_interface<1_0>()) > > get_interface<1_0>()->Rename(...); > > else > > return cc.MayForce(PP_ERROR_NOINTERFACE); > > > > > http://src.chromium.org/viewvc/chrome/trunk/src/ppapi/cpp/file_io.cc?view=markup > > does that. > > Hmm, you're right, and I see this pattern in other files too. > Presumably the reason is so that the SDK will work properly if we > deprecate and remove the 1.0 version of the interface? That seems like > a bad thing to do-- we should keep around the old versions of the > interface so that plugins built against older versions of the pepper > SDK will continue to work. > > I'd advocate for removing this kind of logic throughout ppapi/cpp. Why > are we doing this? I guess that the current way (i.e. using the latest interface whenever possible) is more unittest friendly. Actually I noticed the issue when I was writing gmock-based unit tests for our PPAPI plugin which calls into your new pp::FileRef interface. Our current testing code is usually like this: PPB_FileRef_1_1_Mock* ppb_file_ref_; .. EXPECT_CALL(*ppb_file_ref_, Create(xxx, _)).WillOnce(Return(..))); EXPECT_CALL(*ppb_file_ref_, Query(xxx,...)); But with your current code (patch set #7), our testing code has to be changed to PPB_FileRef_1_0_Mock* ppb_file_ref_1_0_; PPB_FileRef_1_1_Mock* ppb_file_ref_1_1_; .. EXPECT_CALL(*ppb_file_ref_1_0_, Create(xxx, _)).WillOnce(Return(..))); EXPECT_CALL(*ppb_file_ref_1_1_, Query(xxx,...)); which I feel is a bit difficult to maintain.
On Tue, Mar 26, 2013 at 2:42 PM, <yusukes@chromium.org> wrote: > On 2013/03/26 20:12:20, teravest wrote: > >> On Sun, Mar 24, 2013 at 2:00 AM, <mailto:yusukes@chromium.org> wrote: >> > >> > >> > https://codereview.chromium.org/12817009/diff/45019/ppapi/cpp/file_ref.cc >> > File ppapi/cpp/file_ref.cc (right): >> > >> > > > > https://codereview.chromium.org/12817009/diff/45019/ppapi/cpp/file_ref.cc#new... >> >> > ppapi/cpp/file_ref.cc:110: if (!has_interface<PPB_FileRef_1_0>()) >> > I guess this (and all other v1.0 methods) should be like: >> > >> > if (has_interface<1_1>()) >> > get_interface<1_1>()->Rename(...); >> > else if (has_interface<1_0>()) >> > get_interface<1_0>()->Rename(...); >> > else >> > return cc.MayForce(PP_ERROR_NOINTERFACE); >> > >> > > > > http://src.chromium.org/viewvc/chrome/trunk/src/ppapi/cpp/file_io.cc?view=markup >> >> > does that. > > >> Hmm, you're right, and I see this pattern in other files too. >> Presumably the reason is so that the SDK will work properly if we >> deprecate and remove the 1.0 version of the interface? That seems like >> a bad thing to do-- we should keep around the old versions of the >> interface so that plugins built against older versions of the pepper >> SDK will continue to work. > > >> I'd advocate for removing this kind of logic throughout ppapi/cpp. Why >> are we doing this? > > > I guess that the current way (i.e. using the latest interface whenever > possible) > is more unittest friendly. Actually I noticed the issue when I was writing > gmock-based unit tests for our PPAPI plugin which calls into your new > pp::FileRef interface. > > Our current testing code is usually like this: > > PPB_FileRef_1_1_Mock* ppb_file_ref_; > .. > EXPECT_CALL(*ppb_file_ref_, Create(xxx, _)).WillOnce(Return(..))); > EXPECT_CALL(*ppb_file_ref_, Query(xxx,...)); > > But with your current code (patch set #7), our testing code has to be > changed to > > PPB_FileRef_1_0_Mock* ppb_file_ref_1_0_; > PPB_FileRef_1_1_Mock* ppb_file_ref_1_1_; > .. > EXPECT_CALL(*ppb_file_ref_1_0_, Create(xxx, _)).WillOnce(Return(..))); > EXPECT_CALL(*ppb_file_ref_1_1_, Query(xxx,...)); > > which I feel is a bit difficult to maintain. Hmm, that is gross. I'll change my code to match the prevailing style, but I do wish there was a better way to solve this. Thanks for the testing example. > > > > https://codereview.chromium.org/12817009/
On Tue, Mar 26, 2013 at 2:42 PM, <yusukes@chromium.org> wrote: > On 2013/03/26 20:12:20, teravest wrote: > > On Sun, Mar 24, 2013 at 2:00 AM, <mailto:yusukes@chromium.org> wrote: >> > >> > https://codereview.chromium.**org/12817009/diff/45019/ppapi/** >> cpp/file_ref.cc<https://codereview.chromium.org/12817009/diff/45019/ppapi/cpp/file_ref.cc> >> > File ppapi/cpp/file_ref.cc (right): >> > >> > >> > > https://codereview.chromium.**org/12817009/diff/45019/ppapi/** > cpp/file_ref.cc#newcode110<https://codereview.chromium.org/12817009/diff/45019/ppapi/cpp/file_ref.cc#newcode110> > >> > ppapi/cpp/file_ref.cc:110: if (!has_interface<PPB_FileRef_1_**0>()) >> > I guess this (and all other v1.0 methods) should be like: >> > >> > if (has_interface<1_1>()) >> > get_interface<1_1>()->Rename(.**..); >> > else if (has_interface<1_0>()) >> > get_interface<1_0>()->Rename(.**..); >> > else >> > return cc.MayForce(PP_ERROR_**NOINTERFACE); >> > >> > >> > > http://src.chromium.org/**viewvc/chrome/trunk/src/ppapi/** > cpp/file_io.cc?view=markup<http://src.chromium.org/viewvc/chrome/trunk/src/ppapi/cpp/file_io.cc?view=markup> > >> > does that. >> > > Hmm, you're right, and I see this pattern in other files too. >> Presumably the reason is so that the SDK will work properly if we >> deprecate and remove the 1.0 version of the interface? That seems like >> a bad thing to do-- we should keep around the old versions of the >> interface so that plugins built against older versions of the pepper >> SDK will continue to work. >> > > I'd advocate for removing this kind of logic throughout ppapi/cpp. Why >> are we doing this? >> > > I guess that the current way (i.e. using the latest interface whenever > possible) > is more unittest friendly. Actually I noticed the issue when I was writing > gmock-based unit tests for our PPAPI plugin which calls into your new > pp::FileRef interface. > > Our current testing code is usually like this: > > PPB_FileRef_1_1_Mock* ppb_file_ref_; > .. > EXPECT_CALL(*ppb_file_ref_, Create(xxx, _)).WillOnce(Return(..))); > EXPECT_CALL(*ppb_file_ref_, Query(xxx,...)); > > But with your current code (patch set #7), our testing code has to be > changed to > > PPB_FileRef_1_0_Mock* ppb_file_ref_1_0_; > PPB_FileRef_1_1_Mock* ppb_file_ref_1_1_; > .. > EXPECT_CALL(*ppb_file_ref_1_0_**, Create(xxx, _)).WillOnce(Return(..))); > EXPECT_CALL(*ppb_file_ref_1_1_**, Query(xxx,...)); > > which I feel is a bit difficult to maintain. > In a lot of cases, we're just appending to the struct. So an object w/version 1.1 might be a perfectly valid response if asked for 1.0. E.g., that's true here. You would only have: PPB_FileRef_1_1_Mock* ppb_file_ref_1_1_; And make GetInterface return it whether you ask for 1.0 or 1.1. That would work here, but not for everything. Also, do we want to prefer making our test code simpler vs our production C++ code? Might make sense to prioritize making the C++ simple. I've always preferred just asking for the older version when we know the versions are identical (like var does it<https://code.google.com/p/chromium/codesearch#chromium/src/ppapi/cpp/var.cc&q=var.cc&sq=package:chromium&type=cs&l=109>). But this has come up before... and I can't seem to find all of the debate. I seem to remember viettrungluu was opposed to the shorter style. > > > https://codereview.chromium.**org/12817009/<https://codereview.chromium.org/1... >
Some more comments. Thanks! https://codereview.chromium.org/12817009/diff/64002/ppapi/cpp/file_ref.cc File ppapi/cpp/file_ref.cc (right): https://codereview.chromium.org/12817009/diff/64002/ppapi/cpp/file_ref.cc#new... ppapi/cpp/file_ref.cc:51: else if (has_interface<PPB_FileRef_1_0>()) I remember that the preferred style is: (And please change all methods below.) if () return... if () return... return... Please see the code formatting section of http://dev.chromium.org/developers/coding-style https://codereview.chromium.org/12817009/diff/64002/ppapi/proxy/ppb_file_ref_... File ppapi/proxy/ppb_file_ref_proxy.cc (right): https://codereview.chromium.org/12817009/diff/64002/ppapi/proxy/ppb_file_ref_... ppapi/proxy/ppb_file_ref_proxy.cc:334: memset(info, 0, sizeof(PP_FileInfo)); You have run the default constructor on the previous line, right? ("new PP_FileInfo()" does init while "new PP_FileInfo" doesn't.) https://codereview.chromium.org/12817009/diff/64002/ppapi/tests/test_file_ref.cc File ppapi/tests/test_file_ref.cc (right): https://codereview.chromium.org/12817009/diff/64002/ppapi/tests/test_file_ref... ppapi/tests/test_file_ref.cc:52: std::string TestFileRef::MakeExternalFileRef(pp::FileRef *file_ref_ext) { '*' is at wrong position. https://codereview.chromium.org/12817009/diff/64002/ppapi/tests/test_file_ref... ppapi/tests/test_file_ref.cc:143: if (result != "") nit: please use !result.empty() https://codereview.chromium.org/12817009/diff/64002/ppapi/tests/test_file_ref... ppapi/tests/test_file_ref.cc:730: if (result != "") ditto. https://codereview.chromium.org/12817009/diff/64002/ppapi/tests/test_file_ref.h File ppapi/tests/test_file_ref.h (right): https://codereview.chromium.org/12817009/diff/64002/ppapi/tests/test_file_ref... ppapi/tests/test_file_ref.h:27: std::string MakeExternalFileRef(pp::FileRef *file_ref_ext); wrong position: '*' https://codereview.chromium.org/12817009/diff/64002/webkit/plugins/ppapi/ppb_... File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): https://codereview.chromium.org/12817009/diff/64002/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:308: // We have to do something totally different for external filesystems. nit: file systems. https://codereview.chromium.org/12817009/diff/64002/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:315: // Non-external filesystem Just out of curiosity: I wonder why we have IsValidNonExternalFileSystem(), if (file_system.get() != NULL) ==> non-external filesystem. (That method has a check about file_system_->type().) https://codereview.chromium.org/12817009/diff/64002/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:332: int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); Please test that whether |callback| is still pending. If not you could return early. https://codereview.chromium.org/12817009/diff/64002/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:335: base::PlatformFile file = passed_file.ReleaseValue(); It seems the file handle is leaked? (Besides, because you are using weakptr factory, it is not reliable to close the file handle in GetFileInfoCallback().) https://codereview.chromium.org/12817009/diff/64002/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:353: int32_t pp_error = ::ppapi::PlatformFileErrorToPepperError(error_code); Same here, please test whether |callback| is still pending, if not, you shouldn't touch |info|. It may be invalid.
On Tue, Mar 26, 2013 at 5:32 PM, <yzshen@chromium.org> wrote: > Some more comments. > Thanks! > > > https://codereview.chromium.org/12817009/diff/64002/ppapi/cpp/file_ref.cc > File ppapi/cpp/file_ref.cc (right): > > https://codereview.chromium.org/12817009/diff/64002/ppapi/cpp/file_ref.cc#new... > ppapi/cpp/file_ref.cc:51: else if (has_interface<PPB_FileRef_1_0>()) > I remember that the preferred style is: (And please change all methods > below.) > if () > return... > if () > return... > return... > > Please see the code formatting section of > http://dev.chromium.org/developers/coding-style Done. I left the braces because the return statement is too big to fit on one line. Let me know if I should get rid of the braces, too. > > https://codereview.chromium.org/12817009/diff/64002/ppapi/proxy/ppb_file_ref_... > File ppapi/proxy/ppb_file_ref_proxy.cc (right): > > https://codereview.chromium.org/12817009/diff/64002/ppapi/proxy/ppb_file_ref_... > ppapi/proxy/ppb_file_ref_proxy.cc:334: memset(info, 0, > sizeof(PP_FileInfo)); > You have run the default constructor on the previous line, right? > ("new PP_FileInfo()" does init while "new PP_FileInfo" doesn't.) Removed. I think the memset() was left over from when it was allocated on the stack. > > https://codereview.chromium.org/12817009/diff/64002/ppapi/tests/test_file_ref.cc > File ppapi/tests/test_file_ref.cc (right): > > https://codereview.chromium.org/12817009/diff/64002/ppapi/tests/test_file_ref... > ppapi/tests/test_file_ref.cc:52: std::string > TestFileRef::MakeExternalFileRef(pp::FileRef *file_ref_ext) { > '*' is at wrong position. Fixed. I'll get this right eventually. :) > > https://codereview.chromium.org/12817009/diff/64002/ppapi/tests/test_file_ref... > ppapi/tests/test_file_ref.cc:143: if (result != "") > nit: please use !result.empty() done. > > https://codereview.chromium.org/12817009/diff/64002/ppapi/tests/test_file_ref... > ppapi/tests/test_file_ref.cc:730: if (result != "") > ditto. done. > > https://codereview.chromium.org/12817009/diff/64002/ppapi/tests/test_file_ref.h > File ppapi/tests/test_file_ref.h (right): > > https://codereview.chromium.org/12817009/diff/64002/ppapi/tests/test_file_ref... > ppapi/tests/test_file_ref.h:27: std::string > MakeExternalFileRef(pp::FileRef *file_ref_ext); > wrong position: '*' Fixed. > > https://codereview.chromium.org/12817009/diff/64002/webkit/plugins/ppapi/ppb_... > File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): > > https://codereview.chromium.org/12817009/diff/64002/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:308: // We have to do > something totally different for external filesystems. > nit: file systems. Done. > > https://codereview.chromium.org/12817009/diff/64002/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:315: // Non-external > filesystem > Just out of curiosity: I wonder why we have > IsValidNonExternalFileSystem(), if (file_system.get() != NULL) ==> > non-external filesystem. > (That method has a check about file_system_->type().) I thought this was odd too. file_system_ is always initialized to NULL when it's external. I didn't see a need to touch it in this change, but I can clean that up if you want. > > https://codereview.chromium.org/12817009/diff/64002/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:332: int32_t pp_error = > ::ppapi::PlatformFileErrorToPepperError(error_code); > Please test that whether |callback| is still pending. If not you could > return early. Done. > > https://codereview.chromium.org/12817009/diff/64002/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:335: base::PlatformFile file = > passed_file.ReleaseValue(); > It seems the file handle is leaked? > (Besides, because you are using weakptr factory, it is not reliable to > close the file handle in GetFileInfoCallback().) Fixed. I no longer use weakptr factory, and now explicitly close the PlatformFile. Should I block until the close completes before calling the user callback? Right now, I ignore the return code from ClosePlatformFile(). > > https://codereview.chromium.org/12817009/diff/64002/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:353: int32_t pp_error = > ::ppapi::PlatformFileErrorToPepperError(error_code); > Same here, please test whether |callback| is still pending, if not, you > shouldn't touch |info|. It may be invalid. Done. > > https://codereview.chromium.org/12817009/
Thanks Justin! Only two more nits. > Done. I left the braces because the return statement is too big to fit > on one line. Let me know if I should get rid of the braces, too. That sounds good to me. > I thought this was odd too. file_system_ is always initialized to NULL > when it's external. > I didn't see a need to touch it in this change, but I can clean that > up if you want. No need to change it in this CL. I am just curious and want to make sure I didn't misunderstand things. Thanks! > Fixed. I no longer use weakptr factory, and now explicitly close the > PlatformFile. Should I block until the close completes before calling > the user callback? Right now, I ignore the return code from > ClosePlatformFile(). I think that is fine. https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:141: base::Bind(&GetFileInfoCallback, plugin_instance, file, info, callback))) nit: I think the reply won't be run when it returns false. https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:364: base::Bind(&QueryCallback, plugin_instance, info, callback))) PPB_FileRef_Impl itself is ref-counted, maybe holding an extra ref to it is better than holding one to |plugin_instance|?
On Wed, Mar 27, 2013 at 1:41 PM, <yzshen@chromium.org> wrote: > Thanks Justin! Only two more nits. > > > >> Done. I left the braces because the return statement is too big to fit >> on one line. Let me know if I should get rid of the braces, too. > > That sounds good to me. > > >> I thought this was odd too. file_system_ is always initialized to NULL >> when it's external. >> I didn't see a need to touch it in this change, but I can clean that >> up if you want. > > No need to change it in this CL. I am just curious and want to make sure I > didn't misunderstand things. > Thanks! > > >> Fixed. I no longer use weakptr factory, and now explicitly close the >> PlatformFile. Should I block until the close completes before calling >> the user callback? Right now, I ignore the return code from >> ClosePlatformFile(). > > I think that is fine. > > > https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... > File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): > > https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:141: > base::Bind(&GetFileInfoCallback, plugin_instance, file, info, > callback))) > nit: I think the reply won't be run when it returns false. Can you clarify what you mean? There's a "callback->Run(PP_ERROR_FAILED);" statement for when GetFileInfoFromPlatformFile() returns false. Looking at this did make me realize that I leak the file handle in this case, though, so I'll add code to close the PlatformFile when that happens. > > https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:364: > base::Bind(&QueryCallback, plugin_instance, info, callback))) > PPB_FileRef_Impl itself is ref-counted, maybe holding an extra ref to it > is better than holding one to |plugin_instance|? What's the advantage of holding a ref on PPB_FileRef_Impl instead of the PluginInstance? I'd like to understand for the future. > > https://codereview.chromium.org/12817009/
https://codereview.chromium.org/12817009/diff/79001/ppapi/api/ppb_file_ref.idl File ppapi/api/ppb_file_ref.idl (right): https://codereview.chromium.org/12817009/diff/79001/ppapi/api/ppb_file_ref.id... ppapi/api/ppb_file_ref.idl:13: M27 = 1.1 (nit: probably M28 now) https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.cc File ppapi/cpp/file_ref.cc (right): https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.cc#new... ppapi/cpp/file_ref.cc:38: } else if (has_interface<PPB_FileRef_1_0>()) { Wow, this is ugly. yzshen: I think we've talked about this before... but I can't find the old conversation. How do you feel about just using the oldest version when we know the backing implementation is identical? I can't really see the harm in it. That's what we do for Var. Disadvantages here are code complexity and increasing the code that we force the plugin or NaCl app to link in. Advantages... the pattern works even when the backing implementation differs (in practice that hasn't happened yet), so we don't have to think about it. I feel like optimizing for the common case, and only doing the fallback code when it's necessary. That also makes it clearer to the reader that it _is_ necessary. https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.h File ppapi/cpp/file_ref.h (right): https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.h#newc... ppapi/cpp/file_ref.h:22: template<typename T> class CompletionCallbackWithOutput; nit: I think there should be a space between "template" and "<" https://codereview.chromium.org/12817009/diff/79001/ppapi/tests/test_file_ref.cc File ppapi/tests/test_file_ref.cc (right): https://codereview.chromium.org/12817009/diff/79001/ppapi/tests/test_file_ref... ppapi/tests/test_file_ref.cc:57: TestCompletionCallback callback(instance_->pp_instance(), force_async_); callback_type() https://codereview.chromium.org/12817009/diff/79001/ppapi/tests/test_file_ref... ppapi/tests/test_file_ref.cc:62: return ReportError("URLLoader::Open force_async", rv); IIRC You can use ASSERT_EQ and friends in here; they just return a string if the assert fails. https://codereview.chromium.org/12817009/diff/79001/ppapi/tests/test_file_ref... ppapi/tests/test_file_ref.cc:91: RUN_TEST_FORCEASYNC_AND_NOT(Query, filter); If you want, you can use RUN_CALLBACK_TEST here. That will also run the "blocking completion callback" version of your test (the other tests in this file don't support that yet because they're written the "old" way). https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:140: plugin_instance->delegate()->GetFileThreadMessageLoopProxy(), file, nit: 4-space indent https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:363: GetSystemPath(), base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, nit: 4-space indent https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:364: base::Bind(&QueryCallback, plugin_instance, info, callback))) On 2013/03/27 19:41:22, yzshen1 wrote: > PPB_FileRef_Impl itself is ref-counted, maybe holding an extra ref to it is > better than holding one to |plugin_instance|? +1... those callbacks could just be members, I think, and there's no need for a WeakPtrFactory.
On Wed, Mar 27, 2013 at 2:20 PM, <dmichael@chromium.org> wrote: > > https://codereview.chromium.org/12817009/diff/79001/ppapi/api/ppb_file_ref.idl > File ppapi/api/ppb_file_ref.idl (right): > > https://codereview.chromium.org/12817009/diff/79001/ppapi/api/ppb_file_ref.id... > ppapi/api/ppb_file_ref.idl:13: M27 = 1.1 > (nit: probably M28 now) Good call. > > https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.cc > File ppapi/cpp/file_ref.cc (right): > > https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.cc#new... > ppapi/cpp/file_ref.cc:38: } else if (has_interface<PPB_FileRef_1_0>()) { > Wow, this is ugly. yzshen: I think we've talked about this before... > but I can't find the old conversation. How do you feel about just using > the oldest version when we know the backing implementation is identical? > I can't really see the harm in it. That's what we do for Var. > > Disadvantages here are code complexity and increasing the code that we > force the plugin or NaCl app to link in. > > Advantages... the pattern works even when the backing implementation > differs (in practice that hasn't happened yet), so we don't have to > think about it. > > I feel like optimizing for the common case, and only doing the fallback > code when it's necessary. That also makes it clearer to the reader that > it _is_ necessary. > > https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.h > File ppapi/cpp/file_ref.h (right): > > https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.h#newc... > ppapi/cpp/file_ref.h:22: template<typename T> class > CompletionCallbackWithOutput; > nit: I think there should be a space between "template" and "<" Done. > > https://codereview.chromium.org/12817009/diff/79001/ppapi/tests/test_file_ref.cc > File ppapi/tests/test_file_ref.cc (right): > > https://codereview.chromium.org/12817009/diff/79001/ppapi/tests/test_file_ref... > ppapi/tests/test_file_ref.cc:57: TestCompletionCallback > callback(instance_->pp_instance(), force_async_); > callback_type() Done. > > https://codereview.chromium.org/12817009/diff/79001/ppapi/tests/test_file_ref... > ppapi/tests/test_file_ref.cc:62: return ReportError("URLLoader::Open > force_async", rv); > IIRC You can use ASSERT_EQ and friends in here; they just return a > string if the assert fails. Cool. Done. > > https://codereview.chromium.org/12817009/diff/79001/ppapi/tests/test_file_ref... > ppapi/tests/test_file_ref.cc:91: RUN_TEST_FORCEASYNC_AND_NOT(Query, > filter); > If you want, you can use RUN_CALLBACK_TEST here. That will also run the > "blocking completion callback" version of your test (the other tests in > this file don't support that yet because they're written the "old" way). Hmm. I'm not sure what to make of this, I don't understand what would break support for blocking completions. Actual: "QueryBlocking FAIL: TestCompletionCallback: Call did not run synchronously when passed a blocking completion callback! failed with error: 0, QueryBackground FAIL: TestCompletionCallback: Call did not run synchronously when passed a blocking completion callback! failed with error: 0" > > > https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... > File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): > > https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:140: > plugin_instance->delegate()->GetFileThreadMessageLoopProxy(), file, > nit: 4-space indent Done. > > https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:363: GetSystemPath(), > base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, > nit: 4-space indent Done. > > > https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:364: > base::Bind(&QueryCallback, plugin_instance, info, callback))) > On 2013/03/27 19:41:22, yzshen1 wrote: >> >> PPB_FileRef_Impl itself is ref-counted, maybe holding an extra ref to > > it is >> >> better than holding one to |plugin_instance|? > > +1... those callbacks could just be members, I think, and there's no > need for a WeakPtrFactory. There shouldn't be a WeakPtrFactory at all in there anymore. What's the advantage to making those functions members and holding a ref on PPB_FileRef_Impl instead of PluginInstance? > > https://codereview.chromium.org/12817009/
On Wed, Mar 27, 2013 at 2:37 PM, Justin TerAvest <teravest@chromium.org> wrote: > On Wed, Mar 27, 2013 at 2:20 PM, <dmichael@chromium.org> wrote: >> >> https://codereview.chromium.org/12817009/diff/79001/ppapi/api/ppb_file_ref.idl >> File ppapi/api/ppb_file_ref.idl (right): >> >> https://codereview.chromium.org/12817009/diff/79001/ppapi/api/ppb_file_ref.id... >> ppapi/api/ppb_file_ref.idl:13: M27 = 1.1 >> (nit: probably M28 now) > > Good call. > >> >> https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.cc >> File ppapi/cpp/file_ref.cc (right): >> >> https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.cc#new... >> ppapi/cpp/file_ref.cc:38: } else if (has_interface<PPB_FileRef_1_0>()) { >> Wow, this is ugly. yzshen: I think we've talked about this before... >> but I can't find the old conversation. How do you feel about just using >> the oldest version when we know the backing implementation is identical? >> I can't really see the harm in it. That's what we do for Var. >> >> Disadvantages here are code complexity and increasing the code that we >> force the plugin or NaCl app to link in. >> >> Advantages... the pattern works even when the backing implementation >> differs (in practice that hasn't happened yet), so we don't have to >> think about it. >> >> I feel like optimizing for the common case, and only doing the fallback >> code when it's necessary. That also makes it clearer to the reader that >> it _is_ necessary. >> >> https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.h >> File ppapi/cpp/file_ref.h (right): >> >> https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.h#newc... >> ppapi/cpp/file_ref.h:22: template<typename T> class >> CompletionCallbackWithOutput; >> nit: I think there should be a space between "template" and "<" > > Done. > >> >> https://codereview.chromium.org/12817009/diff/79001/ppapi/tests/test_file_ref.cc >> File ppapi/tests/test_file_ref.cc (right): >> >> https://codereview.chromium.org/12817009/diff/79001/ppapi/tests/test_file_ref... >> ppapi/tests/test_file_ref.cc:57: TestCompletionCallback >> callback(instance_->pp_instance(), force_async_); >> callback_type() > > Done. > >> >> https://codereview.chromium.org/12817009/diff/79001/ppapi/tests/test_file_ref... >> ppapi/tests/test_file_ref.cc:62: return ReportError("URLLoader::Open >> force_async", rv); >> IIRC You can use ASSERT_EQ and friends in here; they just return a >> string if the assert fails. > > Cool. Done. > >> >> https://codereview.chromium.org/12817009/diff/79001/ppapi/tests/test_file_ref... >> ppapi/tests/test_file_ref.cc:91: RUN_TEST_FORCEASYNC_AND_NOT(Query, >> filter); >> If you want, you can use RUN_CALLBACK_TEST here. That will also run the >> "blocking completion callback" version of your test (the other tests in >> this file don't support that yet because they're written the "old" way). > > Hmm. I'm not sure what to make of this, I don't understand what would > break support for blocking completions. > Actual: "QueryBlocking FAIL: TestCompletionCallback: Call did not > run synchronously when passed a blocking completion callback! failed > with error: 0, QueryBackground FAIL: TestCompletionCallback: Call did > not run synchronously when passed a blocking completion callback! > failed with error: 0" Fixed. > > >> >> >> https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... >> File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): >> >> https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... >> webkit/plugins/ppapi/ppb_file_ref_impl.cc:140: >> plugin_instance->delegate()->GetFileThreadMessageLoopProxy(), file, >> nit: 4-space indent > > Done. > >> >> https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... >> webkit/plugins/ppapi/ppb_file_ref_impl.cc:363: GetSystemPath(), >> base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, >> nit: 4-space indent > > Done. > >> >> >> https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... >> webkit/plugins/ppapi/ppb_file_ref_impl.cc:364: >> base::Bind(&QueryCallback, plugin_instance, info, callback))) >> On 2013/03/27 19:41:22, yzshen1 wrote: >>> >>> PPB_FileRef_Impl itself is ref-counted, maybe holding an extra ref to >> >> it is >>> >>> better than holding one to |plugin_instance|? >> >> +1... those callbacks could just be members, I think, and there's no >> need for a WeakPtrFactory. > > There shouldn't be a WeakPtrFactory at all in there anymore. > What's the advantage to making those functions members and holding a > ref on PPB_FileRef_Impl instead of PluginInstance? > >> >> https://codereview.chromium.org/12817009/
> There shouldn't be a WeakPtrFactory at all in there anymore. > What's the advantage to making those functions members and holding a > ref on PPB_FileRef_Impl instead of PluginInstance? I think the intent will be clearer (it's more idiomatic to have a callback to |this|), and you'll be pinning less stuff in memory that way. I think it will now be possible that the instance is deleted, in which case your callback should just do any necessary cleanup and return. > > > > > https://codereview.chromium.org/12817009/
On Wed, Mar 27, 2013 at 3:08 PM, <dmichael@chromium.org> wrote: >> There shouldn't be a WeakPtrFactory at all in there anymore. >> What's the advantage to making those functions members and holding a >> ref on PPB_FileRef_Impl instead of PluginInstance? > > I think the intent will be clearer (it's more idiomatic to have a callback > to > |this|), and you'll be pinning less stuff in memory that way. I think it > will > now be possible that the instance is deleted, in which case your callback > should > just do any necessary cleanup and return. Done. > > >> > >> > https://codereview.chromium.org/12817009/ > > > > > https://codereview.chromium.org/12817009/
https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:141: > base::Bind(&GetFileInfoCallback, plugin_instance, file, info, > callback))) > nit: I think the reply won't be run when it returns false. > Can you clarify what you mean? There's a > "callback->Run(PP_ERROR_FAILED);" statement for when > GetFileInfoFromPlatformFile() returns false. > Looking at this did make me realize that I leak the file handle in > this case, though, so I'll add code to close the PlatformFile when > that happens. That is what I meant. It leaks when GetFileInfoFromPlatformFile fails. https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:364: > base::Bind(&QueryCallback, plugin_instance, info, callback))) > PPB_FileRef_Impl itself is ref-counted, maybe holding an extra ref to it > is better than holding one to |plugin_instance|? > What's the advantage of holding a ref on PPB_FileRef_Impl instead of > the PluginInstance? I'd like to understand for the future. (David has answered it thoroughly. Thanks!) https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.cc File ppapi/cpp/file_ref.cc (right): https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.cc#new... ppapi/cpp/file_ref.cc:38: } else if (has_interface<PPB_FileRef_1_0>()) { It was in the thread "Provide a way to disable Nagle's algorithm on Pepper TCP sockets." I think all of us have expressed the reasons behind our preferences there. But a clear conclusion wasn't reached. Hmm... Honestly, I am kind of sitting on the fence right now. :) Is it a good idea to send a mail to the team, fully describe the reasons from both sides and then make a final decision which we will follow from now on? It affects quite a lot of files, I think it should qualify for a thread. On 2013/03/27 20:20:06, dmichael wrote: > Wow, this is ugly. yzshen: I think we've talked about this before... but I > can't find the old conversation. How do you feel about just using the oldest > version when we know the backing implementation is identical? I can't really see > the harm in it. That's what we do for Var. > > Disadvantages here are code complexity and increasing the code that we force the > plugin or NaCl app to link in. > > Advantages... the pattern works even when the backing implementation differs > (in practice that hasn't happened yet), so we don't have to think about it. > > I feel like optimizing for the common case, and only doing the fallback code > when it's necessary. That also makes it clearer to the reader that it _is_ > necessary.
On Wed, Mar 27, 2013 at 3:28 PM, <yzshen@chromium.org> wrote: > > https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... > >> webkit/plugins/ppapi/ppb_file_ref_impl.cc:141: >> base::Bind(&GetFileInfoCallback, plugin_instance, file, info, >> callback))) >> nit: I think the reply won't be run when it returns false. > > >> Can you clarify what you mean? There's a >> "callback->Run(PP_ERROR_FAILED);" statement for when >> GetFileInfoFromPlatformFile() returns false. > > >> Looking at this did make me realize that I leak the file handle in >> this case, though, so I'll add code to close the PlatformFile when >> that happens. > > That is what I meant. It leaks when GetFileInfoFromPlatformFile fails. Cool! Good catch. That should be fixed now. > > > https://codereview.chromium.org/12817009/diff/79001/webkit/plugins/ppapi/ppb_... >> >> webkit/plugins/ppapi/ppb_file_ref_impl.cc:364: >> base::Bind(&QueryCallback, plugin_instance, info, callback))) >> PPB_FileRef_Impl itself is ref-counted, maybe holding an extra ref to it >> is better than holding one to |plugin_instance|? > > >> What's the advantage of holding a ref on PPB_FileRef_Impl instead of >> the PluginInstance? I'd like to understand for the future. > > (David has answered it thoroughly. Thanks!) > > > > > > https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.cc > File ppapi/cpp/file_ref.cc (right): > > https://codereview.chromium.org/12817009/diff/79001/ppapi/cpp/file_ref.cc#new... > ppapi/cpp/file_ref.cc:38: } else if (has_interface<PPB_FileRef_1_0>()) { > It was in the thread "Provide a way to disable Nagle's algorithm on > Pepper TCP sockets." > I think all of us have expressed the reasons behind our preferences > there. But a clear conclusion wasn't reached. > Hmm... Honestly, I am kind of sitting on the fence right now. :) > > Is it a good idea to send a mail to the team, fully describe the reasons > from both sides and then make a final decision which we will follow from > now on? It affects quite a lot of files, I think it should qualify for a > thread. Yeah, let's move this to its own discussion. > > > > On 2013/03/27 20:20:06, dmichael wrote: >> >> Wow, this is ugly. yzshen: I think we've talked about this before... > > but I >> >> can't find the old conversation. How do you feel about just using the > > oldest >> >> version when we know the backing implementation is identical? I can't > > really see >> >> the harm in it. That's what we do for Var. > > >> Disadvantages here are code complexity and increasing the code that we > > force the >> >> plugin or NaCl app to link in. > > >> Advantages... the pattern works even when the backing implementation > > differs >> >> (in practice that hasn't happened yet), so we don't have to think > > about it. > >> I feel like optimizing for the common case, and only doing the > > fallback code >> >> when it's necessary. That also makes it clearer to the reader that it > > _is_ >> >> necessary. > > > https://codereview.chromium.org/12817009/
https://codereview.chromium.org/12817009/diff/27004/ppapi/tests/test_file_ref.cc File ppapi/tests/test_file_ref.cc (right): https://codereview.chromium.org/12817009/diff/27004/ppapi/tests/test_file_ref... ppapi/tests/test_file_ref.cc:83: // RUN_TEST_FORCEASYNC_AND_NOT(Query, filter); nit: Please remove ^^^ https://codereview.chromium.org/12817009/diff/27004/ppapi/tests/test_utils.h File ppapi/tests/test_utils.h (right): https://codereview.chromium.org/12817009/diff/27004/ppapi/tests/test_utils.h#... ppapi/tests/test_utils.h:229: (callback).errors().c_str()); \ sweet, thanks https://codereview.chromium.org/12817009/diff/27004/webkit/plugins/ppapi/ppb_... File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): https://codereview.chromium.org/12817009/diff/27004/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:335: return; Do you need to close passed_file here? https://codereview.chromium.org/12817009/diff/27004/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:340: callback->Run(PP_ERROR_FAILED); I think callback->Abort() is more appropriate here. (May disappear, though... see comment below) https://codereview.chromium.org/12817009/diff/27004/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:366: if (plugin_instance.get()) { nit: You don't need to say ".get()" https://codereview.chromium.org/12817009/diff/27004/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:369: file, base::Bind(&IgnoreCloseCallback)); Hmm, in the rare case that the instance is gone by this point, you still can leak the handle. Can you just pass the MessageLoopProxy around instead of getting the instance? I guess that would mean you don't actually need the reference on the PPB_FileRef_Impl?
On Wed, Mar 27, 2013 at 4:13 PM, <dmichael@chromium.org> wrote: > > https://codereview.chromium.org/12817009/diff/27004/ppapi/tests/test_file_ref.cc > File ppapi/tests/test_file_ref.cc (right): > > https://codereview.chromium.org/12817009/diff/27004/ppapi/tests/test_file_ref... > ppapi/tests/test_file_ref.cc:83: // RUN_TEST_FORCEASYNC_AND_NOT(Query, > filter); > nit: Please remove ^^^ Done. > > https://codereview.chromium.org/12817009/diff/27004/ppapi/tests/test_utils.h > File ppapi/tests/test_utils.h (right): > > https://codereview.chromium.org/12817009/diff/27004/ppapi/tests/test_utils.h#... > ppapi/tests/test_utils.h:229: (callback).errors().c_str()); \ > sweet, thanks > > https://codereview.chromium.org/12817009/diff/27004/webkit/plugins/ppapi/ppb_... > File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): > > https://codereview.chromium.org/12817009/diff/27004/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:335: return; > Do you need to close passed_file here? I don't believe so. I haven't taken ownership of passed_file, since I never called ReleaseValue on it. > > https://codereview.chromium.org/12817009/diff/27004/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:340: > callback->Run(PP_ERROR_FAILED); > I think callback->Abort() is more appropriate here. (May disappear, > though... see comment below) > > https://codereview.chromium.org/12817009/diff/27004/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:366: if > (plugin_instance.get()) { > nit: You don't need to say ".get()" Removed. > > https://codereview.chromium.org/12817009/diff/27004/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:369: file, > base::Bind(&IgnoreCloseCallback)); > Hmm, in the rare case that the instance is gone by this point, you still > can leak the handle. > > Can you just pass the MessageLoopProxy around instead of getting the > instance? I guess that would mean you don't actually need the reference > on the PPB_FileRef_Impl? That seems to work. > > https://codereview.chromium.org/12817009/
lgtm https://codereview.chromium.org/12817009/diff/93001/webkit/plugins/ppapi/ppb_... File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): https://codereview.chromium.org/12817009/diff/93001/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:95: scoped_refptr<base::MessageLoopProxy> message_loop_proxy, My bad, I think TaskRunner is the new hotness instead of MessageLoopProxy (see comment below; when we refactor, we should use the SequencedTaskRunner instead, I think) https://codereview.chromium.org/12817009/diff/93001/webkit/plugins/ppapi/ppb_... webkit/plugins/ppapi/ppb_file_ref_impl.cc:368: plugin_instance->delegate()->GetFileThreadMessageLoopProxy(); nit: Could you add a TODO that we should be using the SequencedWorkerPool instead?
LGTM Thanks!
On Wed, Mar 27, 2013 at 4:40 PM, <dmichael@chromium.org> wrote: > lgtm > > > > > https://codereview.chromium.org/12817009/diff/93001/webkit/plugins/ppapi/ppb_... > File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): > > https://codereview.chromium.org/12817009/diff/93001/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:95: > scoped_refptr<base::MessageLoopProxy> message_loop_proxy, > My bad, I think TaskRunner is the new hotness instead of > MessageLoopProxy (see comment below; when we refactor, we should use the > SequencedTaskRunner instead, I think) Done. > > https://codereview.chromium.org/12817009/diff/93001/webkit/plugins/ppapi/ppb_... > webkit/plugins/ppapi/ppb_file_ref_impl.cc:368: > plugin_instance->delegate()->GetFileThreadMessageLoopProxy(); > nit: Could you add a TODO that we should be using the > SequencedWorkerPool instead? Done. > > https://codereview.chromium.org/12817009/
+jschuh for ppapi/proxy/ppapi_messages.h jschuh, This change makes a few changes to ppapi_messages.h * Existing (PpapiHostMsg_PPBFileRef* messages now use uint32_t to pass the callback id. Previously, there was a problematic signed/unsigned mismatch. * PpapiHostMsg_PPBFileRef_Query was added, which allows users to query file info (size, file type, creation time, etc). PpapiMsg_PPBFileRef_QueryCallbackComplete is the reply message. The query functionality exists in a slightly different format in the message pair: PpapiHostMsg_FileIO_Query, PpapiPluginMsg_FileIO_QueryReply Adding this to FileRef reduces the number of calls the user has to make (they don't have to call Open() anymore), improving performance. On Thu, Mar 28, 2013 at 8:31 AM, Justin TerAvest <teravest@chromium.org> wrote: > On Wed, Mar 27, 2013 at 4:40 PM, <dmichael@chromium.org> wrote: >> lgtm >> >> >> >> >> https://codereview.chromium.org/12817009/diff/93001/webkit/plugins/ppapi/ppb_... >> File webkit/plugins/ppapi/ppb_file_ref_impl.cc (right): >> >> https://codereview.chromium.org/12817009/diff/93001/webkit/plugins/ppapi/ppb_... >> webkit/plugins/ppapi/ppb_file_ref_impl.cc:95: >> scoped_refptr<base::MessageLoopProxy> message_loop_proxy, >> My bad, I think TaskRunner is the new hotness instead of >> MessageLoopProxy (see comment below; when we refactor, we should use the >> SequencedTaskRunner instead, I think) > > Done. > >> >> https://codereview.chromium.org/12817009/diff/93001/webkit/plugins/ppapi/ppb_... >> webkit/plugins/ppapi/ppb_file_ref_impl.cc:368: >> plugin_instance->delegate()->GetFileThreadMessageLoopProxy(); >> nit: Could you add a TODO that we should be using the >> SequencedWorkerPool instead? > > Done. > >> >> https://codereview.chromium.org/12817009/
Thanks for the front-end explanation. IPC security lgtm.
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/teravest@chromium.org/12817009/104001
Retried try job too often on linux_chromeos for step(s) browser_tests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=linux_chro...
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/teravest@chromium.org/12817009/108003
Retried try job too often on win for step(s) compile http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=win&number...
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/teravest@chromium.org/12817009/113004
Retried try job too often on win_rel for step(s) browser_tests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=win_rel&nu...
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/teravest@chromium.org/12817009/113004
Message was sent while issue was closed.
Change committed as 191805 |