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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/file_util_proxy.h" | 10 #include "base/file_util_proxy.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 : callback(entry.callback), | 45 : callback(entry.callback), |
46 read_buffer(entry.read_buffer) { | 46 read_buffer(entry.read_buffer) { |
47 } | 47 } |
48 | 48 |
49 PPB_FileIO_Impl::CallbackEntry::~CallbackEntry() { | 49 PPB_FileIO_Impl::CallbackEntry::~CallbackEntry() { |
50 } | 50 } |
51 | 51 |
52 PPB_FileIO_Impl::PPB_FileIO_Impl(PP_Instance instance) | 52 PPB_FileIO_Impl::PPB_FileIO_Impl(PP_Instance instance) |
53 : Resource(instance), | 53 : Resource(instance), |
54 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)), | 54 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)), |
| 55 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
55 file_(base::kInvalidPlatformFileValue), | 56 file_(base::kInvalidPlatformFileValue), |
56 file_system_type_(PP_FILESYSTEMTYPE_INVALID), | 57 file_system_type_(PP_FILESYSTEMTYPE_INVALID), |
57 pending_op_(OPERATION_NONE), | 58 pending_op_(OPERATION_NONE), |
58 info_(NULL), | 59 info_(NULL), |
59 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 60 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
60 } | 61 } |
61 | 62 |
62 PPB_FileIO_Impl::~PPB_FileIO_Impl() { | 63 PPB_FileIO_Impl::~PPB_FileIO_Impl() { |
63 Close(); | 64 Close(); |
64 } | 65 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 126 |
126 DCHECK(!info_); // If |info_|, a callback should be pending (caught above). | 127 DCHECK(!info_); // If |info_|, a callback should be pending (caught above). |
127 info_ = info; | 128 info_ = info; |
128 | 129 |
129 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 130 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
130 if (!plugin_delegate) | 131 if (!plugin_delegate) |
131 return PP_ERROR_FAILED; | 132 return PP_ERROR_FAILED; |
132 | 133 |
133 if (!base::FileUtilProxy::GetFileInfoFromPlatformFile( | 134 if (!base::FileUtilProxy::GetFileInfoFromPlatformFile( |
134 plugin_delegate->GetFileThreadMessageLoopProxy(), file_, | 135 plugin_delegate->GetFileThreadMessageLoopProxy(), file_, |
135 callback_factory_.NewCallback(&PPB_FileIO_Impl::QueryInfoCallback))) | 136 base::Bind(&PPB_FileIO_Impl::QueryInfoCallback, |
| 137 weak_factory_.GetWeakPtr()))) |
136 return PP_ERROR_FAILED; | 138 return PP_ERROR_FAILED; |
137 | 139 |
138 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); | 140 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); |
139 return PP_OK_COMPLETIONPENDING; | 141 return PP_OK_COMPLETIONPENDING; |
140 } | 142 } |
141 | 143 |
142 int32_t PPB_FileIO_Impl::Touch(PP_Time last_access_time, | 144 int32_t PPB_FileIO_Impl::Touch(PP_Time last_access_time, |
143 PP_Time last_modified_time, | 145 PP_Time last_modified_time, |
144 PP_CompletionCallback callback) { | 146 PP_CompletionCallback callback) { |
145 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); | 147 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 if (error_code != base::PLATFORM_FILE_OK) { | 473 if (error_code != base::PLATFORM_FILE_OK) { |
472 RunAndRemoveFirstPendingCallback( | 474 RunAndRemoveFirstPendingCallback( |
473 PlatformFileErrorToPepperError(error_code)); | 475 PlatformFileErrorToPepperError(error_code)); |
474 } else { | 476 } else { |
475 RunAndRemoveFirstPendingCallback(bytes_written); | 477 RunAndRemoveFirstPendingCallback(bytes_written); |
476 } | 478 } |
477 } | 479 } |
478 | 480 |
479 } // namespace ppapi | 481 } // namespace ppapi |
480 } // namespace webkit | 482 } // namespace webkit |
OLD | NEW |