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

Side by Side 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: fixed tests 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_plugin_delegate_impl.h" 5 #include "content/renderer/pepper_plugin_delegate_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/file_util_proxy.h" 13 #include "base/file_util_proxy.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/string_split.h" 16 #include "base/string_split.h"
17 #include "base/sync_socket.h" 17 #include "base/sync_socket.h"
18 #include "base/task.h" 18 #include "base/task.h"
19 #include "base/time.h" 19 #include "base/time.h"
20 #include "content/common/child_process_messages.h" 20 #include "content/common/child_process_messages.h"
21 #include "content/common/child_process.h" 21 #include "content/common/child_process.h"
22 #include "content/common/child_thread.h" 22 #include "content/common/child_thread.h"
23 #include "content/common/content_switches.h" 23 #include "content/common/content_switches.h"
24 #include "content/common/file_system/file_system_dispatcher.h" 24 #include "content/common/file_system/file_system_dispatcher.h"
25 #include "content/common/file_system_messages.h"
25 #include "content/common/media/audio_messages.h" 26 #include "content/common/media/audio_messages.h"
26 #include "content/common/pepper_file_messages.h" 27 #include "content/common/pepper_file_messages.h"
27 #include "content/common/pepper_plugin_registry.h" 28 #include "content/common/pepper_plugin_registry.h"
28 #include "content/common/pepper_messages.h" 29 #include "content/common/pepper_messages.h"
30 #include "content/common/quota_dispatcher.h"
29 #include "content/common/view_messages.h" 31 #include "content/common/view_messages.h"
30 #include "content/renderer/content_renderer_client.h" 32 #include "content/renderer/content_renderer_client.h"
31 #include "content/renderer/gpu/command_buffer_proxy.h" 33 #include "content/renderer/gpu/command_buffer_proxy.h"
32 #include "content/renderer/gpu/gpu_channel_host.h" 34 #include "content/renderer/gpu/gpu_channel_host.h"
33 #include "content/renderer/gpu/renderer_gl_context.h" 35 #include "content/renderer/gpu/renderer_gl_context.h"
34 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" 36 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h"
35 #include "content/renderer/media/audio_message_filter.h" 37 #include "content/renderer/media/audio_message_filter.h"
36 #include "content/renderer/p2p/p2p_transport_impl.h" 38 #include "content/renderer/p2p/p2p_transport_impl.h"
37 #include "content/renderer/pepper_platform_context_3d_impl.h" 39 #include "content/renderer/pepper_platform_context_3d_impl.h"
38 #include "content/renderer/pepper_platform_video_decoder_impl.h" 40 #include "content/renderer/pepper_platform_video_decoder_impl.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 pp::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); 351 pp::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get());
350 } 352 }
351 virtual void RemoveInstance(PP_Instance instance) { 353 virtual void RemoveInstance(PP_Instance instance) {
352 pp::proxy::HostDispatcher::RemoveForInstance(instance); 354 pp::proxy::HostDispatcher::RemoveForInstance(instance);
353 } 355 }
354 356
355 private: 357 private:
356 scoped_ptr<pp::proxy::HostDispatcher> dispatcher_; 358 scoped_ptr<pp::proxy::HostDispatcher> dispatcher_;
357 }; 359 };
358 360
361 class QuotaCallbackTranslator : public QuotaDispatcher::Callback {
362 public:
363 typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback;
364 explicit QuotaCallbackTranslator(PluginCallback* cb) : callback_(cb) {}
365 virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE {
366 callback_->Run(std::max(static_cast<int64>(0), quota - usage));
367 }
368 virtual void DidGrantStorageQuota(int64 granted_quota) OVERRIDE {
369 NOTREACHED();
370 }
371 virtual void DidFail(quota::QuotaStatusCode error) OVERRIDE {
372 callback_->Run(0);
373 }
374 private:
375 scoped_ptr<PluginCallback> callback_;
376 };
377
359 } // namespace 378 } // namespace
360 379
361 bool DispatcherWrapper::Init( 380 bool DispatcherWrapper::Init(
362 RenderView* render_view, 381 RenderView* render_view,
363 base::ProcessHandle plugin_process_handle, 382 base::ProcessHandle plugin_process_handle,
364 const IPC::ChannelHandle& channel_handle, 383 const IPC::ChannelHandle& channel_handle,
365 PP_Module pp_module, 384 PP_Module pp_module,
366 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface) { 385 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface) {
367 dispatcher_.reset(new pp::proxy::HostDispatcher( 386 dispatcher_.reset(new pp::proxy::HostDispatcher(
368 plugin_process_handle, pp_module, local_get_interface)); 387 plugin_process_handle, pp_module, local_get_interface));
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 } 1011 }
993 1012
994 bool PepperPluginDelegateImpl::ReadDirectory( 1013 bool PepperPluginDelegateImpl::ReadDirectory(
995 const GURL& directory_path, 1014 const GURL& directory_path,
996 fileapi::FileSystemCallbackDispatcher* dispatcher) { 1015 fileapi::FileSystemCallbackDispatcher* dispatcher) {
997 FileSystemDispatcher* file_system_dispatcher = 1016 FileSystemDispatcher* file_system_dispatcher =
998 ChildThread::current()->file_system_dispatcher(); 1017 ChildThread::current()->file_system_dispatcher();
999 return file_system_dispatcher->ReadDirectory(directory_path, dispatcher); 1018 return file_system_dispatcher->ReadDirectory(directory_path, dispatcher);
1000 } 1019 }
1001 1020
1021 void PepperPluginDelegateImpl::QueryAvailableSpace(
1022 const GURL& origin, quota::StorageType type,
1023 AvailableSpaceCallback* callback) {
1024 ChildThread::current()->quota_dispatcher()->QueryStorageUsageAndQuota(
1025 origin, type, new QuotaCallbackTranslator(callback));
1026 }
1027
1028 void PepperPluginDelegateImpl::WillUpdateFile(const GURL& path) {
1029 ChildThread::current()->Send(new FileSystemHostMsg_WillUpdate(path));
1030 }
1031
1032 void PepperPluginDelegateImpl::DidUpdateFile(const GURL& path, int64_t delta) {
1033 ChildThread::current()->Send(new FileSystemHostMsg_DidUpdate(path, delta));
1034 }
1035
1002 class AsyncOpenFileSystemURLCallbackTranslator 1036 class AsyncOpenFileSystemURLCallbackTranslator
1003 : public fileapi::FileSystemCallbackDispatcher { 1037 : public fileapi::FileSystemCallbackDispatcher {
1004 public: 1038 public:
1005 AsyncOpenFileSystemURLCallbackTranslator( 1039 AsyncOpenFileSystemURLCallbackTranslator(
1006 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback) 1040 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback)
1007 : callback_(callback) { 1041 : callback_(callback) {
1008 } 1042 }
1009 1043
1010 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} 1044 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {}
1011 1045
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 if (!base::SharedMemory::IsHandleValid(handle)) { 1378 if (!base::SharedMemory::IsHandleValid(handle)) {
1345 DLOG(WARNING) << "Browser failed to allocate shared memory"; 1379 DLOG(WARNING) << "Browser failed to allocate shared memory";
1346 return NULL; 1380 return NULL;
1347 } 1381 }
1348 return new base::SharedMemory(handle, false); 1382 return new base::SharedMemory(handle, false);
1349 } 1383 }
1350 1384
1351 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { 1385 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() {
1352 return ppapi::Preferences(render_view_->webkit_preferences()); 1386 return ppapi::Preferences(render_view_->webkit_preferences());
1353 } 1387 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698