diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-07 21:45:32 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-07 21:45:32 +0000 |
commit | fa48a62baee2e842d6479d786eeb2899deb18681 (patch) | |
tree | f7c42adacc574277f60782622c00ac78a1d5f11e /content | |
parent | 83c2e233067108fb212ba4082ee02a9bff90d98d (diff) | |
download | chromium_src-fa48a62baee2e842d6479d786eeb2899deb18681.zip chromium_src-fa48a62baee2e842d6479d786eeb2899deb18681.tar.gz chromium_src-fa48a62baee2e842d6479d786eeb2899deb18681.tar.bz2 |
Convert a bunch of pepper implementation to use base::Callback.
BUG=35223
TEST=ppapi ui_tests
Review URL: http://codereview.chromium.org/8135010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104572 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/renderer/gpu/command_buffer_proxy.cc | 30 | ||||
-rw-r--r-- | content/renderer/gpu/command_buffer_proxy.h | 15 | ||||
-rw-r--r-- | content/renderer/gpu/renderer_gl_context.cc | 13 | ||||
-rw-r--r-- | content/renderer/gpu/renderer_gl_context.h | 10 | ||||
-rw-r--r-- | content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc | 12 | ||||
-rw-r--r-- | content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h | 5 | ||||
-rw-r--r-- | content/renderer/pepper_platform_context_3d_impl.cc | 18 | ||||
-rw-r--r-- | content/renderer/pepper_platform_context_3d_impl.h | 10 | ||||
-rw-r--r-- | content/renderer/pepper_plugin_delegate_impl.cc | 39 | ||||
-rw-r--r-- | content/renderer/pepper_plugin_delegate_impl.h | 16 | ||||
-rw-r--r-- | content/renderer/render_widget_fullscreen_pepper.cc | 12 | ||||
-rw-r--r-- | content/renderer/render_widget_fullscreen_pepper.h | 4 |
12 files changed, 92 insertions, 92 deletions
diff --git a/content/renderer/gpu/command_buffer_proxy.cc b/content/renderer/gpu/command_buffer_proxy.cc index 907eb072..e1f9a66 100644 --- a/content/renderer/gpu/command_buffer_proxy.cc +++ b/content/renderer/gpu/command_buffer_proxy.cc @@ -73,22 +73,23 @@ void CommandBufferProxy::OnDestroyed(gpu::error::ContextLostReason reason) { last_state_.error = gpu::error::kLostContext; last_state_.context_lost_reason = reason; - if (channel_error_callback_.get()) { - channel_error_callback_->Run(); + if (!channel_error_callback_.is_null()) { + channel_error_callback_.Run(); // Avoid calling the error callback more than once. - channel_error_callback_.reset(); + channel_error_callback_.Reset(); } } void CommandBufferProxy::OnEchoAck() { DCHECK(!echo_tasks_.empty()); - Task* task = echo_tasks_.front().release(); + base::Closure callback = echo_tasks_.front(); echo_tasks_.pop(); - task->Run(); + callback.Run(); } -void CommandBufferProxy::SetChannelErrorCallback(Callback0::Type* callback) { - channel_error_callback_.reset(callback); +void CommandBufferProxy::SetChannelErrorCallback( + const base::Closure& callback) { + channel_error_callback_ = callback; } bool CommandBufferProxy::Initialize(int32 size) { @@ -335,9 +336,10 @@ void CommandBufferProxy::SetToken(int32 token) { } void CommandBufferProxy::OnNotifyRepaint() { - if (notify_repaint_task_.get()) + if (!notify_repaint_task_.is_null()) MessageLoop::current()->PostNonNestableTask( - FROM_HERE, notify_repaint_task_.release()); + FROM_HERE, notify_repaint_task_); + notify_repaint_task_.Reset(); } void CommandBufferProxy::SetParseError( @@ -352,18 +354,16 @@ void CommandBufferProxy::SetContextLostReason( NOTREACHED(); } -bool CommandBufferProxy::Echo(Task* task) { +bool CommandBufferProxy::Echo(const base::Closure& callback) { if (last_state_.error != gpu::error::kNoError) { - delete task; return false; } if (!Send(new GpuChannelMsg_Echo(GpuCommandBufferMsg_EchoAck(route_id_)))) { - delete task; return false; } - echo_tasks_.push(linked_ptr<Task>(task)); + echo_tasks_.push(callback); return true; } @@ -395,8 +395,8 @@ bool CommandBufferProxy::SetParent(CommandBufferProxy* parent_command_buffer, return result; } -void CommandBufferProxy::SetNotifyRepaintTask(Task* task) { - notify_repaint_task_.reset(task); +void CommandBufferProxy::SetNotifyRepaintTask(const base::Closure& task) { + notify_repaint_task_ = task; } scoped_refptr<GpuVideoDecodeAcceleratorHost> diff --git a/content/renderer/gpu/command_buffer_proxy.h b/content/renderer/gpu/command_buffer_proxy.h index 52cc471..efb89fe 100644 --- a/content/renderer/gpu/command_buffer_proxy.h +++ b/content/renderer/gpu/command_buffer_proxy.h @@ -11,7 +11,7 @@ #include <map> #include <queue> -#include "base/callback_old.h" +#include "base/callback.h" #include "base/memory/linked_ptr.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" @@ -31,7 +31,6 @@ class Size; class GpuChannelHost; class PluginChannelHost; -class Task; // Client side proxy that forwards messages synchronously to a // CommandBufferStub. @@ -69,7 +68,7 @@ class CommandBufferProxy : public gpu::CommandBuffer, // Invoke the task when the channel has been flushed. Takes care of deleting // the task whether the echo succeeds or not. - bool Echo(Task* task); + bool Echo(const base::Closure& callback); // Reparent a command buffer. TODO(apatrick): going forward, the notion of // the parent / child relationship between command buffers is going away in @@ -78,11 +77,11 @@ class CommandBufferProxy : public gpu::CommandBuffer, virtual bool SetParent(CommandBufferProxy* parent_command_buffer, uint32 parent_texture_id); - void SetChannelErrorCallback(Callback0::Type* callback); + void SetChannelErrorCallback(const base::Closure& callback); // Set a task that will be invoked the next time the window becomes invalid // and needs to be repainted. Takes ownership of task. - void SetNotifyRepaintTask(Task* task); + void SetNotifyRepaintTask(const base::Closure& callback); // Sends an IPC message to create a GpuVideoDecodeAccelerator. Creates and // returns a pointer to a GpuVideoDecodeAcceleratorHost. @@ -130,11 +129,11 @@ class CommandBufferProxy : public gpu::CommandBuffer, unsigned int flush_count_; // Tasks to be invoked in echo responses. - std::queue<linked_ptr<Task> > echo_tasks_; + std::queue<base::Closure> echo_tasks_; - scoped_ptr<Task> notify_repaint_task_; + base::Closure notify_repaint_task_; - scoped_ptr<Callback0::Type> channel_error_callback_; + base::Closure channel_error_callback_; DISALLOW_COPY_AND_ASSIGN(CommandBufferProxy); }; diff --git a/content/renderer/gpu/renderer_gl_context.cc b/content/renderer/gpu/renderer_gl_context.cc index af93c92..2611ec9 100644 --- a/content/renderer/gpu/renderer_gl_context.cc +++ b/content/renderer/gpu/renderer_gl_context.cc @@ -4,6 +4,7 @@ #include "content/renderer/gpu/renderer_gl_context.h" +#include "base/bind.h" #include "base/debug/trace_event.h" #include "base/lazy_instance.h" #include "base/memory/ref_counted.h" @@ -192,8 +193,8 @@ void RendererGLContext::DeleteParentTexture(uint32 texture) { } void RendererGLContext::SetContextLostCallback( - Callback1<ContextLostReason>::Type* callback) { - context_lost_callback_.reset(callback); + const base::Callback<void (ContextLostReason)>& callback) { + context_lost_callback_ = callback; } bool RendererGLContext::MakeCurrent(RendererGLContext* context) { @@ -229,7 +230,7 @@ bool RendererGLContext::SwapBuffers() { return true; } -bool RendererGLContext::Echo(Task* task) { +bool RendererGLContext::Echo(const base::Closure& task) { return command_buffer_->Echo(task); } @@ -371,7 +372,7 @@ bool RendererGLContext::Initialize(bool onscreen, } command_buffer_->SetChannelErrorCallback( - NewCallback(this, &RendererGLContext::OnContextLost)); + base::Bind(&RendererGLContext::OnContextLost, base::Unretained(this))); // Create the GLES2 helper, which writes the command buffer protocol. gles2_helper_ = new gpu::gles2::GLES2CmdHelper(command_buffer_); @@ -446,12 +447,12 @@ void RendererGLContext::Destroy() { } void RendererGLContext::OnContextLost() { - if (context_lost_callback_.get()) { + if (!context_lost_callback_.is_null()) { RendererGLContext::ContextLostReason reason = kUnknown; if (command_buffer_) { reason = ConvertReason( command_buffer_->GetLastState().context_lost_reason); } - context_lost_callback_->Run(reason); + context_lost_callback_.Run(reason); } } diff --git a/content/renderer/gpu/renderer_gl_context.h b/content/renderer/gpu/renderer_gl_context.h index 8b04fd2..37da68d 100644 --- a/content/renderer/gpu/renderer_gl_context.h +++ b/content/renderer/gpu/renderer_gl_context.h @@ -10,7 +10,7 @@ #define CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ #pragma once -#include "base/callback_old.h" +#include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" @@ -22,7 +22,6 @@ class GpuChannelHost; class CommandBufferProxy; class GURL; -class Task; class TransportTextureHost; namespace gpu { @@ -142,7 +141,8 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext>, // Deletes a texture in the parent's RendererGLContext. void DeleteParentTexture(uint32 texture); - void SetContextLostCallback(Callback1<ContextLostReason>::Type* callback); + void SetContextLostCallback( + const base::Callback<void(ContextLostReason)>& callback); // Set the current RendererGLContext for the calling thread. static bool MakeCurrent(RendererGLContext* context); @@ -155,7 +155,7 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext>, // Run the task once the channel has been flushed. Takes care of deleting the // task whether the echo succeeds or not. - bool Echo(Task* task); + bool Echo(const base::Closure& task); // Create a TransportTextureHost object associated with the context. scoped_refptr<TransportTextureHost> CreateTransportTextureHost(); @@ -192,7 +192,7 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext>, scoped_refptr<GpuChannelHost> channel_; base::WeakPtr<RendererGLContext> parent_; - scoped_ptr<Callback1<ContextLostReason>::Type> context_lost_callback_; + base::Callback<void(ContextLostReason)> context_lost_callback_; uint32 parent_texture_id_; CommandBufferProxy* command_buffer_; gpu::gles2::GLES2CmdHelper* gles2_helper_; diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc index da50f0c..29a368a 100644 --- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc @@ -15,6 +15,7 @@ #include <algorithm> #include <set> +#include "base/bind.h" #include "base/lazy_instance.h" #include "base/string_tokenizer.h" #include "base/command_line.h" @@ -52,7 +53,7 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl() cached_width_(0), cached_height_(0), bound_fbo_(0), - method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { + weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } WebGraphicsContext3DCommandBufferImpl:: @@ -174,8 +175,8 @@ bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation"); context_->SetContextLostCallback( - NewCallback(this, - &WebGraphicsContext3DCommandBufferImpl::OnContextLost)); + base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnContextLost, + weak_ptr_factory_.GetWeakPtr())); // TODO(gman): Remove this. const CommandLine& command_line = *CommandLine::ForCurrentProcess(); @@ -245,8 +246,9 @@ void WebGraphicsContext3DCommandBufferImpl::prepareTexture() { if (renderview) renderview->OnViewContextSwapBuffersPosted(); context_->SwapBuffers(); - context_->Echo(method_factory_.NewRunnableMethod( - &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete)); + context_->Echo(base::Bind( + &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, + weak_ptr_factory_.GetWeakPtr())); #if defined(OS_MACOSX) // It appears that making the compositor's on-screen context current on // other platforms implies this flush. TODO(kbr): this means that the diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h index 48e7d9a..c1265f1 100644 --- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h +++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h @@ -11,7 +11,7 @@ #include <vector> #include "base/memory/scoped_ptr.h" -#include "base/task.h" +#include "base/memory/weak_ptr.h" #include "content/renderer/gpu/renderer_gl_context.h" #include "googleurl/src/gurl.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D.h" @@ -487,8 +487,7 @@ class WebGraphicsContext3DCommandBufferImpl // Errors raised by synthesizeGLError(). std::vector<WGC3Denum> synthetic_errors_; - ScopedRunnableMethodFactory<WebGraphicsContext3DCommandBufferImpl> - method_factory_; + base::WeakPtrFactory<WebGraphicsContext3DCommandBufferImpl> weak_ptr_factory_; #ifdef FLIP_FRAMEBUFFER_VERTICALLY scoped_array<uint8> scanline_; diff --git a/content/renderer/pepper_platform_context_3d_impl.cc b/content/renderer/pepper_platform_context_3d_impl.cc index 6b50700..af08efd 100644 --- a/content/renderer/pepper_platform_context_3d_impl.cc +++ b/content/renderer/pepper_platform_context_3d_impl.cc @@ -4,6 +4,7 @@ #include "content/renderer/pepper_platform_context_3d_impl.h" +#include "base/bind.h" #include "content/renderer/render_thread_impl.h" #include "content/renderer/gpu/renderer_gl_context.h" #include "content/renderer/gpu/gpu_channel_host.h" @@ -18,7 +19,7 @@ PlatformContext3DImpl::PlatformContext3DImpl(RendererGLContext* parent_context) : parent_context_(parent_context->AsWeakPtr()), parent_texture_id_(0), command_buffer_(NULL), - callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { + weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } PlatformContext3DImpl::~PlatformContext3DImpl() { @@ -105,8 +106,9 @@ bool PlatformContext3DImpl::Init(const int32* attrib_list) { if (!command_buffer_->SetParent(parent_command_buffer, parent_texture_id_)) return false; - command_buffer_->SetChannelErrorCallback(callback_factory_.NewCallback( - &PlatformContext3DImpl::OnContextLost)); + command_buffer_->SetChannelErrorCallback( + base::Bind(&PlatformContext3DImpl::OnContextLost, + weak_ptr_factory_.GetWeakPtr())); return true; } @@ -125,19 +127,19 @@ int PlatformContext3DImpl::GetCommandBufferRouteId() { return command_buffer_->route_id(); } -void PlatformContext3DImpl::SetContextLostCallback(Callback0::Type* callback) { - context_lost_callback_.reset(callback); +void PlatformContext3DImpl::SetContextLostCallback(const base::Closure& task) { + context_lost_callback_ = task; } -bool PlatformContext3DImpl::Echo(Task* task) { +bool PlatformContext3DImpl::Echo(const base::Closure& task) { return command_buffer_->Echo(task); } void PlatformContext3DImpl::OnContextLost() { DCHECK(command_buffer_); - if (context_lost_callback_.get()) - context_lost_callback_->Run(); + if (!context_lost_callback_.is_null()) + context_lost_callback_.Run(); } #endif // ENABLE_GPU diff --git a/content/renderer/pepper_platform_context_3d_impl.h b/content/renderer/pepper_platform_context_3d_impl.h index d793758..ff4c1c2 100644 --- a/content/renderer/pepper_platform_context_3d_impl.h +++ b/content/renderer/pepper_platform_context_3d_impl.h @@ -5,7 +5,6 @@ #define CONTENT_RENDERER_PEPPER_PLATFORM_CONTEXT_3D_IMPL_H_ #include "base/callback.h" -#include "base/memory/scoped_callback_factory.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "webkit/plugins/ppapi/plugin_delegate.h" @@ -21,7 +20,6 @@ class CommandBuffer; class CommandBufferProxy; class GpuChannelHost; class RendererGLContext; -class Task; class PlatformContext3DImpl : public webkit::ppapi::PluginDelegate::PlatformContext3D { @@ -33,8 +31,8 @@ class PlatformContext3DImpl virtual unsigned GetBackingTextureId(); virtual gpu::CommandBuffer* GetCommandBuffer(); virtual int GetCommandBufferRouteId(); - virtual void SetContextLostCallback(Callback0::Type* callback); - virtual bool Echo(Task* task); + virtual void SetContextLostCallback(const base::Closure& callback); + virtual bool Echo(const base::Closure& task); private: bool InitRaw(); @@ -44,8 +42,8 @@ class PlatformContext3DImpl scoped_refptr<GpuChannelHost> channel_; unsigned int parent_texture_id_; CommandBufferProxy* command_buffer_; - scoped_ptr<Callback0::Type> context_lost_callback_; - base::ScopedCallbackFactory<PlatformContext3DImpl> callback_factory_; + base::Closure context_lost_callback_; + base::WeakPtrFactory<PlatformContext3DImpl> weak_ptr_factory_; }; #endif // ENABLE_GPU diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc index 438afc7..866aa3b 100644 --- a/content/renderer/pepper_plugin_delegate_impl.cc +++ b/content/renderer/pepper_plugin_delegate_impl.cc @@ -280,7 +280,7 @@ void PlatformAudioImpl::ShutDown() { client_ = NULL; ChildProcess::current()->io_message_loop()->PostTask( FROM_HERE, - NewRunnableMethod(this, &PlatformAudioImpl::ShutDownOnIOThread)); + base::Bind(&PlatformAudioImpl::ShutDownOnIOThread, this)); } void PlatformAudioImpl::InitializeOnIOThread(const AudioParameters& params) { @@ -396,18 +396,18 @@ class HostDispatcherWrapper class QuotaCallbackTranslator : public QuotaDispatcher::Callback { public: typedef webkit::ppapi::PluginDelegate::AvailableSpaceCallback PluginCallback; - explicit QuotaCallbackTranslator(PluginCallback* cb) : callback_(cb) {} + explicit QuotaCallbackTranslator(const PluginCallback& cb) : callback_(cb) {} virtual void DidQueryStorageUsageAndQuota(int64 usage, int64 quota) OVERRIDE { - callback_->Run(std::max(static_cast<int64>(0), quota - usage)); + 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); + callback_.Run(0); } private: - scoped_ptr<PluginCallback> callback_; + PluginCallback callback_; }; class PlatformVideoCaptureImpl @@ -665,7 +665,6 @@ PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) : render_view_(render_view), has_saved_context_menu_action_(false), saved_context_menu_action_(0), - id_generator_(0), is_pepper_plugin_focused_(false), mouse_lock_owner_(NULL), mouse_locked_(false), @@ -1017,12 +1016,12 @@ bool PepperPluginDelegateImpl::RunFileChooser( 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); +bool PepperPluginDelegateImpl::AsyncOpenFile( + const FilePath& path, + int flags, + const AsyncOpenFileCallback& callback) { + int message_id = pending_async_open_files_.Add( + new AsyncOpenFileCallback(callback)); IPC::Message* msg = new ViewHostMsg_AsyncOpenFile( render_view_->routing_id(), path, flags, message_id); return render_view_->Send(msg); @@ -1033,9 +1032,9 @@ void PepperPluginDelegateImpl::OnAsyncFileOpened( base::PlatformFile file, int message_id) { AsyncOpenFileCallback* callback = - messages_waiting_replies_.Lookup(message_id); + pending_async_open_files_.Lookup(message_id); DCHECK(callback); - messages_waiting_replies_.Remove(message_id); + pending_async_open_files_.Remove(message_id); callback->Run(error_code, base::PassPlatformFile(&file)); // Make sure we won't leak file handle if the requester has died. if (file != base::kInvalidPlatformFileValue) @@ -1187,7 +1186,7 @@ void PepperPluginDelegateImpl::PublishPolicy(const std::string& policy_json) { void PepperPluginDelegateImpl::QueryAvailableSpace( const GURL& origin, quota::StorageType type, - AvailableSpaceCallback* callback) { + const AvailableSpaceCallback& callback) { ChildThread::current()->quota_dispatcher()->QueryStorageUsageAndQuota( origin, type, new QuotaCallbackTranslator(callback)); } @@ -1204,7 +1203,7 @@ class AsyncOpenFileSystemURLCallbackTranslator : public fileapi::FileSystemCallbackDispatcher { public: AsyncOpenFileSystemURLCallbackTranslator( - webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback) + const webkit::ppapi::PluginDelegate::AsyncOpenFileCallback& callback) : callback_(callback) { } @@ -1230,7 +1229,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)); } virtual void DidWrite(int64 bytes, bool complete) { @@ -1240,7 +1239,7 @@ class AsyncOpenFileSystemURLCallbackTranslator virtual void DidOpenFile( base::PlatformFile file, base::ProcessHandle unused) { - callback_->Run(base::PLATFORM_FILE_OK, base::PassPlatformFile(&file)); + callback_.Run(base::PLATFORM_FILE_OK, base::PassPlatformFile(&file)); // Make sure we won't leak file handle if the requester has died. if (file != base::kInvalidPlatformFileValue) { base::FileUtilProxy::Close(RenderThreadImpl::current()-> @@ -1249,11 +1248,11 @@ class AsyncOpenFileSystemURLCallbackTranslator } private: // TODO(ericu): Delete this? - webkit::ppapi::PluginDelegate::AsyncOpenFileCallback* callback_; + webkit::ppapi::PluginDelegate::AsyncOpenFileCallback callback_; }; bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL( - const GURL& path, int flags, AsyncOpenFileCallback* callback) { + const GURL& path, int flags, const AsyncOpenFileCallback& callback) { FileSystemDispatcher* file_system_dispatcher = ChildThread::current()->file_system_dispatcher(); diff --git a/content/renderer/pepper_plugin_delegate_impl.h b/content/renderer/pepper_plugin_delegate_impl.h index 7410490..432e46f 100644 --- a/content/renderer/pepper_plugin_delegate_impl.h +++ b/content/renderer/pepper_plugin_delegate_impl.h @@ -208,11 +208,11 @@ class PepperPluginDelegateImpl WebKit::WebFileChooserCompletion* chooser_completion); virtual bool AsyncOpenFile(const FilePath& path, int flags, - AsyncOpenFileCallback* callback); + const AsyncOpenFileCallback& callback); virtual bool AsyncOpenFileSystemURL( const GURL& path, int flags, - AsyncOpenFileCallback* callback) OVERRIDE; + const AsyncOpenFileCallback& callback) OVERRIDE; virtual bool OpenFileSystem( const GURL& url, fileapi::FileSystemType type, @@ -241,9 +241,10 @@ class PepperPluginDelegateImpl const GURL& directory_path, fileapi::FileSystemCallbackDispatcher* dispatcher) OVERRIDE; virtual void PublishPolicy(const std::string& policy_json) OVERRIDE; - virtual void QueryAvailableSpace(const GURL& origin, - quota::StorageType type, - AvailableSpaceCallback* callback) OVERRIDE; + virtual void QueryAvailableSpace( + const GURL& origin, + quota::StorageType type, + const AvailableSpaceCallback& callback) OVERRIDE; virtual void WillUpdateFile(const GURL& file_path) OVERRIDE; virtual void DidUpdateFile(const GURL& file_path, int64_t delta) OVERRIDE; virtual base::PlatformFileError OpenFile( @@ -341,10 +342,7 @@ class PepperPluginDelegateImpl bool has_saved_context_menu_action_; unsigned saved_context_menu_action_; - // TODO(viettrungluu): Get rid of |id_generator_| -- just use |IDMap::Add()|. - // Rename |messages_waiting_replies_| (to specify async open file). - int id_generator_; - IDMap<AsyncOpenFileCallback> messages_waiting_replies_; + IDMap<AsyncOpenFileCallback> pending_async_open_files_; IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>, IDMapOwnPointer> pending_connect_tcps_; diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc index 2a71e50..da41497 100644 --- a/content/renderer/render_widget_fullscreen_pepper.cc +++ b/content/renderer/render_widget_fullscreen_pepper.cc @@ -4,6 +4,7 @@ #include "content/renderer/render_widget_fullscreen_pepper.h" +#include "base/bind.h" #include "base/message_loop.h" #include "content/common/view_messages.h" #include "content/renderer/gpu/gpu_channel_host.h" @@ -221,7 +222,7 @@ RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper( context_(NULL), buffer_(0), program_(0), - method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { + weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } RenderWidgetFullscreenPepper::~RenderWidgetFullscreenPepper() { @@ -361,7 +362,7 @@ void RenderWidgetFullscreenPepper::CreateContext() { return; } context_->SetContextLostCallback( - NewCallback(this, &RenderWidgetFullscreenPepper::OnLostContext)); + base::Bind(&RenderWidgetFullscreenPepper::OnLostContext, this)); } namespace { @@ -474,8 +475,9 @@ void RenderWidgetFullscreenPepper::SwapBuffers() { DCHECK(context_); OnSwapBuffersPosted(); context_->SwapBuffers(); - context_->Echo(method_factory_.NewRunnableMethod( - &RenderWidgetFullscreenPepper::OnSwapBuffersCompleteByRendererGLContext)); + context_->Echo(base::Bind( + &RenderWidgetFullscreenPepper::OnSwapBuffersCompleteByRendererGLContext, + weak_ptr_factory_.GetWeakPtr())); } void RenderWidgetFullscreenPepper::OnLostContext( @@ -487,7 +489,7 @@ void RenderWidgetFullscreenPepper::OnLostContext( // created when the plugin recreates its own. MessageLoop::current()->PostTask( FROM_HERE, - NewRunnableFunction(DestroyContext, context_, program_, buffer_)); + base::Bind(DestroyContext, context_, program_, buffer_)); context_ = NULL; program_ = 0; buffer_ = 0; diff --git a/content/renderer/render_widget_fullscreen_pepper.h b/content/renderer/render_widget_fullscreen_pepper.h index b8f095f..fdae363 100644 --- a/content/renderer/render_widget_fullscreen_pepper.h +++ b/content/renderer/render_widget_fullscreen_pepper.h @@ -5,7 +5,7 @@ #ifndef CONTENT_RENDERER_RENDER_WIDGET_FULLSCREEN_PEPPER_H_ #define CONTENT_RENDERER_RENDER_WIDGET_FULLSCREEN_PEPPER_H_ -#include "base/task.h" +#include "base/memory/weak_ptr.h" #include "content/renderer/render_widget_fullscreen.h" #include "content/renderer/gpu/renderer_gl_context.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" @@ -93,7 +93,7 @@ class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen, unsigned int buffer_; unsigned int program_; - ScopedRunnableMethodFactory<RenderWidgetFullscreenPepper> method_factory_; + base::WeakPtrFactory<RenderWidgetFullscreenPepper> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(RenderWidgetFullscreenPepper); }; |