Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Issue 562063002: CdmFileIOImpl: Always SetLength(0) before WriteFile(). (Closed)

Created:
6 years, 3 months ago by xhwang
Modified:
6 years, 3 months ago
Reviewers:
ddorwin, tzik
CC:
chromium-reviews, feature-media-reviews_chromium.org, yusukes+watch_chromium.org, binji+watch_chromium.org, raymes+watch_chromium.org, eme-reviews_chromium.org, teravest+watch_chromium.org, nfullagar1, piman+watch_chromium.org, noelallen1, ihf+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

CdmFileIOImpl: Always SetLength(0) before WriteFile(). Since Write() takes two (or more) steps to finish, it's possible for CdmFileIOImpl to be destructed after SetLength() is called but before WriteFile() is called. In that case, if we SetLength(data_size), we end up with a corrupted file. If we SetLength(0), we end up with an empty file, which is relatively better. BUG=410630 TEST=ECKEncryptedMediaTest.FileIOTest still passes.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+42 lines, -1 line) Patch
M media/cdm/ppapi/cdm_file_io_impl.cc View 1 chunk +6 lines, -1 line 0 comments Download
M media/cdm/ppapi/cdm_file_io_test.cc View 2 chunks +36 lines, -0 lines 0 comments Download

Messages

Total messages: 6 (1 generated)
xhwang
ddorwin: PTAL tzik: Please help make sure this doesn't have any unexpected side effects. I ...
6 years, 3 months ago (2014-09-11 04:30:59 UTC) #2
tzik
On 2014/09/11 04:30:59, xhwang wrote: > ddorwin: PTAL > > tzik: Please help make sure ...
6 years, 3 months ago (2014-09-11 04:45:27 UTC) #3
xhwang
On 2014/09/11 04:45:27, tzik wrote: > On 2014/09/11 04:30:59, xhwang wrote: > > ddorwin: PTAL ...
6 years, 3 months ago (2014-09-11 17:49:55 UTC) #4
tzik
On 2014/09/11 17:49:55, xhwang wrote: > On 2014/09/11 04:45:27, tzik wrote: > > On 2014/09/11 ...
6 years, 3 months ago (2014-09-12 02:35:46 UTC) #5
xhwang
6 years, 3 months ago (2014-09-15 19:57:47 UTC) #6
On 2014/09/12 02:35:46, tzik wrote:
> On 2014/09/11 17:49:55, xhwang wrote:
> > On 2014/09/11 04:45:27, tzik wrote:
> > > On 2014/09/11 04:30:59, xhwang wrote:
> > > > ddorwin: PTAL
> > > > 
> > > > tzik: Please help make sure this doesn't have any unexpected side
effects.
> > > > 
> > > > I tested this with existing/new tests and with a real player that users
> > > > CdmFileIO and everything seems to be working fine.
> > > 
> > > LGTM.
> > > 
> > > Is it possible to avoid overwriting the file by replacing it with a new
file
> > > with Rename()?
> > 
> > Yeah, we are investigating using two files to avoid overwriting.
> > 
> > I don't see a Rename() method in the PPB File IO?
(ppapi/api/ppb_file_io.idl)
> 
> It's in FileRef, ppapi/api/ppb_file_ref.idl.

I'll do the rename approach as suggested by tzik@ (thanks!). Closing this
issue...

Powered by Google App Engine
This is Rietveld 408576698