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

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: '' Created 9 years, 4 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
« no previous file with comments | « content/renderer/pepper_plugin_delegate_impl.h ('k') | ppapi/tests/test_file_io.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 } 1009 }
991 1010
992 bool PepperPluginDelegateImpl::ReadDirectory( 1011 bool PepperPluginDelegateImpl::ReadDirectory(
993 const GURL& directory_path, 1012 const GURL& directory_path,
994 fileapi::FileSystemCallbackDispatcher* dispatcher) { 1013 fileapi::FileSystemCallbackDispatcher* dispatcher) {
995 FileSystemDispatcher* file_system_dispatcher = 1014 FileSystemDispatcher* file_system_dispatcher =
996 ChildThread::current()->file_system_dispatcher(); 1015 ChildThread::current()->file_system_dispatcher();
997 return file_system_dispatcher->ReadDirectory(directory_path, dispatcher); 1016 return file_system_dispatcher->ReadDirectory(directory_path, dispatcher);
998 } 1017 }
999 1018
1019 void PepperPluginDelegateImpl::QueryAvailableSpace(
1020 const GURL& origin, quota::StorageType type,
1021 AvailableSpaceCallback* callback) {
1022 ChildThread::current()->quota_dispatcher()->QueryStorageUsageAndQuota(
1023 origin, type, new QuotaCallbackTranslator(callback));
1024 }
1025
1026 void PepperPluginDelegateImpl::WillUpdateFile(const GURL& path) {
1027 ChildThread::current()->Send(new FileSystemHostMsg_WillUpdate(path));
1028 }
1029
1030 void PepperPluginDelegateImpl::DidUpdateFile(const GURL& path, int64_t delta) {
1031 ChildThread::current()->Send(new FileSystemHostMsg_DidUpdate(path, delta));
1032 }
1033
1000 class AsyncOpenFileSystemURLCallbackTranslator 1034 class AsyncOpenFileSystemURLCallbackTranslator
1001 : public fileapi::FileSystemCallbackDispatcher { 1035 : public fileapi::FileSystemCallbackDispatcher {
1002 public: 1036 public:
1003 AsyncOpenFileSystemURLCallbackTranslator( 1037 AsyncOpenFileSystemURLCallbackTranslator(
1004 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback) 1038 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback)
1005 : callback_(callback) { 1039 : callback_(callback) {
1006 } 1040 }
1007 1041
1008 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} 1042 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {}
1009 1043
(...skipping 334 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
« no previous file with comments | « content/renderer/pepper_plugin_delegate_impl.h ('k') | ppapi/tests/test_file_io.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698