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/plugins/ppapi/ppb_file_io_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/file_util_proxy.h" | 9 #include "base/file_util_proxy.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 307 } |
308 | 308 |
309 void PPB_FileIO_Impl::RegisterCallback(OperationType op, | 309 void PPB_FileIO_Impl::RegisterCallback(OperationType op, |
310 PP_CompletionCallback callback, | 310 PP_CompletionCallback callback, |
311 char* read_buffer) { | 311 char* read_buffer) { |
312 DCHECK(callback.func); | 312 DCHECK(callback.func); |
313 DCHECK(pending_op_ == OPERATION_NONE || | 313 DCHECK(pending_op_ == OPERATION_NONE || |
314 (pending_op_ != OPERATION_EXCLUSIVE && pending_op_ == op)); | 314 (pending_op_ != OPERATION_EXCLUSIVE && pending_op_ == op)); |
315 | 315 |
316 CallbackEntry entry; | 316 CallbackEntry entry; |
317 PP_Resource resource_id = GetReferenceNoAddRef(); | |
318 CHECK(resource_id); | |
319 entry.callback = new TrackedCompletionCallback( | 317 entry.callback = new TrackedCompletionCallback( |
320 instance()->module()->GetCallbackTracker(), resource_id, callback); | 318 instance()->module()->GetCallbackTracker(), pp_resource(), callback); |
321 entry.read_buffer = read_buffer; | 319 entry.read_buffer = read_buffer; |
322 | 320 |
323 callbacks_.push(entry); | 321 callbacks_.push(entry); |
324 pending_op_ = op; | 322 pending_op_ = op; |
325 } | 323 } |
326 | 324 |
327 void PPB_FileIO_Impl::RunAndRemoveFirstPendingCallback(int32_t result) { | 325 void PPB_FileIO_Impl::RunAndRemoveFirstPendingCallback(int32_t result) { |
328 DCHECK(!callbacks_.empty()); | 326 DCHECK(!callbacks_.empty()); |
329 | 327 |
330 CallbackEntry front = callbacks_.front(); | 328 CallbackEntry front = callbacks_.front(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 if (error_code != base::PLATFORM_FILE_OK) { | 436 if (error_code != base::PLATFORM_FILE_OK) { |
439 RunAndRemoveFirstPendingCallback( | 437 RunAndRemoveFirstPendingCallback( |
440 PlatformFileErrorToPepperError(error_code)); | 438 PlatformFileErrorToPepperError(error_code)); |
441 } else { | 439 } else { |
442 RunAndRemoveFirstPendingCallback(bytes_written); | 440 RunAndRemoveFirstPendingCallback(bytes_written); |
443 } | 441 } |
444 } | 442 } |
445 | 443 |
446 } // namespace ppapi | 444 } // namespace ppapi |
447 } // namespace webkit | 445 } // namespace webkit |
OLD | NEW |