| Index: mojo/data_pipe_utils/data_pipe_file_utils.cc
|
| diff --git a/mojo/data_pipe_utils/data_pipe_file_utils.cc b/mojo/data_pipe_utils/data_pipe_file_utils.cc
|
| index e37c8dfe9aeee9140bb33717c5b55d5066c8f9b3..7a8f87b99af178c49a561ef5071d5269e0dfd64e 100644
|
| --- a/mojo/data_pipe_utils/data_pipe_file_utils.cc
|
| +++ b/mojo/data_pipe_utils/data_pipe_file_utils.cc
|
| @@ -315,18 +315,24 @@ size_t CopyToFileHelper(FILE* fp, const void* buffer, uint32_t num_bytes) {
|
|
|
| } // namespace
|
|
|
| -bool BlockingCopyToFile(ScopedDataPipeConsumerHandle source,
|
| - const base::FilePath& destination) {
|
| - TRACE_EVENT1("data_pipe_utils", "BlockingCopyToFile", "dest",
|
| - destination.MaybeAsASCII());
|
| - base::ScopedFILE fp(base::OpenFile(destination, "wb"));
|
| +base::ScopedFILE BlockingCopyToTempFile(ScopedDataPipeConsumerHandle source) {
|
| + base::FilePath path;
|
| + base::ScopedFILE fp(CreateAndOpenTemporaryFile(&path));
|
| if (!fp) {
|
| - LOG(ERROR) << "OpenFile('" << destination.value()
|
| - << "'failed in BlockingCopyToFile";
|
| - return false;
|
| + LOG(ERROR) << "CreateAndOpenTemporaryFile failed in"
|
| + << "BlockingCopyToTempFile";
|
| + return NULL;
|
| }
|
| - return BlockingCopyHelper(source.Pass(),
|
| - base::Bind(&CopyToFileHelper, fp.get()));
|
| + if (unlink(path.value().c_str())) {
|
| + LOG(ERROR) << "Failed to unlink temporary file";
|
| + return NULL;
|
| + }
|
| + if (!BlockingCopyHelper(source.Pass(),
|
| + base::Bind(&CopyToFileHelper, fp.get()))) {
|
| + LOG(ERROR) << "Could not copy source to temporary file";
|
| + return NULL;
|
| + }
|
| + return fp;
|
| }
|
|
|
| void CopyToFile(ScopedDataPipeConsumerHandle source,
|
|
|