| 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 "ppapi/proxy/ppb_file_ref_proxy.h" | 5 #include "ppapi/proxy/ppb_file_ref_proxy.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 using ppapi::thunk::ResourceCreationAPI; | 26 using ppapi::thunk::ResourceCreationAPI; |
| 27 | 27 |
| 28 namespace ppapi { | 28 namespace ppapi { |
| 29 namespace proxy { | 29 namespace proxy { |
| 30 | 30 |
| 31 class FileRef : public PPB_FileRef_Shared { | 31 class FileRef : public PPB_FileRef_Shared { |
| 32 public: | 32 public: |
| 33 explicit FileRef(const PPB_FileRef_CreateInfo& info); | 33 explicit FileRef(const PPB_FileRef_CreateInfo& info); |
| 34 virtual ~FileRef(); | 34 virtual ~FileRef(); |
| 35 | 35 |
| 36 // Resource overrides. | |
| 37 virtual void LastPluginRefWasDeleted() OVERRIDE; | |
| 38 | |
| 39 // PPB_FileRef_API implementation (not provided by PPB_FileRef_Shared). | 36 // PPB_FileRef_API implementation (not provided by PPB_FileRef_Shared). |
| 40 virtual PP_Resource GetParent() OVERRIDE; | 37 virtual PP_Resource GetParent() OVERRIDE; |
| 41 virtual int32_t MakeDirectory(PP_Bool make_ancestors, | 38 virtual int32_t MakeDirectory(PP_Bool make_ancestors, |
| 42 PP_CompletionCallback callback) OVERRIDE; | 39 PP_CompletionCallback callback) OVERRIDE; |
| 43 virtual int32_t Touch(PP_Time last_access_time, | 40 virtual int32_t Touch(PP_Time last_access_time, |
| 44 PP_Time last_modified_time, | 41 PP_Time last_modified_time, |
| 45 PP_CompletionCallback callback) OVERRIDE; | 42 PP_CompletionCallback callback) OVERRIDE; |
| 46 virtual int32_t Delete(PP_CompletionCallback callback) OVERRIDE; | 43 virtual int32_t Delete(PP_CompletionCallback callback) OVERRIDE; |
| 47 virtual int32_t Rename(PP_Resource new_file_ref, | 44 virtual int32_t Rename(PP_Resource new_file_ref, |
| 48 PP_CompletionCallback callback) OVERRIDE; | 45 PP_CompletionCallback callback) OVERRIDE; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 73 | 70 |
| 74 DISALLOW_IMPLICIT_CONSTRUCTORS(FileRef); | 71 DISALLOW_IMPLICIT_CONSTRUCTORS(FileRef); |
| 75 }; | 72 }; |
| 76 | 73 |
| 77 FileRef::FileRef(const PPB_FileRef_CreateInfo& info) | 74 FileRef::FileRef(const PPB_FileRef_CreateInfo& info) |
| 78 : PPB_FileRef_Shared(PPB_FileRef_Shared::InitAsProxy(), info), | 75 : PPB_FileRef_Shared(PPB_FileRef_Shared::InitAsProxy(), info), |
| 79 next_callback_id_(1) { | 76 next_callback_id_(1) { |
| 80 } | 77 } |
| 81 | 78 |
| 82 FileRef::~FileRef() { | 79 FileRef::~FileRef() { |
| 83 // The callbacks map should have been cleared by LastPluginRefWasDeleted. | |
| 84 DCHECK(pending_callbacks_.empty()); | |
| 85 } | |
| 86 | |
| 87 void FileRef::LastPluginRefWasDeleted() { | |
| 88 // Abort all pending callbacks. Do this by posting a task to avoid reentering | 80 // Abort all pending callbacks. Do this by posting a task to avoid reentering |
| 89 // the plugin's Release() call that probably deleted this object. | 81 // the plugin's Release() call that probably deleted this object. |
| 90 for (PendingCallbackMap::iterator i = pending_callbacks_.begin(); | 82 for (PendingCallbackMap::iterator i = pending_callbacks_.begin(); |
| 91 i != pending_callbacks_.end(); ++i) { | 83 i != pending_callbacks_.end(); ++i) { |
| 92 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 84 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
| 93 i->second.func, i->second.user_data, | 85 i->second.func, i->second.user_data, |
| 94 static_cast<int32_t>(PP_ERROR_ABORTED))); | 86 static_cast<int32_t>(PP_ERROR_ABORTED))); |
| 95 } | 87 } |
| 96 pending_callbacks_.clear(); | |
| 97 } | 88 } |
| 98 | 89 |
| 99 PP_Resource FileRef::GetParent() { | 90 PP_Resource FileRef::GetParent() { |
| 100 PPB_FileRef_CreateInfo create_info; | 91 PPB_FileRef_CreateInfo create_info; |
| 101 GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_GetParent( | 92 GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_GetParent( |
| 102 API_ID_PPB_FILE_REF, host_resource(), &create_info)); | 93 API_ID_PPB_FILE_REF, host_resource(), &create_info)); |
| 103 return PPB_FileRef_Proxy::DeserializeFileRef(create_info); | 94 return PPB_FileRef_Proxy::DeserializeFileRef(create_info); |
| 104 } | 95 } |
| 105 | 96 |
| 106 int32_t FileRef::MakeDirectory(PP_Bool make_ancestors, | 97 int32_t FileRef::MakeDirectory(PP_Bool make_ancestors, |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 int32_t result, | 334 int32_t result, |
| 344 const HostResource& host_resource, | 335 const HostResource& host_resource, |
| 345 int callback_id) { | 336 int callback_id) { |
| 346 // Execute OnMsgCallbackComplete in the plugin process. | 337 // Execute OnMsgCallbackComplete in the plugin process. |
| 347 Send(new PpapiMsg_PPBFileRef_CallbackComplete( | 338 Send(new PpapiMsg_PPBFileRef_CallbackComplete( |
| 348 API_ID_PPB_FILE_REF, host_resource, callback_id, result)); | 339 API_ID_PPB_FILE_REF, host_resource, callback_id, result)); |
| 349 } | 340 } |
| 350 | 341 |
| 351 } // namespace proxy | 342 } // namespace proxy |
| 352 } // namespace ppapi | 343 } // namespace ppapi |
| OLD | NEW |