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" |
11 #include "ppapi/c/ppb_file_ref.h" | 11 #include "ppapi/c/ppb_file_ref.h" |
12 #include "ppapi/c/private/ppb_file_ref_private.h" | 12 #include "ppapi/c/private/ppb_file_ref_private.h" |
13 #include "ppapi/c/private/ppb_proxy_private.h" | 13 #include "ppapi/c/private/ppb_proxy_private.h" |
14 #include "ppapi/proxy/enter_proxy.h" | 14 #include "ppapi/proxy/enter_proxy.h" |
15 #include "ppapi/proxy/host_dispatcher.h" | 15 #include "ppapi/proxy/host_dispatcher.h" |
16 #include "ppapi/proxy/plugin_dispatcher.h" | 16 #include "ppapi/proxy/plugin_dispatcher.h" |
17 #include "ppapi/proxy/ppapi_messages.h" | 17 #include "ppapi/proxy/ppapi_messages.h" |
18 #include "ppapi/proxy/serialized_var.h" | 18 #include "ppapi/proxy/serialized_var.h" |
19 #include "ppapi/shared_impl/ppb_file_ref_shared.h" | 19 #include "ppapi/shared_impl/file_ref_impl.h" |
20 #include "ppapi/thunk/resource_creation_api.h" | 20 #include "ppapi/thunk/resource_creation_api.h" |
21 #include "ppapi/thunk/thunk.h" | 21 #include "ppapi/thunk/thunk.h" |
22 | 22 |
23 using ppapi::thunk::EnterFunctionNoLock; | 23 using ppapi::thunk::EnterFunctionNoLock; |
24 using ppapi::thunk::EnterResourceNoLock; | 24 using ppapi::thunk::EnterResourceNoLock; |
25 using ppapi::thunk::PPB_FileRef_API; | 25 using ppapi::thunk::PPB_FileRef_API; |
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 FileRefImpl { |
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 // PPB_FileRef_API implementation (not provided by PPB_FileRef_Shared). | 36 // PPB_FileRef_API implementation (not provided by FileRefImpl). |
37 virtual PP_Resource GetParent() OVERRIDE; | 37 virtual PP_Resource GetParent() OVERRIDE; |
38 virtual int32_t MakeDirectory(PP_Bool make_ancestors, | 38 virtual int32_t MakeDirectory(PP_Bool make_ancestors, |
39 PP_CompletionCallback callback) OVERRIDE; | 39 PP_CompletionCallback callback) OVERRIDE; |
40 virtual int32_t Touch(PP_Time last_access_time, | 40 virtual int32_t Touch(PP_Time last_access_time, |
41 PP_Time last_modified_time, | 41 PP_Time last_modified_time, |
42 PP_CompletionCallback callback) OVERRIDE; | 42 PP_CompletionCallback callback) OVERRIDE; |
43 virtual int32_t Delete(PP_CompletionCallback callback) OVERRIDE; | 43 virtual int32_t Delete(PP_CompletionCallback callback) OVERRIDE; |
44 virtual int32_t Rename(PP_Resource new_file_ref, | 44 virtual int32_t Rename(PP_Resource new_file_ref, |
45 PP_CompletionCallback callback) OVERRIDE; | 45 PP_CompletionCallback callback) OVERRIDE; |
46 virtual PP_Var GetAbsolutePath() OVERRIDE; | 46 virtual PP_Var GetAbsolutePath() OVERRIDE; |
(...skipping 18 matching lines...) Expand all Loading... |
65 // the callback will be identified when it's passed to the host and then | 65 // the callback will be identified when it's passed to the host and then |
66 // back here. | 66 // back here. |
67 int next_callback_id_; | 67 int next_callback_id_; |
68 typedef std::map<int, PP_CompletionCallback> PendingCallbackMap; | 68 typedef std::map<int, PP_CompletionCallback> PendingCallbackMap; |
69 PendingCallbackMap pending_callbacks_; | 69 PendingCallbackMap pending_callbacks_; |
70 | 70 |
71 DISALLOW_IMPLICIT_CONSTRUCTORS(FileRef); | 71 DISALLOW_IMPLICIT_CONSTRUCTORS(FileRef); |
72 }; | 72 }; |
73 | 73 |
74 FileRef::FileRef(const PPB_FileRef_CreateInfo& info) | 74 FileRef::FileRef(const PPB_FileRef_CreateInfo& info) |
75 : PPB_FileRef_Shared(PPB_FileRef_Shared::InitAsProxy(), info), | 75 : FileRefImpl(FileRefImpl::InitAsProxy(), info), |
76 next_callback_id_(1) { | 76 next_callback_id_(1) { |
77 } | 77 } |
78 | 78 |
79 FileRef::~FileRef() { | 79 FileRef::~FileRef() { |
80 // 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 |
81 // the plugin's Release() call that probably deleted this object. | 81 // the plugin's Release() call that probably deleted this object. |
82 for (PendingCallbackMap::iterator i = pending_callbacks_.begin(); | 82 for (PendingCallbackMap::iterator i = pending_callbacks_.begin(); |
83 i != pending_callbacks_.end(); ++i) { | 83 i != pending_callbacks_.end(); ++i) { |
84 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 84 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
85 i->second.func, i->second.user_data, | 85 i->second.func, i->second.user_data, |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 int32_t result, | 334 int32_t result, |
335 const HostResource& host_resource, | 335 const HostResource& host_resource, |
336 int callback_id) { | 336 int callback_id) { |
337 // Execute OnMsgCallbackComplete in the plugin process. | 337 // Execute OnMsgCallbackComplete in the plugin process. |
338 Send(new PpapiMsg_PPBFileRef_CallbackComplete( | 338 Send(new PpapiMsg_PPBFileRef_CallbackComplete( |
339 API_ID_PPB_FILE_REF, host_resource, callback_id, result)); | 339 API_ID_PPB_FILE_REF, host_resource, callback_id, result)); |
340 } | 340 } |
341 | 341 |
342 } // namespace proxy | 342 } // namespace proxy |
343 } // namespace ppapi | 343 } // namespace ppapi |
OLD | NEW |