OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/fileapi/file_system_file_util_proxy.h" | 5 #include "webkit/fileapi/file_system_file_util_proxy.h" |
6 | 6 |
7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
8 #include "webkit/fileapi/file_system_context.h" | 8 #include "webkit/fileapi/file_system_context.h" |
9 #include "webkit/fileapi/file_system_file_util.h" | 9 #include "webkit/fileapi/file_system_file_util.h" |
10 #include "webkit/fileapi/file_system_operation_context.h" | 10 #include "webkit/fileapi/file_system_operation_context.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 private: | 156 private: |
157 base::PlatformFile file_handle_; | 157 base::PlatformFile file_handle_; |
158 }; | 158 }; |
159 | 159 |
160 class RelayEnsureFileExists : public MessageLoopRelay { | 160 class RelayEnsureFileExists : public MessageLoopRelay { |
161 public: | 161 public: |
162 RelayEnsureFileExists( | 162 RelayEnsureFileExists( |
163 const fileapi::FileSystemOperationContext& context, | 163 const fileapi::FileSystemOperationContext& context, |
164 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, | 164 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, |
165 const FilePath& file_path, | 165 const FilePath& file_path, |
166 fileapi::FileSystemFileUtilProxy::EnsureFileExistsCallback* callback) | 166 const fileapi::FileSystemFileUtilProxy::EnsureFileExistsCallback callback) |
167 : MessageLoopRelay(context), | 167 : MessageLoopRelay(context), |
168 message_loop_proxy_(message_loop_proxy), | 168 message_loop_proxy_(message_loop_proxy), |
169 file_path_(file_path), | 169 file_path_(file_path), |
170 callback_(callback), | 170 callback_(callback), |
171 created_(false) { | 171 created_(false) { |
172 DCHECK(callback); | 172 DCHECK_EQ(false, callback.is_null()); |
173 } | 173 } |
174 | 174 |
175 protected: | 175 protected: |
176 virtual void RunWork() { | 176 virtual void RunWork() { |
177 set_error_code(file_util()->EnsureFileExists( | 177 set_error_code(file_util()->EnsureFileExists( |
178 context(), file_path_, &created_)); | 178 context(), file_path_, &created_)); |
179 } | 179 } |
180 | 180 |
181 virtual void RunCallback() { | 181 virtual void RunCallback() { |
182 callback_->Run(error_code(), created_); | 182 callback_.Run(error_code(), created_); |
183 delete callback_; | |
184 } | 183 } |
185 | 184 |
186 private: | 185 private: |
187 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 186 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
188 FilePath file_path_; | 187 FilePath file_path_; |
189 fileapi::FileSystemFileUtilProxy::EnsureFileExistsCallback* callback_; | 188 fileapi::FileSystemFileUtilProxy::EnsureFileExistsCallback callback_; |
190 bool created_; | 189 bool created_; |
191 }; | 190 }; |
192 | 191 |
193 | 192 |
194 class RelayGetLocalPath : public MessageLoopRelay { | 193 class RelayGetLocalPath : public MessageLoopRelay { |
195 public: | 194 public: |
196 RelayGetLocalPath( | 195 RelayGetLocalPath( |
197 const fileapi::FileSystemOperationContext& context, | 196 const fileapi::FileSystemOperationContext& context, |
198 const FilePath& virtual_path, | 197 const FilePath& virtual_path, |
199 fileapi::FileSystemFileUtilProxy::GetLocalPathCallback* callback) | 198 fileapi::FileSystemFileUtilProxy::GetLocalPathCallback* callback) |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 StatusCallback* callback) { | 443 StatusCallback* callback) { |
445 return Start(FROM_HERE, message_loop_proxy, | 444 return Start(FROM_HERE, message_loop_proxy, |
446 new RelayClose(context, file_handle, callback)); | 445 new RelayClose(context, file_handle, callback)); |
447 } | 446 } |
448 | 447 |
449 // static | 448 // static |
450 bool FileSystemFileUtilProxy::EnsureFileExists( | 449 bool FileSystemFileUtilProxy::EnsureFileExists( |
451 const FileSystemOperationContext& context, | 450 const FileSystemOperationContext& context, |
452 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 451 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
453 const FilePath& file_path, | 452 const FilePath& file_path, |
454 EnsureFileExistsCallback* callback) { | 453 const EnsureFileExistsCallback& callback) { |
455 return Start(FROM_HERE, message_loop_proxy, new RelayEnsureFileExists( | 454 return Start(FROM_HERE, message_loop_proxy, new RelayEnsureFileExists( |
456 context, message_loop_proxy, file_path, callback)); | 455 context, message_loop_proxy, file_path, callback)); |
457 } | 456 } |
458 | 457 |
459 // static | 458 // static |
460 bool FileSystemFileUtilProxy::GetLocalPath( | 459 bool FileSystemFileUtilProxy::GetLocalPath( |
461 const FileSystemOperationContext& context, | 460 const FileSystemOperationContext& context, |
462 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 461 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
463 const FilePath& virtual_path, | 462 const FilePath& virtual_path, |
464 GetLocalPathCallback* callback) { | 463 GetLocalPathCallback* callback) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 const FileSystemOperationContext& context, | 550 const FileSystemOperationContext& context, |
552 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 551 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
553 const FilePath& path, | 552 const FilePath& path, |
554 int64 length, | 553 int64 length, |
555 StatusCallback* callback) { | 554 StatusCallback* callback) { |
556 return Start(FROM_HERE, message_loop_proxy, | 555 return Start(FROM_HERE, message_loop_proxy, |
557 new RelayTruncate(context, path, length, callback)); | 556 new RelayTruncate(context, path, length, callback)); |
558 } | 557 } |
559 | 558 |
560 } // namespace fileapi | 559 } // namespace fileapi |
OLD | NEW |