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

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: Rebase. 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 virtual bool HandleMouseLockedInputEvent( 187 virtual bool HandleMouseLockedInputEvent(
188 const WebKit::WebMouseEvent &event) OVERRIDE { 188 const WebKit::WebMouseEvent &event) OVERRIDE {
189 plugin_->HandleMouseLockedInputEvent(event); 189 plugin_->HandleMouseLockedInputEvent(event);
190 return true; 190 return true;
191 } 191 }
192 192
193 private: 193 private:
194 webkit::ppapi::PluginInstance* plugin_; 194 webkit::ppapi::PluginInstance* plugin_;
195 }; 195 };
196 196
197 class AsyncOpenFileSystemURLCallbackTranslator
198 : public fileapi::FileSystemCallbackDispatcher {
199 public:
200 AsyncOpenFileSystemURLCallbackTranslator(
201 const webkit::ppapi::PluginDelegate::AsyncOpenFileSystemURLCallback&
202 callback,
203 const webkit::ppapi::PluginDelegate::NotifyCloseFileCallback&
204 close_file_callback)
205 : callback_(callback),
206 close_file_callback_(close_file_callback) {
207 }
208
209 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {}
210
211 virtual void DidSucceed() {
212 NOTREACHED();
213 }
214 virtual void DidReadMetadata(
215 const base::PlatformFileInfo& file_info,
216 const FilePath& platform_path) {
217 NOTREACHED();
218 }
219 virtual void DidReadDirectory(
220 const std::vector<base::FileUtilProxy::Entry>& entries,
221 bool has_more) {
222 NOTREACHED();
223 }
224 virtual void DidOpenFileSystem(const std::string& name,
225 const GURL& root) {
226 NOTREACHED();
227 }
228
229 virtual void DidFail(base::PlatformFileError error_code) {
230 base::PlatformFile invalid_file = base::kInvalidPlatformFileValue;
231 callback_.Run(error_code,
232 base::PassPlatformFile(&invalid_file),
233 webkit::ppapi::PluginDelegate::NotifyCloseFileCallback());
234 }
235
236 virtual void DidWrite(int64 bytes, bool complete) {
237 NOTREACHED();
238 }
239
240 virtual void DidOpenFile(base::PlatformFile file) {
241 callback_.Run(base::PLATFORM_FILE_OK,
242 base::PassPlatformFile(&file),
243 close_file_callback_);
244 // Make sure we won't leak file handle if the requester has died.
245 if (file != base::kInvalidPlatformFileValue) {
246 base::FileUtilProxy::Close(
247 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file,
248 close_file_callback_);
249 }
250 }
251
252 private:
253 webkit::ppapi::PluginDelegate::AsyncOpenFileSystemURLCallback callback_;
254 webkit::ppapi::PluginDelegate::NotifyCloseFileCallback close_file_callback_;
255 };
256
257 void DoNotifyCloseFile(const GURL& path, base::PlatformFileError /* unused */) {
258 ChildThread::current()->file_system_dispatcher()->NotifyCloseFile(path);
259 }
260
197 } // namespace 261 } // namespace
198 262
199 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderViewImpl* render_view) 263 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderViewImpl* render_view)
200 : RenderViewObserver(render_view), 264 : RenderViewObserver(render_view),
201 render_view_(render_view), 265 render_view_(render_view),
202 has_saved_context_menu_action_(false), 266 has_saved_context_menu_action_(false),
203 saved_context_menu_action_(0), 267 saved_context_menu_action_(0),
204 focused_plugin_(NULL), 268 focused_plugin_(NULL),
205 last_mouse_event_target_(NULL), 269 last_mouse_event_target_(NULL),
206 device_enumeration_event_handler_( 270 device_enumeration_event_handler_(
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 } 916 }
853 917
854 void PepperPluginDelegateImpl::WillUpdateFile(const GURL& path) { 918 void PepperPluginDelegateImpl::WillUpdateFile(const GURL& path) {
855 ChildThread::current()->Send(new FileSystemHostMsg_WillUpdate(path)); 919 ChildThread::current()->Send(new FileSystemHostMsg_WillUpdate(path));
856 } 920 }
857 921
858 void PepperPluginDelegateImpl::DidUpdateFile(const GURL& path, int64_t delta) { 922 void PepperPluginDelegateImpl::DidUpdateFile(const GURL& path, int64_t delta) {
859 ChildThread::current()->Send(new FileSystemHostMsg_DidUpdate(path, delta)); 923 ChildThread::current()->Send(new FileSystemHostMsg_DidUpdate(path, delta));
860 } 924 }
861 925
862 class AsyncOpenFileSystemURLCallbackTranslator
863 : public fileapi::FileSystemCallbackDispatcher {
864 public:
865 AsyncOpenFileSystemURLCallbackTranslator(
866 const webkit::ppapi::PluginDelegate::AsyncOpenFileCallback& callback)
867 : callback_(callback) {
868 }
869
870 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {}
871
872 virtual void DidSucceed() {
873 NOTREACHED();
874 }
875 virtual void DidReadMetadata(
876 const base::PlatformFileInfo& file_info,
877 const FilePath& platform_path) {
878 NOTREACHED();
879 }
880 virtual void DidReadDirectory(
881 const std::vector<base::FileUtilProxy::Entry>& entries,
882 bool has_more) {
883 NOTREACHED();
884 }
885 virtual void DidOpenFileSystem(const std::string& name,
886 const GURL& root) {
887 NOTREACHED();
888 }
889
890 virtual void DidFail(base::PlatformFileError error_code) {
891 base::PlatformFile invalid_file = base::kInvalidPlatformFileValue;
892 callback_.Run(error_code, base::PassPlatformFile(&invalid_file));
893 }
894
895 virtual void DidWrite(int64 bytes, bool complete) {
896 NOTREACHED();
897 }
898
899 virtual void DidOpenFile(
900 base::PlatformFile file) {
901 callback_.Run(base::PLATFORM_FILE_OK, base::PassPlatformFile(&file));
902 // Make sure we won't leak file handle if the requester has died.
903 if (file != base::kInvalidPlatformFileValue) {
904 base::FileUtilProxy::Close(
905 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file,
906 base::FileUtilProxy::StatusCallback());
907 }
908 }
909
910 private: // TODO(ericu): Delete this?
911 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback callback_;
912 };
913
914 bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL( 926 bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL(
915 const GURL& path, int flags, const AsyncOpenFileCallback& callback) { 927 const GURL& path,
928 int flags,
929 const AsyncOpenFileSystemURLCallback& callback) {
916 930
917 FileSystemDispatcher* file_system_dispatcher = 931 FileSystemDispatcher* file_system_dispatcher =
918 ChildThread::current()->file_system_dispatcher(); 932 ChildThread::current()->file_system_dispatcher();
919 return file_system_dispatcher->OpenFile(path, flags, 933 return file_system_dispatcher->OpenFile(path, flags,
920 new AsyncOpenFileSystemURLCallbackTranslator(callback)); 934 new AsyncOpenFileSystemURLCallbackTranslator(
935 callback,
936 base::Bind(&DoNotifyCloseFile, path)));
921 } 937 }
922 938
923 base::PlatformFileError PepperPluginDelegateImpl::OpenFile( 939 base::PlatformFileError PepperPluginDelegateImpl::OpenFile(
924 const ppapi::PepperFilePath& path, 940 const ppapi::PepperFilePath& path,
925 int flags, 941 int flags,
926 base::PlatformFile* file) { 942 base::PlatformFile* file) {
927 IPC::PlatformFileForTransit transit_file; 943 IPC::PlatformFileForTransit transit_file;
928 base::PlatformFileError error; 944 base::PlatformFileError error;
929 IPC::Message* msg = new PepperFileMsg_OpenFile( 945 IPC::Message* msg = new PepperFileMsg_OpenFile(
930 path, flags, &error, &transit_file); 946 path, flags, &error, &transit_file);
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 else 1729 else
1714 return render_view_->mouse_lock_dispatcher(); 1730 return render_view_->mouse_lock_dispatcher();
1715 } 1731 }
1716 1732
1717 webkit_glue::ClipboardClient* 1733 webkit_glue::ClipboardClient*
1718 PepperPluginDelegateImpl::CreateClipboardClient() const { 1734 PepperPluginDelegateImpl::CreateClipboardClient() const {
1719 return new RendererClipboardClient; 1735 return new RendererClipboardClient;
1720 } 1736 }
1721 1737
1722 } // namespace content 1738 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_delegate_impl.h ('k') | webkit/chromeos/fileapi/remote_file_system_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698