| 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..df3f848156b021355cf9459e7ea7c81dbdc858c8 100644
|
| --- a/content/renderer/pepper_plugin_delegate_impl.cc
|
| +++ b/content/renderer/pepper_plugin_delegate_impl.cc
|
| @@ -26,6 +26,7 @@
|
| #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 +357,26 @@ class DispatcherWrapper
|
| scoped_ptr<pp::proxy::HostDispatcher> dispatcher_;
|
| };
|
|
|
| +class QuotaCallbackTranslator : public QuotaDispatcher::Callback {
|
| + public:
|
| + typedef webkit::ppapi::PluginDelegate::QuotaStatusCallback PluginCallback;
|
| + QuotaCallbackTranslator(int64 requesting_size, PluginCallback* callback)
|
| + : requesting_size_(requesting_size), callback_(callback) {}
|
| + virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE {
|
| + callback_->Run((quota - usage) >= requesting_size_);
|
| + }
|
| + virtual void DidGrantStorageQuota(int64 granted_quota) OVERRIDE {
|
| + NOTREACHED();
|
| + }
|
| + virtual void DidFail(quota::QuotaStatusCode error) OVERRIDE {
|
| + callback_->Run(false);
|
| + }
|
| +
|
| + private:
|
| + int64_t requesting_size_;
|
| + scoped_ptr<PluginCallback> callback_;
|
| +};
|
| +
|
| } // namespace
|
|
|
| bool DispatcherWrapper::Init(
|
| @@ -915,7 +936,7 @@ void PepperPluginDelegateImpl::OnAsyncFileOpened(
|
| messages_waiting_replies_.Lookup(message_id);
|
| DCHECK(callback);
|
| messages_waiting_replies_.Remove(message_id);
|
| - callback->Run(error_code, base::PassPlatformFile(&file));
|
| + callback->Run(error_code, base::PassPlatformFile(&file), -1);
|
| // Make sure we won't leak file handle if the requester has died.
|
| if (file != base::kInvalidPlatformFileValue)
|
| base::FileUtilProxy::Close(GetFileThreadMessageLoopProxy(), file, NULL);
|
| @@ -999,6 +1020,21 @@ bool PepperPluginDelegateImpl::ReadDirectory(
|
| return file_system_dispatcher->ReadDirectory(directory_path, dispatcher);
|
| }
|
|
|
| +bool PepperPluginDelegateImpl::CanWrite(
|
| + const GURL& origin, quota::StorageType type, int64 growth,
|
| + QuotaStatusCallback* callback) const {
|
| + ChildThread::current()->quota_dispatcher()->QueryStorageUsageAndQuota(
|
| + origin, type, new QuotaCallbackTranslator(growth, callback));
|
| + return true;
|
| +}
|
| +
|
| +void PepperPluginDelegateImpl::NotifyStorageModified(
|
| + quota::QuotaClient::ID client_id, const GURL& origin,
|
| + quota::StorageType type, int64 delta) {
|
| + ChildThread::current()->quota_dispatcher()->NotifyStorageModified(
|
| + client_id, origin, type, delta);
|
| +}
|
| +
|
| class AsyncOpenFileSystemURLCallbackTranslator
|
| : public fileapi::FileSystemCallbackDispatcher {
|
| public:
|
| @@ -1029,7 +1065,7 @@ class AsyncOpenFileSystemURLCallbackTranslator
|
|
|
| virtual void DidFail(base::PlatformFileError error_code) {
|
| base::PlatformFile invalid_file = base::kInvalidPlatformFileValue;
|
| - callback_->Run(error_code, base::PassPlatformFile(&invalid_file));
|
| + callback_->Run(error_code, base::PassPlatformFile(&invalid_file), -1);
|
| }
|
|
|
| virtual void DidWrite(int64 bytes, bool complete) {
|
| @@ -1038,8 +1074,10 @@ class AsyncOpenFileSystemURLCallbackTranslator
|
|
|
| virtual void DidOpenFile(
|
| base::PlatformFile file,
|
| - base::ProcessHandle unused) {
|
| - callback_->Run(base::PLATFORM_FILE_OK, base::PassPlatformFile(&file));
|
| + base::ProcessHandle unused,
|
| + int64 file_size) {
|
| + callback_->Run(base::PLATFORM_FILE_OK, base::PassPlatformFile(&file),
|
| + file_size);
|
| // Make sure we won't leak file handle if the requester has died.
|
| if (file != base::kInvalidPlatformFileValue) {
|
| base::FileUtilProxy::Close(
|
| @@ -1047,8 +1085,8 @@ class AsyncOpenFileSystemURLCallbackTranslator
|
| }
|
| }
|
|
|
| -private: // TODO(ericu): Delete this?
|
| - webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback_;
|
| +private:
|
| + scoped_ptr<webkit::ppapi::PluginDelegate::AsyncOpenFileCallback> callback_;
|
| };
|
|
|
| bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL(
|
|
|