Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: content/renderer/pepper/pepper_plugin_delegate_impl.cc

Issue 14472008: [FileAPI] Add file open ID and close callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/pepper/pepper_plugin_delegate_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <cstddef> 8 #include <cstddef>
9 #include <map> 9 #include <map>
10 #include <queue> 10 #include <queue>
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 virtual bool HandleMouseLockedInputEvent( 248 virtual bool HandleMouseLockedInputEvent(
249 const WebKit::WebMouseEvent &event) OVERRIDE { 249 const WebKit::WebMouseEvent &event) OVERRIDE {
250 plugin_->HandleMouseLockedInputEvent(event); 250 plugin_->HandleMouseLockedInputEvent(event);
251 return true; 251 return true;
252 } 252 }
253 253
254 private: 254 private:
255 webkit::ppapi::PluginInstance* plugin_; 255 webkit::ppapi::PluginInstance* plugin_;
256 }; 256 };
257 257
258 void DoNotifyCloseFile(int file_open_id, base::PlatformFileError /* unused */) {
259 ChildThread::current()->file_system_dispatcher()->NotifyCloseFile(
260 file_open_id);
261 }
262
258 class AsyncOpenFileSystemURLCallbackTranslator 263 class AsyncOpenFileSystemURLCallbackTranslator
259 : public fileapi::FileSystemCallbackDispatcher { 264 : public fileapi::FileSystemCallbackDispatcher {
260 public: 265 public:
261 AsyncOpenFileSystemURLCallbackTranslator( 266 AsyncOpenFileSystemURLCallbackTranslator(
262 const webkit::ppapi::PluginDelegate::AsyncOpenFileSystemURLCallback& 267 const webkit::ppapi::PluginDelegate::AsyncOpenFileSystemURLCallback&
263 callback, 268 callback)
264 const webkit::ppapi::PluginDelegate::NotifyCloseFileCallback& 269 : callback_(callback) {
265 close_file_callback)
266 : callback_(callback),
267 close_file_callback_(close_file_callback) {
268 } 270 }
269 271
270 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} 272 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {}
271 273
272 virtual void DidSucceed() OVERRIDE { 274 virtual void DidSucceed() OVERRIDE {
273 NOTREACHED(); 275 NOTREACHED();
274 } 276 }
275 virtual void DidReadMetadata( 277 virtual void DidReadMetadata(
276 const base::PlatformFileInfo& file_info, 278 const base::PlatformFileInfo& file_info,
277 const base::FilePath& platform_path) OVERRIDE { 279 const base::FilePath& platform_path) OVERRIDE {
(...skipping 20 matching lines...) Expand all
298 base::PassPlatformFile(&invalid_file), 300 base::PassPlatformFile(&invalid_file),
299 quota::kQuotaLimitTypeUnknown, 301 quota::kQuotaLimitTypeUnknown,
300 webkit::ppapi::PluginDelegate::NotifyCloseFileCallback()); 302 webkit::ppapi::PluginDelegate::NotifyCloseFileCallback());
301 } 303 }
302 304
303 virtual void DidWrite(int64 bytes, bool complete) OVERRIDE { 305 virtual void DidWrite(int64 bytes, bool complete) OVERRIDE {
304 NOTREACHED(); 306 NOTREACHED();
305 } 307 }
306 308
307 virtual void DidOpenFile(base::PlatformFile file, 309 virtual void DidOpenFile(base::PlatformFile file,
310 int file_open_id,
308 quota::QuotaLimitType quota_policy) OVERRIDE { 311 quota::QuotaLimitType quota_policy) OVERRIDE {
309 callback_.Run(base::PLATFORM_FILE_OK, 312 callback_.Run(base::PLATFORM_FILE_OK,
310 base::PassPlatformFile(&file), 313 base::PassPlatformFile(&file),
311 quota_policy, 314 quota_policy,
312 close_file_callback_); 315 base::Bind(&DoNotifyCloseFile, file_open_id));
313 // Make sure we won't leak file handle if the requester has died. 316 // Make sure we won't leak file handle if the requester has died.
314 if (file != base::kInvalidPlatformFileValue) { 317 if (file != base::kInvalidPlatformFileValue) {
315 base::FileUtilProxy::Close( 318 base::FileUtilProxy::Close(
316 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file, 319 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file,
317 close_file_callback_); 320 base::Bind(&DoNotifyCloseFile, file_open_id));
318 } 321 }
319 } 322 }
320 323
321 private: 324 private:
322 webkit::ppapi::PluginDelegate::AsyncOpenFileSystemURLCallback callback_; 325 webkit::ppapi::PluginDelegate::AsyncOpenFileSystemURLCallback callback_;
323 webkit::ppapi::PluginDelegate::NotifyCloseFileCallback close_file_callback_;
324 }; 326 };
325 327
326 void DoNotifyCloseFile(const GURL& path, base::PlatformFileError /* unused */) {
327 ChildThread::current()->file_system_dispatcher()->NotifyCloseFile(path);
328 }
329
330 void CreateHostForInProcessModule(RenderViewImpl* render_view, 328 void CreateHostForInProcessModule(RenderViewImpl* render_view,
331 webkit::ppapi::PluginModule* module, 329 webkit::ppapi::PluginModule* module,
332 const webkit::WebPluginInfo& webplugin_info) { 330 const webkit::WebPluginInfo& webplugin_info) {
333 // First time an in-process plugin was used, make a host for it. 331 // First time an in-process plugin was used, make a host for it.
334 const PepperPluginInfo* info = 332 const PepperPluginInfo* info =
335 PepperPluginRegistry::GetInstance()->GetInfoForPlugin(webplugin_info); 333 PepperPluginRegistry::GetInstance()->GetInfoForPlugin(webplugin_info);
336 DCHECK(!info->is_out_of_process); 334 DCHECK(!info->is_out_of_process);
337 335
338 ppapi::PpapiPermissions perms( 336 ppapi::PpapiPermissions perms(
339 PepperPluginRegistry::GetInstance()->GetInfoForPlugin( 337 PepperPluginRegistry::GetInstance()->GetInfoForPlugin(
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 1130
1133 bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL( 1131 bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL(
1134 const GURL& path, 1132 const GURL& path,
1135 int flags, 1133 int flags,
1136 const AsyncOpenFileSystemURLCallback& callback) { 1134 const AsyncOpenFileSystemURLCallback& callback) {
1137 1135
1138 FileSystemDispatcher* file_system_dispatcher = 1136 FileSystemDispatcher* file_system_dispatcher =
1139 ChildThread::current()->file_system_dispatcher(); 1137 ChildThread::current()->file_system_dispatcher();
1140 return file_system_dispatcher->OpenFile(path, flags, 1138 return file_system_dispatcher->OpenFile(path, flags,
1141 new AsyncOpenFileSystemURLCallbackTranslator( 1139 new AsyncOpenFileSystemURLCallbackTranslator(
1142 callback, 1140 callback));
1143 base::Bind(&DoNotifyCloseFile, path)));
1144 } 1141 }
1145 1142
1146 void PepperPluginDelegateImpl::SyncGetFileSystemPlatformPath( 1143 void PepperPluginDelegateImpl::SyncGetFileSystemPlatformPath(
1147 const GURL& url, base::FilePath* platform_path) { 1144 const GURL& url, base::FilePath* platform_path) {
1148 RenderThreadImpl::current()->Send(new FileSystemHostMsg_SyncGetPlatformPath( 1145 RenderThreadImpl::current()->Send(new FileSystemHostMsg_SyncGetPlatformPath(
1149 url, platform_path)); 1146 url, platform_path));
1150 } 1147 }
1151 1148
1152 scoped_refptr<base::MessageLoopProxy> 1149 scoped_refptr<base::MessageLoopProxy>
1153 PepperPluginDelegateImpl::GetFileThreadMessageLoopProxy() { 1150 PepperPluginDelegateImpl::GetFileThreadMessageLoopProxy() {
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 should_close_source); 1640 should_close_source);
1644 } 1641 }
1645 1642
1646 bool PepperPluginDelegateImpl::IsRunningInProcess(PP_Instance instance) const { 1643 bool PepperPluginDelegateImpl::IsRunningInProcess(PP_Instance instance) const {
1647 RendererPpapiHostImpl* host = 1644 RendererPpapiHostImpl* host =
1648 RendererPpapiHostImpl::GetForPPInstance(instance); 1645 RendererPpapiHostImpl::GetForPPInstance(instance);
1649 return host && host->IsRunningInProcess(); 1646 return host && host->IsRunningInProcess();
1650 } 1647 }
1651 1648
1652 } // namespace content 1649 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698