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

Unified Diff: content/renderer/pepper_plugin_delegate_impl.cc

Issue 7433006: Pepper quota support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/pepper_plugin_delegate_impl.cc
diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc
index 325f3f8fa160c8015556c9f3f98bb0454730de12..8166dc4045fe53d94c0f76d992283f07faf0e84e 100644
--- a/content/renderer/pepper_plugin_delegate_impl.cc
+++ b/content/renderer/pepper_plugin_delegate_impl.cc
@@ -22,10 +22,12 @@
#include "content/common/child_thread.h"
#include "content/common/content_switches.h"
#include "content/common/file_system/file_system_dispatcher.h"
+#include "content/common/file_system_messages.h"
#include "content/common/media/audio_messages.h"
#include "content/common/pepper_file_messages.h"
#include "content/common/pepper_plugin_registry.h"
#include "content/common/pepper_messages.h"
+#include "content/common/quota_dispatcher.h"
#include "content/common/view_messages.h"
#include "content/renderer/content_renderer_client.h"
#include "content/renderer/gpu/command_buffer_proxy.h"
@@ -356,6 +358,24 @@ class DispatcherWrapper
scoped_ptr<pp::proxy::HostDispatcher> dispatcher_;
};
+class QuotaCallbackTranslator : public QuotaDispatcher::Callback {
+ public:
+ typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback;
+ QuotaCallbackTranslator(PluginCallback* callback) : callback_(callback) {}
+ virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE {
+ callback_->Run(std::max(static_cast<int64>(0), quota - usage));
+ }
+ virtual void DidGrantStorageQuota(int64 granted_quota) OVERRIDE {
+ NOTREACHED();
+ }
+ virtual void DidFail(quota::QuotaStatusCode error) OVERRIDE {
+ callback_->Run(0);
+ }
+
+ private:
+ scoped_ptr<PluginCallback> callback_;
+};
+
} // namespace
bool DispatcherWrapper::Init(
@@ -999,6 +1019,21 @@ bool PepperPluginDelegateImpl::ReadDirectory(
return file_system_dispatcher->ReadDirectory(directory_path, dispatcher);
}
+void PepperPluginDelegateImpl::QueryAvailableSpace(
+ const GURL& origin, quota::StorageType type,
+ AvailableSpaceCallback* callback) {
+ ChildThread::current()->quota_dispatcher()->QueryStorageUsageAndQuota(
+ origin, type, new QuotaCallbackTranslator(callback));
+}
+
+void PepperPluginDelegateImpl::WillUpdateFile(const GURL& path) {
+ ChildThread::current()->Send(new FileSystemHostMsg_WillUpdate(path));
+}
+
+void PepperPluginDelegateImpl::DidUpdateFile(const GURL& path, int64_t delta) {
+ ChildThread::current()->Send(new FileSystemHostMsg_DidUpdate(path, delta));
+}
+
class AsyncOpenFileSystemURLCallbackTranslator
: public fileapi::FileSystemCallbackDispatcher {
public:
@@ -1047,8 +1082,8 @@ class AsyncOpenFileSystemURLCallbackTranslator
}
}
-private: // TODO(ericu): Delete this?
- webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback_;
+private:
+ scoped_ptr<webkit::ppapi::PluginDelegate::AsyncOpenFileCallback> callback_;
};
bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL(

Powered by Google App Engine
This is Rietveld 408576698