[fsp] Fix crash when reading files.
commitd32e64031e9d24ff1b1d9be499b25038e6c5936b
authormtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Mon, 2 Jun 2014 05:50:54 +0000 (2 05:50 +0000)
committermtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Mon, 2 Jun 2014 05:50:54 +0000 (2 05:50 +0000)
tree7a3602f2d9ba5be0d847d466edd9384a5ce170d9
parentfc18261a2a895af32331a07c16e67c8f69dab27e
[fsp] Fix crash when reading files.

Before, the net::IOBuffer was being passed as a pointer, from the
FileStreamReader::Read to operations::ReadFile. However, there are PostTask
invocations on the way. When FileStreamReader is deleted after a PostTask is
fired from FileStreamReader::Read, and the operation is not completed, then
the net::IOBuffer will become invalid. When the operation is completed,
operation::ReadFile would cause a segmentation fault.

Since net::IOBuffer is ref counted, we should pass it as ref counted object
to be sure, that the buffer is always valid.

This patch migrates from passing IOBuffer as a pointer, to scoped_refptr.

TEST=Tested manually, that crashing doesn't occur anymore.
BUG=248427

Review URL: https://codereview.chromium.org/301973007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274174 0039d316-1c4b-4281-b951-d872f2087c98
chrome/browser/chromeos/file_system_provider/fileapi/file_stream_reader.cc
chrome/browser/chromeos/file_system_provider/fileapi/file_stream_reader.h
chrome/browser/chromeos/file_system_provider/operations/read_file.cc
chrome/browser/chromeos/file_system_provider/operations/read_file.h