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

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

Issue 10541113: Notify CloseFile from Pepper to FileSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added DLOG, DCHECK. Created 8 years, 5 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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 } 848 }
849 849
850 void PepperPluginDelegateImpl::DidUpdateFile(const GURL& path, int64_t delta) { 850 void PepperPluginDelegateImpl::DidUpdateFile(const GURL& path, int64_t delta) {
851 ChildThread::current()->Send(new FileSystemHostMsg_DidUpdate(path, delta)); 851 ChildThread::current()->Send(new FileSystemHostMsg_DidUpdate(path, delta));
852 } 852 }
853 853
854 class AsyncOpenFileSystemURLCallbackTranslator 854 class AsyncOpenFileSystemURLCallbackTranslator
855 : public fileapi::FileSystemCallbackDispatcher { 855 : public fileapi::FileSystemCallbackDispatcher {
856 public: 856 public:
857 AsyncOpenFileSystemURLCallbackTranslator( 857 AsyncOpenFileSystemURLCallbackTranslator(
858 const webkit::ppapi::PluginDelegate::AsyncOpenFileCallback& callback) 858 const webkit::ppapi::PluginDelegate::AsyncOpenFileCallback& callback,
859 : callback_(callback) { 859 const base::FileUtilProxy::StatusCallback& close_file_callback)
860 : callback_(callback),
861 close_file_callback_(close_file_callback) {
860 } 862 }
861 863
862 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} 864 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {}
863 865
864 virtual void DidSucceed() { 866 virtual void DidSucceed() {
865 NOTREACHED(); 867 NOTREACHED();
866 } 868 }
867 virtual void DidReadMetadata( 869 virtual void DidReadMetadata(
868 const base::PlatformFileInfo& file_info, 870 const base::PlatformFileInfo& file_info,
869 const FilePath& platform_path) { 871 const FilePath& platform_path) {
(...skipping 18 matching lines...) Expand all
888 NOTREACHED(); 890 NOTREACHED();
889 } 891 }
890 892
891 virtual void DidOpenFile( 893 virtual void DidOpenFile(
892 base::PlatformFile file) { 894 base::PlatformFile file) {
893 callback_.Run(base::PLATFORM_FILE_OK, base::PassPlatformFile(&file)); 895 callback_.Run(base::PLATFORM_FILE_OK, base::PassPlatformFile(&file));
894 // Make sure we won't leak file handle if the requester has died. 896 // Make sure we won't leak file handle if the requester has died.
895 if (file != base::kInvalidPlatformFileValue) { 897 if (file != base::kInvalidPlatformFileValue) {
896 base::FileUtilProxy::Close( 898 base::FileUtilProxy::Close(
897 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file, 899 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file,
898 base::FileUtilProxy::StatusCallback()); 900 close_file_callback_);
899 } 901 }
900 } 902 }
901 903
902 private: // TODO(ericu): Delete this? 904 private: // TODO(ericu): Delete this?
kinuko 2012/06/26 11:13:36 nit: can you delete this comment (and fix indent)
kinaba 2012/06/27 03:47:42 Done.
903 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback callback_; 905 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback callback_;
906 base::FileUtilProxy::StatusCallback close_file_callback_;
904 }; 907 };
905 908
906 bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL( 909 bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL(
907 const GURL& path, int flags, const AsyncOpenFileCallback& callback) { 910 const GURL& path, int flags, const AsyncOpenFileCallback& callback) {
908 911
909 FileSystemDispatcher* file_system_dispatcher = 912 FileSystemDispatcher* file_system_dispatcher =
910 ChildThread::current()->file_system_dispatcher(); 913 ChildThread::current()->file_system_dispatcher();
911 return file_system_dispatcher->OpenFile(path, flags, 914 return file_system_dispatcher->OpenFile(path, flags,
912 new AsyncOpenFileSystemURLCallbackTranslator(callback)); 915 new AsyncOpenFileSystemURLCallbackTranslator(
916 callback, GetCloseFileSystemURLCallback(path)));
917 }
918
919 base::Callback<void (base::PlatformFileError)>
920 PepperPluginDelegateImpl::GetCloseFileSystemURLCallback(const GURL& path) {
921 return base::Bind(&PepperPluginDelegateImpl::DoNotifyCloseFile,
922 AsWeakPtr(),
923 path);
924 }
925
926 void PepperPluginDelegateImpl::DoNotifyCloseFile(
927 const GURL& path,
928 base::PlatformFileError /* unused */) {
929 ChildThread::current()->file_system_dispatcher()->NotifyCloseFile(path);
913 } 930 }
914 931
915 base::PlatformFileError PepperPluginDelegateImpl::OpenFile( 932 base::PlatformFileError PepperPluginDelegateImpl::OpenFile(
916 const ppapi::PepperFilePath& path, 933 const ppapi::PepperFilePath& path,
917 int flags, 934 int flags,
918 base::PlatformFile* file) { 935 base::PlatformFile* file) {
919 IPC::PlatformFileForTransit transit_file; 936 IPC::PlatformFileForTransit transit_file;
920 base::PlatformFileError error; 937 base::PlatformFileError error;
921 IPC::Message* msg = new PepperFileMsg_OpenFile( 938 IPC::Message* msg = new PepperFileMsg_OpenFile(
922 path, flags, &error, &transit_file); 939 path, flags, &error, &transit_file);
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 else 1722 else
1706 return render_view_->mouse_lock_dispatcher(); 1723 return render_view_->mouse_lock_dispatcher();
1707 } 1724 }
1708 1725
1709 webkit_glue::ClipboardClient* 1726 webkit_glue::ClipboardClient*
1710 PepperPluginDelegateImpl::CreateClipboardClient() const { 1727 PepperPluginDelegateImpl::CreateClipboardClient() const {
1711 return new RendererClipboardClient; 1728 return new RendererClipboardClient;
1712 } 1729 }
1713 1730
1714 } // namespace content 1731 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698