OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "webkit/browser/fileapi/async_file_util_adapter.h" | 5 #include "webkit/browser/fileapi/async_file_util_adapter.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 origin_loop->PostTask( | 130 origin_loop->PostTask( |
131 FROM_HERE, base::Bind(callback, base::File::FILE_OK, entries, | 131 FROM_HERE, base::Bind(callback, base::File::FILE_OK, entries, |
132 false /* has_more */)); | 132 false /* has_more */)); |
133 } | 133 } |
134 | 134 |
135 void RunCreateOrOpenCallback( | 135 void RunCreateOrOpenCallback( |
136 FileSystemOperationContext* context, | 136 FileSystemOperationContext* context, |
137 const AsyncFileUtil::CreateOrOpenCallback& callback, | 137 const AsyncFileUtil::CreateOrOpenCallback& callback, |
138 base::File file) { | 138 base::File file) { |
139 // TODO(rvargas): Remove PlatformFile from AsyncFileUtil. | 139 callback.Run(file.Pass(), base::Closure()); |
140 base::File::Error error; | |
141 base::PlatformFile platform_file; | |
142 if (file.IsValid()) { | |
143 error = base::File::FILE_OK; | |
144 platform_file = file.TakePlatformFile(); | |
145 } else { | |
146 error = file.error_details(); | |
147 platform_file = base::kInvalidPlatformFileValue; | |
148 } | |
149 | |
150 callback.Run(error, base::PassPlatformFile(&platform_file), base::Closure()); | |
151 base::File closer(platform_file); | |
152 } | 140 } |
153 | 141 |
154 } // namespace | 142 } // namespace |
155 | 143 |
156 AsyncFileUtilAdapter::AsyncFileUtilAdapter( | 144 AsyncFileUtilAdapter::AsyncFileUtilAdapter( |
157 FileSystemFileUtil* sync_file_util) | 145 FileSystemFileUtil* sync_file_util) |
158 : sync_file_util_(sync_file_util) { | 146 : sync_file_util_(sync_file_util) { |
159 DCHECK(sync_file_util_.get()); | 147 DCHECK(sync_file_util_.get()); |
160 } | 148 } |
161 | 149 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 GetFileInfoHelper* helper = new GetFileInfoHelper; | 343 GetFileInfoHelper* helper = new GetFileInfoHelper; |
356 const bool success = context_ptr->task_runner()->PostTaskAndReply( | 344 const bool success = context_ptr->task_runner()->PostTaskAndReply( |
357 FROM_HERE, | 345 FROM_HERE, |
358 Bind(&GetFileInfoHelper::CreateSnapshotFile, Unretained(helper), | 346 Bind(&GetFileInfoHelper::CreateSnapshotFile, Unretained(helper), |
359 sync_file_util_.get(), base::Owned(context_ptr), url), | 347 sync_file_util_.get(), base::Owned(context_ptr), url), |
360 Bind(&GetFileInfoHelper::ReplySnapshotFile, Owned(helper), callback)); | 348 Bind(&GetFileInfoHelper::ReplySnapshotFile, Owned(helper), callback)); |
361 DCHECK(success); | 349 DCHECK(success); |
362 } | 350 } |
363 | 351 |
364 } // namespace fileapi | 352 } // namespace fileapi |
OLD | NEW |