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_system_proxy.h" | 5 #include "ppapi/proxy/ppb_file_system_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 PP_CompletionCallback callback) { | 91 PP_CompletionCallback callback) { |
92 if (current_open_callback_.func) | 92 if (current_open_callback_.func) |
93 return PP_ERROR_INPROGRESS; | 93 return PP_ERROR_INPROGRESS; |
94 if (called_open_) | 94 if (called_open_) |
95 return PP_ERROR_FAILED; | 95 return PP_ERROR_FAILED; |
96 | 96 |
97 current_open_callback_ = callback; | 97 current_open_callback_ = callback; |
98 called_open_ = true; | 98 called_open_ = true; |
99 PluginDispatcher::GetForResource(this)->Send( | 99 PluginDispatcher::GetForResource(this)->Send( |
100 new PpapiHostMsg_PPBFileSystem_Open( | 100 new PpapiHostMsg_PPBFileSystem_Open( |
101 INTERFACE_ID_PPB_FILE_SYSTEM, host_resource(), expected_size)); | 101 API_ID_PPB_FILE_SYSTEM, host_resource(), expected_size)); |
102 return PP_OK_COMPLETIONPENDING; | 102 return PP_OK_COMPLETIONPENDING; |
103 } | 103 } |
104 | 104 |
105 PP_FileSystemType FileSystem::GetType() { | 105 PP_FileSystemType FileSystem::GetType() { |
106 return type_; | 106 return type_; |
107 } | 107 } |
108 | 108 |
109 void FileSystem::OpenComplete(int32_t result) { | 109 void FileSystem::OpenComplete(int32_t result) { |
110 PP_RunAndClearCompletionCallback(¤t_open_callback_, result); | 110 PP_RunAndClearCompletionCallback(¤t_open_callback_, result); |
111 } | 111 } |
112 | 112 |
113 PPB_FileSystem_Proxy::PPB_FileSystem_Proxy(Dispatcher* dispatcher) | 113 PPB_FileSystem_Proxy::PPB_FileSystem_Proxy(Dispatcher* dispatcher) |
114 : InterfaceProxy(dispatcher), | 114 : InterfaceProxy(dispatcher), |
115 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 115 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
116 } | 116 } |
117 | 117 |
118 PPB_FileSystem_Proxy::~PPB_FileSystem_Proxy() { | 118 PPB_FileSystem_Proxy::~PPB_FileSystem_Proxy() { |
119 } | 119 } |
120 | 120 |
121 const InterfaceProxy::Info* PPB_FileSystem_Proxy::GetInfo() { | 121 const InterfaceProxy::Info* PPB_FileSystem_Proxy::GetInfo() { |
122 static const Info info = { | 122 static const Info info = { |
123 thunk::GetPPB_FileSystem_Thunk(), | 123 thunk::GetPPB_FileSystem_Thunk(), |
124 PPB_FILESYSTEM_INTERFACE, | 124 PPB_FILESYSTEM_INTERFACE, |
125 INTERFACE_ID_PPB_FILE_SYSTEM, | 125 API_ID_PPB_FILE_SYSTEM, |
126 false, | 126 false, |
127 &CreateFileSystemProxy, | 127 &CreateFileSystemProxy, |
128 }; | 128 }; |
129 return &info; | 129 return &info; |
130 } | 130 } |
131 | 131 |
132 // static | 132 // static |
133 PP_Resource PPB_FileSystem_Proxy::CreateProxyResource( | 133 PP_Resource PPB_FileSystem_Proxy::CreateProxyResource( |
134 PP_Instance instance, | 134 PP_Instance instance, |
135 PP_FileSystemType type) { | 135 PP_FileSystemType type) { |
136 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 136 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
137 if (!dispatcher) | 137 if (!dispatcher) |
138 return PP_ERROR_BADARGUMENT; | 138 return PP_ERROR_BADARGUMENT; |
139 | 139 |
140 HostResource result; | 140 HostResource result; |
141 dispatcher->Send(new PpapiHostMsg_PPBFileSystem_Create( | 141 dispatcher->Send(new PpapiHostMsg_PPBFileSystem_Create( |
142 INTERFACE_ID_PPB_FILE_SYSTEM, instance, type, &result)); | 142 API_ID_PPB_FILE_SYSTEM, instance, type, &result)); |
143 if (result.is_null()) | 143 if (result.is_null()) |
144 return 0; | 144 return 0; |
145 return (new FileSystem(result, type))->GetReference(); | 145 return (new FileSystem(result, type))->GetReference(); |
146 } | 146 } |
147 | 147 |
148 bool PPB_FileSystem_Proxy::OnMessageReceived(const IPC::Message& msg) { | 148 bool PPB_FileSystem_Proxy::OnMessageReceived(const IPC::Message& msg) { |
149 bool handled = true; | 149 bool handled = true; |
150 IPC_BEGIN_MESSAGE_MAP(PPB_FileSystem_Proxy, msg) | 150 IPC_BEGIN_MESSAGE_MAP(PPB_FileSystem_Proxy, msg) |
151 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileSystem_Create, OnMsgCreate) | 151 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileSystem_Create, OnMsgCreate) |
152 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileSystem_Open, OnMsgOpen) | 152 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileSystem_Open, OnMsgOpen) |
(...skipping 30 matching lines...) Expand all Loading... |
183 int32_t result) { | 183 int32_t result) { |
184 EnterPluginFromHostResource<PPB_FileSystem_API> enter(host_resource); | 184 EnterPluginFromHostResource<PPB_FileSystem_API> enter(host_resource); |
185 if (enter.succeeded()) | 185 if (enter.succeeded()) |
186 static_cast<FileSystem*>(enter.object())->OpenComplete(result); | 186 static_cast<FileSystem*>(enter.object())->OpenComplete(result); |
187 } | 187 } |
188 | 188 |
189 void PPB_FileSystem_Proxy::OpenCompleteInHost( | 189 void PPB_FileSystem_Proxy::OpenCompleteInHost( |
190 int32_t result, | 190 int32_t result, |
191 const HostResource& host_resource) { | 191 const HostResource& host_resource) { |
192 dispatcher()->Send(new PpapiMsg_PPBFileSystem_OpenComplete( | 192 dispatcher()->Send(new PpapiMsg_PPBFileSystem_OpenComplete( |
193 INTERFACE_ID_PPB_FILE_SYSTEM, host_resource, result)); | 193 API_ID_PPB_FILE_SYSTEM, host_resource, result)); |
194 } | 194 } |
195 | 195 |
196 } // namespace proxy | 196 } // namespace proxy |
197 } // namespace ppapi | 197 } // namespace ppapi |
OLD | NEW |