OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/data_pipe_utils/data_pipe_utils.h" | 5 #include "mojo/data_pipe_utils/data_pipe_utils.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 return nullptr; | 328 return nullptr; |
329 } | 329 } |
330 if (!BlockingCopyHelper(source.Pass(), | 330 if (!BlockingCopyHelper(source.Pass(), |
331 base::Bind(&CopyToFileHelper, fp.get()))) { | 331 base::Bind(&CopyToFileHelper, fp.get()))) { |
332 LOG(ERROR) << "Could not copy source to temporary file"; | 332 LOG(ERROR) << "Could not copy source to temporary file"; |
333 return nullptr; | 333 return nullptr; |
334 } | 334 } |
335 return fp; | 335 return fp; |
336 } | 336 } |
337 | 337 |
| 338 base::FilePath BlockingCopyToNewTempFile(ScopedDataPipeConsumerHandle source) { |
| 339 base::FilePath path; |
| 340 base::ScopedFILE fp(CreateAndOpenTemporaryFile(&path)); |
| 341 if (!fp) { |
| 342 LOG(ERROR) << "CreateAndOpenTemporaryFile failed in" |
| 343 << "BlockingCopyToTempFile"; |
| 344 return base::FilePath(""); |
| 345 } |
| 346 if (!BlockingCopyHelper(source.Pass(), |
| 347 base::Bind(&CopyToFileHelper, fp.get()))) { |
| 348 LOG(ERROR) << "Could not copy source to temporary file"; |
| 349 return base::FilePath(""); |
| 350 } |
| 351 return path; |
| 352 } |
| 353 |
338 void CopyToFile(ScopedDataPipeConsumerHandle source, | 354 void CopyToFile(ScopedDataPipeConsumerHandle source, |
339 const base::FilePath& destination, | 355 const base::FilePath& destination, |
340 base::TaskRunner* task_runner, | 356 base::TaskRunner* task_runner, |
341 const base::Callback<void(bool)>& callback) { | 357 const base::Callback<void(bool)>& callback) { |
342 new CopyToFileHandler(source.Pass(), destination, task_runner, callback); | 358 new CopyToFileHandler(source.Pass(), destination, task_runner, callback); |
343 } | 359 } |
344 | 360 |
345 void CopyFromFile(const base::FilePath& source, | 361 void CopyFromFile(const base::FilePath& source, |
346 ScopedDataPipeProducerHandle destination, | 362 ScopedDataPipeProducerHandle destination, |
347 uint32_t skip, | 363 uint32_t skip, |
348 base::TaskRunner* task_runner, | 364 base::TaskRunner* task_runner, |
349 const base::Callback<void(bool)>& callback) { | 365 const base::Callback<void(bool)>& callback) { |
350 new CopyFromFileHandler(source, destination.Pass(), skip, task_runner, | 366 new CopyFromFileHandler(source, destination.Pass(), skip, task_runner, |
351 callback); | 367 callback); |
352 } | 368 } |
353 | 369 |
354 } // namespace common | 370 } // namespace common |
355 } // namespace mojo | 371 } // namespace mojo |
OLD | NEW |