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 "content/browser/loader/temporary_file_stream.h" | 5 #include "content/browser/loader/temporary_file_stream.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/files/file_proxy.h" | 11 #include "base/files/file_proxy.h" |
10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
11 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
12 #include "net/base/file_stream.h" | 14 #include "net/base/file_stream.h" |
13 #include "storage/browser/blob/shareable_file_reference.h" | 15 #include "storage/browser/blob/shareable_file_reference.h" |
14 | 16 |
15 using storage::ShareableFileReference; | 17 using storage::ShareableFileReference; |
16 | 18 |
(...skipping 19 matching lines...) Expand all Loading... |
36 // Cancelled or not, create the deletable_file so the temporary is cleaned up. | 38 // Cancelled or not, create the deletable_file so the temporary is cleaned up. |
37 scoped_refptr<ShareableFileReference> deletable_file = | 39 scoped_refptr<ShareableFileReference> deletable_file = |
38 ShareableFileReference::GetOrCreate( | 40 ShareableFileReference::GetOrCreate( |
39 file_path, | 41 file_path, |
40 ShareableFileReference::DELETE_ON_FINAL_RELEASE, | 42 ShareableFileReference::DELETE_ON_FINAL_RELEASE, |
41 task_runner.get()); | 43 task_runner.get()); |
42 | 44 |
43 scoped_ptr<net::FileStream> file_stream( | 45 scoped_ptr<net::FileStream> file_stream( |
44 new net::FileStream(file_proxy->TakeFile(), task_runner)); | 46 new net::FileStream(file_proxy->TakeFile(), task_runner)); |
45 | 47 |
46 callback.Run(error_code, file_stream.Pass(), deletable_file.get()); | 48 callback.Run(error_code, std::move(file_stream), deletable_file.get()); |
47 } | 49 } |
48 | 50 |
49 } // namespace | 51 } // namespace |
50 | 52 |
51 void CreateTemporaryFileStream( | 53 void CreateTemporaryFileStream( |
52 const CreateTemporaryFileStreamCallback& callback) { | 54 const CreateTemporaryFileStreamCallback& callback) { |
53 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 55 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
54 | 56 |
55 scoped_ptr<base::FileProxy> file_proxy(new base::FileProxy( | 57 scoped_ptr<base::FileProxy> file_proxy(new base::FileProxy( |
56 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get())); | 58 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get())); |
57 base::FileProxy* proxy = file_proxy.get(); | 59 base::FileProxy* proxy = file_proxy.get(); |
58 proxy->CreateTemporary( | 60 proxy->CreateTemporary( |
59 base::File::FLAG_ASYNC, | 61 base::File::FLAG_ASYNC, |
60 base::Bind(&DidCreateTemporaryFile, callback, Passed(&file_proxy))); | 62 base::Bind(&DidCreateTemporaryFile, callback, Passed(&file_proxy))); |
61 } | 63 } |
62 | 64 |
63 } // namespace content | 65 } // namespace content |
OLD | NEW |