Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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::AsyncOpenFileSystemURLCallback& |
| 859 : callback_(callback) { | 859 callback, |
| 860 const webkit::ppapi::PluginDelegate::NotifyCloseFileCallback& | |
| 861 close_file_callback) | |
| 862 : callback_(callback), | |
| 863 close_file_callback_(close_file_callback) { | |
| 860 } | 864 } |
| 861 | 865 |
| 862 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} | 866 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} |
| 863 | 867 |
| 864 virtual void DidSucceed() { | 868 virtual void DidSucceed() { |
| 865 NOTREACHED(); | 869 NOTREACHED(); |
| 866 } | 870 } |
| 867 virtual void DidReadMetadata( | 871 virtual void DidReadMetadata( |
| 868 const base::PlatformFileInfo& file_info, | 872 const base::PlatformFileInfo& file_info, |
| 869 const FilePath& platform_path) { | 873 const FilePath& platform_path) { |
| 870 NOTREACHED(); | 874 NOTREACHED(); |
| 871 } | 875 } |
| 872 virtual void DidReadDirectory( | 876 virtual void DidReadDirectory( |
| 873 const std::vector<base::FileUtilProxy::Entry>& entries, | 877 const std::vector<base::FileUtilProxy::Entry>& entries, |
| 874 bool has_more) { | 878 bool has_more) { |
| 875 NOTREACHED(); | 879 NOTREACHED(); |
| 876 } | 880 } |
| 877 virtual void DidOpenFileSystem(const std::string& name, | 881 virtual void DidOpenFileSystem(const std::string& name, |
| 878 const GURL& root) { | 882 const GURL& root) { |
| 879 NOTREACHED(); | 883 NOTREACHED(); |
| 880 } | 884 } |
| 881 | 885 |
| 882 virtual void DidFail(base::PlatformFileError error_code) { | 886 virtual void DidFail(base::PlatformFileError error_code) { |
| 883 base::PlatformFile invalid_file = base::kInvalidPlatformFileValue; | 887 base::PlatformFile invalid_file = base::kInvalidPlatformFileValue; |
| 884 callback_.Run(error_code, base::PassPlatformFile(&invalid_file)); | 888 callback_.Run(error_code, |
| 889 base::PassPlatformFile(&invalid_file), | |
| 890 close_file_callback_); | |
|
yzshen1
2012/06/29 17:15:52
[optional] Is it better to pass a no-op as the thi
kinaba
2012/07/03 06:46:35
Done.
| |
| 885 } | 891 } |
| 886 | 892 |
| 887 virtual void DidWrite(int64 bytes, bool complete) { | 893 virtual void DidWrite(int64 bytes, bool complete) { |
| 888 NOTREACHED(); | 894 NOTREACHED(); |
| 889 } | 895 } |
| 890 | 896 |
| 891 virtual void DidOpenFile( | 897 virtual void DidOpenFile( |
| 892 base::PlatformFile file) { | 898 base::PlatformFile file) { |
| 893 callback_.Run(base::PLATFORM_FILE_OK, base::PassPlatformFile(&file)); | 899 callback_.Run(base::PLATFORM_FILE_OK, |
| 900 base::PassPlatformFile(&file), | |
| 901 close_file_callback_); | |
| 894 // Make sure we won't leak file handle if the requester has died. | 902 // Make sure we won't leak file handle if the requester has died. |
| 895 if (file != base::kInvalidPlatformFileValue) { | 903 if (file != base::kInvalidPlatformFileValue) { |
| 896 base::FileUtilProxy::Close( | 904 base::FileUtilProxy::Close( |
| 897 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file, | 905 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file, |
| 898 base::FileUtilProxy::StatusCallback()); | 906 close_file_callback_); |
| 899 } | 907 } |
| 900 } | 908 } |
| 901 | 909 |
| 902 private: // TODO(ericu): Delete this? | 910 private: |
| 903 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback callback_; | 911 webkit::ppapi::PluginDelegate::AsyncOpenFileSystemURLCallback callback_; |
| 912 webkit::ppapi::PluginDelegate::NotifyCloseFileCallback close_file_callback_; | |
| 904 }; | 913 }; |
| 905 | 914 |
| 906 bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL( | 915 bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL( |
| 907 const GURL& path, int flags, const AsyncOpenFileCallback& callback) { | 916 const GURL& path, |
| 917 int flags, | |
| 918 const AsyncOpenFileSystemURLCallback& callback) { | |
| 908 | 919 |
| 909 FileSystemDispatcher* file_system_dispatcher = | 920 FileSystemDispatcher* file_system_dispatcher = |
| 910 ChildThread::current()->file_system_dispatcher(); | 921 ChildThread::current()->file_system_dispatcher(); |
| 911 return file_system_dispatcher->OpenFile(path, flags, | 922 return file_system_dispatcher->OpenFile(path, flags, |
| 912 new AsyncOpenFileSystemURLCallbackTranslator(callback)); | 923 new AsyncOpenFileSystemURLCallbackTranslator( |
| 924 callback, | |
| 925 base::Bind(&PepperPluginDelegateImpl::DoNotifyCloseFile, | |
| 926 AsWeakPtr(), | |
| 927 path))); | |
|
dmichael (off chromium)
2012/06/29 16:06:40
nit: indentation is off
kinaba
2012/07/03 06:46:35
Done.
| |
| 928 } | |
| 929 | |
| 930 void PepperPluginDelegateImpl::DoNotifyCloseFile( | |
|
yzshen1
2012/06/29 17:15:52
- please keep the definitions in the same order as
kinaba
2012/07/03 06:46:35
Good point, I haven't realized.
Moved the function
| |
| 931 const GURL& path, | |
| 932 base::PlatformFileError /* unused */) { | |
| 933 ChildThread::current()->file_system_dispatcher()->NotifyCloseFile(path); | |
| 913 } | 934 } |
| 914 | 935 |
| 915 base::PlatformFileError PepperPluginDelegateImpl::OpenFile( | 936 base::PlatformFileError PepperPluginDelegateImpl::OpenFile( |
| 916 const ppapi::PepperFilePath& path, | 937 const ppapi::PepperFilePath& path, |
| 917 int flags, | 938 int flags, |
| 918 base::PlatformFile* file) { | 939 base::PlatformFile* file) { |
| 919 IPC::PlatformFileForTransit transit_file; | 940 IPC::PlatformFileForTransit transit_file; |
| 920 base::PlatformFileError error; | 941 base::PlatformFileError error; |
| 921 IPC::Message* msg = new PepperFileMsg_OpenFile( | 942 IPC::Message* msg = new PepperFileMsg_OpenFile( |
| 922 path, flags, &error, &transit_file); | 943 path, flags, &error, &transit_file); |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1705 else | 1726 else |
| 1706 return render_view_->mouse_lock_dispatcher(); | 1727 return render_view_->mouse_lock_dispatcher(); |
| 1707 } | 1728 } |
| 1708 | 1729 |
| 1709 webkit_glue::ClipboardClient* | 1730 webkit_glue::ClipboardClient* |
| 1710 PepperPluginDelegateImpl::CreateClipboardClient() const { | 1731 PepperPluginDelegateImpl::CreateClipboardClient() const { |
| 1711 return new RendererClipboardClient; | 1732 return new RendererClipboardClient; |
| 1712 } | 1733 } |
| 1713 | 1734 |
| 1714 } // namespace content | 1735 } // namespace content |
| OLD | NEW |