OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/drive/write_on_cache_file.h" | 5 #include "chrome/browser/chromeos/drive/write_on_cache_file.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
10 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 10 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 // Runs |file_io_task_callback| in blocking pool and runs |close_callback| | 30 // Runs |file_io_task_callback| in blocking pool and runs |close_callback| |
31 // in the UI thread after that. | 31 // in the UI thread after that. |
32 void WriteOnCacheFileAfterOpenFile( | 32 void WriteOnCacheFileAfterOpenFile( |
33 const base::FilePath& drive_path, | 33 const base::FilePath& drive_path, |
34 const WriteOnCacheFileCallback& file_io_task_callback, | 34 const WriteOnCacheFileCallback& file_io_task_callback, |
35 const FileOperationCallback& reply, | 35 const FileOperationCallback& reply, |
36 FileError error, | 36 FileError error, |
37 const base::FilePath& local_cache_path, | 37 const base::FilePath& local_cache_path, |
38 const base::Closure& close_callback) { | 38 const base::Closure& close_callback) { |
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 39 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
40 | 40 |
41 BrowserThread::GetBlockingPool()->PostTaskAndReply( | 41 BrowserThread::GetBlockingPool()->PostTaskAndReply( |
42 FROM_HERE, | 42 FROM_HERE, |
43 base::Bind(file_io_task_callback, error, local_cache_path), | 43 base::Bind(file_io_task_callback, error, local_cache_path), |
44 base::Bind(&RunCloseCallbackAndReplyTask, close_callback, reply, error)); | 44 base::Bind(&RunCloseCallbackAndReplyTask, close_callback, reply, error)); |
45 } | 45 } |
46 | 46 |
47 } // namespace | 47 } // namespace |
48 | 48 |
49 void WriteOnCacheFile(FileSystemInterface* file_system, | 49 void WriteOnCacheFile(FileSystemInterface* file_system, |
50 const base::FilePath& path, | 50 const base::FilePath& path, |
51 const std::string& mime_type, | 51 const std::string& mime_type, |
52 const WriteOnCacheFileCallback& callback) { | 52 const WriteOnCacheFileCallback& callback) { |
53 WriteOnCacheFileAndReply(file_system, path, mime_type, callback, | 53 WriteOnCacheFileAndReply(file_system, path, mime_type, callback, |
54 base::Bind(&util::EmptyFileOperationCallback)); | 54 base::Bind(&util::EmptyFileOperationCallback)); |
55 } | 55 } |
56 | 56 |
57 void WriteOnCacheFileAndReply(FileSystemInterface* file_system, | 57 void WriteOnCacheFileAndReply(FileSystemInterface* file_system, |
58 const base::FilePath& path, | 58 const base::FilePath& path, |
59 const std::string& mime_type, | 59 const std::string& mime_type, |
60 const WriteOnCacheFileCallback& callback, | 60 const WriteOnCacheFileCallback& callback, |
61 const FileOperationCallback& reply) { | 61 const FileOperationCallback& reply) { |
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 62 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
63 DCHECK(file_system); | 63 DCHECK(file_system); |
64 DCHECK(!callback.is_null()); | 64 DCHECK(!callback.is_null()); |
65 DCHECK(!reply.is_null()); | 65 DCHECK(!reply.is_null()); |
66 | 66 |
67 file_system->OpenFile( | 67 file_system->OpenFile( |
68 path, | 68 path, |
69 OPEN_OR_CREATE_FILE, | 69 OPEN_OR_CREATE_FILE, |
70 mime_type, | 70 mime_type, |
71 base::Bind(&WriteOnCacheFileAfterOpenFile, path, callback, reply)); | 71 base::Bind(&WriteOnCacheFileAfterOpenFile, path, callback, reply)); |
72 } | 72 } |
73 | 73 |
74 } // namespace drive | 74 } // namespace drive |
OLD | NEW |