summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authordumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-10 04:06:24 +0000
committerdumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-10 04:06:24 +0000
commit27a9ef35b1d9b91dbd5e70e33c808bf05431c4dc (patch)
tree1bed42107533d6e15328ed585504ce5ac4bfe1ea /chrome/renderer
parent3fb43ed1ad7bcfeb686aa48e296ffbc639b35ad7 (diff)
downloadchromium_src-27a9ef35b1d9b91dbd5e70e33c808bf05431c4dc.zip
chromium_src-27a9ef35b1d9b91dbd5e70e33c808bf05431c4dc.tar.gz
chromium_src-27a9ef35b1d9b91dbd5e70e33c808bf05431c4dc.tar.bz2
Implement pepper::FileIO.
TEST=none BUG=none Review URL: http://codereview.chromium.org/3329014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59045 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.cc34
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.h15
-rw-r--r--chrome/renderer/render_view.cc10
-rw-r--r--chrome/renderer/render_view.h4
4 files changed, 62 insertions, 1 deletions
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc
index 8e6763c..a3f2735 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.cc
+++ b/chrome/renderer/pepper_plugin_delegate_impl.cc
@@ -5,6 +5,7 @@
#include "chrome/renderer/pepper_plugin_delegate_impl.h"
#include "app/surface/transport_dib.h"
+#include "base/file_path.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "base/task.h"
@@ -12,12 +13,14 @@
#include "chrome/common/render_messages_params.h"
#include "chrome/renderer/audio_message_filter.h"
#include "chrome/renderer/command_buffer_proxy.h"
+#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/render_view.h"
#include "chrome/renderer/webplugin_delegate_proxy.h"
#include "third_party/ppapi/c/dev/pp_video_dev.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFileChooserCompletion.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
+#include "webkit/glue/plugins/pepper_file_io.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/webplugin.h"
@@ -472,7 +475,8 @@ class PlatformVideoDecoderImpl
} // namespace
PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view)
- : render_view_(render_view) {
+ : render_view_(render_view),
+ id_generator_(0) {
}
void PepperPluginDelegateImpl::ViewInitiatedPaint() {
@@ -609,3 +613,31 @@ bool PepperPluginDelegateImpl::RunFileChooser(
WebKit::WebFileChooserCompletion* chooser_completion) {
return render_view_->runFileChooser(params, chooser_completion);
}
+
+bool PepperPluginDelegateImpl::AsyncOpenFile(const FilePath& path,
+ int flags,
+ AsyncOpenFileCallback* callback) {
+ int message_id = id_generator_++;
+ DCHECK(!messages_waiting_replies_.Lookup(message_id));
+ messages_waiting_replies_.AddWithID(callback, message_id);
+ IPC::Message* msg = new ViewHostMsg_AsyncOpenFile(
+ render_view_->routing_id(), path, flags, message_id);
+ return render_view_->Send(msg);
+}
+
+void PepperPluginDelegateImpl::OnAsyncFileOpened(
+ base::PlatformFileError error_code,
+ base::PlatformFile file,
+ int message_id) {
+ AsyncOpenFileCallback* callback =
+ messages_waiting_replies_.Lookup(message_id);
+ DCHECK(callback);
+ messages_waiting_replies_.Remove(message_id);
+ callback->Run(error_code, file);
+ delete callback;
+}
+
+scoped_refptr<base::MessageLoopProxy>
+PepperPluginDelegateImpl::GetFileThreadMessageLoopProxy() {
+ return RenderThread::current()->GetFileThreadMessageLoopProxy();
+}
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.h b/chrome/renderer/pepper_plugin_delegate_impl.h
index 1930fa8..ebc19ee 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.h
+++ b/chrome/renderer/pepper_plugin_delegate_impl.h
@@ -9,14 +9,17 @@
#include <set>
#include "base/basictypes.h"
+#include "base/id_map.h"
#include "base/weak_ptr.h"
#include "third_party/ppapi/c/pp_errors.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
+class FilePath;
class RenderView;
namespace pepper {
+class FileIO;
class PluginInstance;
}
@@ -37,6 +40,11 @@ class PepperPluginDelegateImpl
void ViewInitiatedPaint();
void ViewFlushedPaint();
+ // Called by RenderView when ViewMsg_AsyncOpenFile_ACK.
+ void OnAsyncFileOpened(base::PlatformFileError error_code,
+ base::PlatformFile file,
+ int message_id);
+
// pepper::PluginDelegate implementation.
virtual void InstanceCreated(pepper::PluginInstance* instance);
virtual void InstanceDeleted(pepper::PluginInstance* instance);
@@ -55,6 +63,10 @@ class PepperPluginDelegateImpl
virtual bool RunFileChooser(
const WebKit::WebFileChooserParams& params,
WebKit::WebFileChooserCompletion* chooser_completion);
+ virtual bool AsyncOpenFile(const FilePath& path,
+ int flags,
+ AsyncOpenFileCallback* callback);
+ virtual scoped_refptr<base::MessageLoopProxy> GetFileThreadMessageLoopProxy();
private:
// Pointer to the RenderView that owns us.
@@ -62,6 +74,9 @@ class PepperPluginDelegateImpl
std::set<pepper::PluginInstance*> active_instances_;
+ int id_generator_;
+ IDMap<AsyncOpenFileCallback> messages_waiting_replies_;
+
DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImpl);
};
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 0f40d00..ed19289 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -805,6 +805,7 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
OnAccessibilityObjectChildrenChangeAck)
IPC_MESSAGE_HANDLER(ViewMsg_OpenFileSystemRequest_Complete,
OnOpenFileSystemRequestComplete)
+ IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened)
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message))
@@ -5689,3 +5690,12 @@ void RenderView::OnOpenFileSystemRequestComplete(
request->callbacks = NULL;
pending_file_system_requests_.Remove(request_id);
}
+
+void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code,
+ IPC::PlatformFileForTransit file_for_transit,
+ int message_id) {
+ pepper_delegate_.OnAsyncFileOpened(
+ error_code,
+ IPC::PlatformFileForTransitToPlatformFile(file_for_transit),
+ message_id);
+}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index cf06c09..cd57b10 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -855,6 +855,10 @@ class RenderView : public RenderWidget,
#endif
void OnZoom(PageZoom::Function function);
+ void OnAsyncFileOpened(base::PlatformFileError error_code,
+ IPC::PlatformFileForTransit file_for_transit,
+ int message_id);
+
// Adding a new message handler? Please add it in alphabetical order above
// and put it in the same position in the .cc file.