diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-18 20:09:53 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-18 20:09:53 +0000 |
commit | 6fdb043493c52b69e8fa2690c0e175866d142323 (patch) | |
tree | dc62f1ca7aac4cf8de210b533737483b8db5a74d /ppapi/native_client | |
parent | 49a71fa2fa914ade80b9f088647ee9c938a8c12a (diff) | |
download | chromium_src-6fdb043493c52b69e8fa2690c0e175866d142323.zip chromium_src-6fdb043493c52b69e8fa2690c0e175866d142323.tar.gz chromium_src-6fdb043493c52b69e8fa2690c0e175866d142323.tar.bz2 |
Rename nacl::RefCounted to nacl::RefCountedThreadSafe, to make it easier to alias as gpu::RefCountedThreadSafe.
Additionally, ensure all of the nacl::RefCountedThreadSafe-derived classes
do not have public destructors.
BUG=123295
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10386080
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137936 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/native_client')
17 files changed, 96 insertions, 62 deletions
diff --git a/ppapi/native_client/src/include/ref_counted.h b/ppapi/native_client/src/include/ref_counted.h index d1a1bbc..d62e020 100644 --- a/ppapi/native_client/src/include/ref_counted.h +++ b/ppapi/native_client/src/include/ref_counted.h @@ -65,10 +65,9 @@ class RefCountedBase { // You should always make your destructor private, to avoid any code deleting // the object accidently while there are references to it. template <class T> -class RefCounted : public subtle::RefCountedBase { +class RefCountedThreadSafe : public subtle::RefCountedBase { public: - RefCounted() { } - ~RefCounted() { } + RefCountedThreadSafe() {} void AddRef() const { subtle::RefCountedBase::AddRef(); @@ -80,9 +79,12 @@ class RefCounted : public subtle::RefCountedBase { } } + protected: + ~RefCountedThreadSafe() {} + private: - RefCounted(const RefCounted<T>&); - void operator=(const RefCounted<T>&); + RefCountedThreadSafe(const RefCountedThreadSafe<T>&); + void operator=(const RefCountedThreadSafe<T>&); }; // @@ -90,7 +92,8 @@ class RefCounted : public subtle::RefCountedBase { // scoped_refptrs<>. // template<typename T> -class RefCountedData : public nacl::RefCounted< nacl::RefCountedData<T> > { +class RefCountedData + : public RefCountedThreadSafe<RefCountedData<T> > { public: RefCountedData() : data() {} RefCountedData(const T& in_value) : data(in_value) {} @@ -151,8 +154,7 @@ class RefCountedData : public nacl::RefCounted< nacl::RefCountedData<T> > { template <class T> class scoped_refptr { public: - scoped_refptr() : ptr_((T*)0) { - } + scoped_refptr() : ptr_((T*)0) {} scoped_refptr(T* p) : ptr_(p) { if (ptr_) diff --git a/ppapi/native_client/src/shared/ppapi_proxy/array_buffer_proxy_var.h b/ppapi/native_client/src/shared/ppapi_proxy/array_buffer_proxy_var.h index b84914f..04e2f67 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/array_buffer_proxy_var.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/array_buffer_proxy_var.h @@ -34,6 +34,9 @@ class ArrayBufferProxyVar : public ProxyVar { static_cast<ArrayBufferProxyVar*>(proxy_var.get())); } + protected: + virtual ~ArrayBufferProxyVar() {} + private: std::vector<uint8_t> buffer_; }; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio.h index 24048bb..07d5a7d 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -31,7 +31,6 @@ enum PluginAudioState { class PluginAudio : public PluginResource { public: PluginAudio(); - virtual ~PluginAudio(); void StreamCreated(NaClSrpcImcDescType socket, NaClSrpcImcDescType shm, size_t shm_size); void set_state(PluginAudioState state) { state_ = state; } @@ -45,6 +44,10 @@ class PluginAudio : public PluginResource { static void AudioThread(void* self); static const PPB_Audio* GetInterface(); virtual bool InitFromBrowserResource(PP_Resource resource); + + protected: + virtual ~PluginAudio(); + private: PP_Resource resource_; NaClSrpcImcDescType socket_; @@ -56,6 +59,7 @@ class PluginAudio : public PluginResource { bool thread_active_; PPB_Audio_Callback user_callback_; void* user_data_; + IMPLEMENT_RESOURCE(PluginAudio); NACL_DISALLOW_COPY_AND_ASSIGN(PluginAudio); }; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.h index 0943383..5f9af58 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.h @@ -18,6 +18,9 @@ class PluginAudioConfig : public PluginResource { // Returns the 1.0 interface to support backwards-compatibility. static const PPB_AudioConfig_1_0* GetInterface1_0(); + protected: + virtual ~PluginAudioConfig() {} + private: NACL_DISALLOW_COPY_AND_ASSIGN(PluginAudioConfig); }; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_buffer.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_buffer.h index beb1ed8..b0fce42 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_buffer.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_buffer.h @@ -1,6 +1,6 @@ -// Copyright 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can -// be found in the LICENSE file. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_BUFFER_H_ #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_BUFFER_H_ @@ -16,6 +16,9 @@ class PluginBuffer : public PluginResource { public: static const PPB_Buffer_Dev* GetInterface(); + protected: + virtual ~PluginBuffer() {} + private: IMPLEMENT_RESOURCE(PluginBuffer); NACL_DISALLOW_COPY_AND_ASSIGN(PluginBuffer); diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_font.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_font.h index 27e149f..733f23d 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_font.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_font.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,6 +19,9 @@ class PluginFont : public PluginResource { static const PPB_Font_Dev* GetInterface(); + protected: + virtual ~PluginFont() {} + private: NACL_DISALLOW_COPY_AND_ASSIGN(PluginFont); }; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_2d.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_2d.h index 9f03436..accc28e 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_2d.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_2d.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,6 +19,9 @@ class PluginGraphics2D : public PluginResource { static const PPB_Graphics2D* GetInterface(); + protected: + virtual ~PluginGraphics2D() {} + private: IMPLEMENT_RESOURCE(PluginGraphics2D); NACL_DISALLOW_COPY_AND_ASSIGN(PluginGraphics2D); diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h index 7ce19cb..c457e19 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h @@ -29,7 +29,6 @@ namespace ppapi_proxy { class PluginGraphics3D : public PluginResource { public: PluginGraphics3D(); - virtual ~PluginGraphics3D(); static const PPB_Graphics3D* GetInterface(); static const PPB_OpenGLES2* GetOpenGLESInterface(); @@ -66,8 +65,13 @@ class PluginGraphics3D : public PluginResource { return implFromResourceSlow(graphics3d_id); } + protected: + virtual ~PluginGraphics3D(); private: + static gpu::gles2::GLES2Implementation* implFromResourceSlow( + PP_Resource context); + // TODO(nfullagar): make cached_* variables TLS once 64bit NaCl is faster, // and the proxy has support for being called off the main thread. // see: http://code.google.com/p/chromium/issues/detail?id=99217 @@ -81,9 +85,6 @@ class PluginGraphics3D : public PluginResource { scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; PP_Instance instance_id_; - static gpu::gles2::GLES2Implementation* implFromResourceSlow( - PP_Resource context); - IMPLEMENT_RESOURCE(PluginGraphics3D); NACL_DISALLOW_COPY_AND_ASSIGN(PluginGraphics3D); }; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_image_data.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_image_data.cc index 297918d2..2bff66d7 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_image_data.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_image_data.cc @@ -141,14 +141,6 @@ PluginImageData::PluginImageData() memset(&desc_, 0, sizeof(desc_)); } -PluginImageData::~PluginImageData() { - Unmap(); - if (shm_fd_ != -1) { - close(shm_fd_); - shm_fd_ = -1; - } -} - bool PluginImageData::InitFromBrowserResource(PP_Resource resource) { nacl_abi_size_t desc_size = static_cast<nacl_abi_size_t>(sizeof(desc_)); int32_t success = PP_FALSE; @@ -185,4 +177,12 @@ void PluginImageData::Unmap() { } } +PluginImageData::~PluginImageData() { + Unmap(); + if (shm_fd_ != -1) { + close(shm_fd_); + shm_fd_ = -1; + } +} + } // namespace ppapi_proxy diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_image_data.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_image_data.h index 7a274a4..27f8a11c 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_image_data.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_image_data.h @@ -1,6 +1,6 @@ -// Copyright 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can -// be found in the LICENSE file. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_IMAGE_DATA_H_ #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_IMAGE_DATA_H_ @@ -15,7 +15,6 @@ namespace ppapi_proxy { class PluginImageData : public PluginResource { public: PluginImageData(); - virtual ~PluginImageData(); static const PPB_ImageData* GetInterface(); @@ -24,13 +23,18 @@ class PluginImageData : public PluginResource { void Unmap(); const PP_ImageDataDesc& desc() const { return desc_; } + + protected: + virtual ~PluginImageData(); + private: - IMPLEMENT_RESOURCE(PluginImageData); - NACL_DISALLOW_COPY_AND_ASSIGN(PluginImageData); PP_ImageDataDesc desc_; int shm_fd_; int32_t shm_size_; void* addr_; + + IMPLEMENT_RESOURCE(PluginImageData); + NACL_DISALLOW_COPY_AND_ASSIGN(PluginImageData); }; } // namespace ppapi_proxy diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.cc index 40d4bf9..2020909 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.cc @@ -411,11 +411,6 @@ void PluginInputEvent::Init(const InputEventData& input_event_data, character_text_ = character_text; } -PluginInputEvent::~PluginInputEvent() { - // Release the character text. This is a no-op if it's not a string. - PPBVarInterface()->Release(character_text_); -} - PP_InputEvent_Type PluginInputEvent::GetType() const { return input_event_data_.event_type; } @@ -474,4 +469,9 @@ uint32_t PluginInputEvent::GetUsbKeyCode() const { return input_event_data_.usb_key_code; } +PluginInputEvent::~PluginInputEvent() { + // Release the character text. This is a no-op if it's not a string. + PPBVarInterface()->Release(character_text_); +} + } // namespace ppapi_proxy diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.h index 0b5a6e2..0e6f229 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.h @@ -20,7 +20,6 @@ class PluginInputEvent : public PluginResource { // Init the PluginInputEvent resource with the given data. Assumes // character_text has been AddRefed if it's a string, and takes ownership. void Init(const InputEventData& input_event_data, PP_Var character_text); - virtual ~PluginInputEvent(); // PluginResource implementation. virtual bool InitFromBrowserResource(PP_Resource /*resource*/) { @@ -53,12 +52,15 @@ class PluginInputEvent : public PluginResource { PP_Bool SetUsbKeyCode(uint32_t usb_key_code); uint32_t GetUsbKeyCode() const; - private: - IMPLEMENT_RESOURCE(PluginInputEvent); - NACL_DISALLOW_COPY_AND_ASSIGN(PluginInputEvent); + protected: + virtual ~PluginInputEvent(); + private: InputEventData input_event_data_; PP_Var character_text_; // Undefined if this is not a character event. + + IMPLEMENT_RESOURCE(PluginInputEvent); + NACL_DISALLOW_COPY_AND_ASSIGN(PluginInputEvent); }; } // namespace ppapi_proxy diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_view.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_view.cc index 5d840a5..4ad5d5b 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_view.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_view.cc @@ -82,11 +82,7 @@ PP_Bool GetClipRect(PP_Resource resource, PP_Rect* clip) { } // namespace -PluginView::PluginView() { -} - -PluginView::~PluginView() { -} +PluginView::PluginView() {} void PluginView::Init(const ViewData& view_data) { view_data_ = view_data; @@ -104,4 +100,6 @@ const PPB_View* PluginView::GetInterface() { return &view_interface; } +PluginView::~PluginView() {} + } // namespace ppapi_proxy diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_view.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_view.h index 99c5077..b55fc2a 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_view.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_view.h @@ -1,6 +1,6 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can -// be found in the LICENSE file. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_VIEW_H_ #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_VIEW_H_ @@ -17,7 +17,6 @@ class PluginView : public PluginResource { public: PluginView(); void Init(const ViewData& view_data); - virtual ~PluginView(); // PluginResource implementation. virtual bool InitFromBrowserResource(PP_Resource /*resource*/) { @@ -29,10 +28,12 @@ class PluginView : public PluginResource { static const PPB_View* GetInterface(); private: - IMPLEMENT_RESOURCE(PluginView); - NACL_DISALLOW_COPY_AND_ASSIGN(PluginView); + virtual ~PluginView(); ViewData view_data_; + + IMPLEMENT_RESOURCE(PluginView); + NACL_DISALLOW_COPY_AND_ASSIGN(PluginView); }; } // namespace ppapi_proxy diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_resource.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_resource.h index 5222127..b80cf00 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_resource.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_resource.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -29,10 +29,9 @@ namespace ppapi_proxy { FOR_ALL_RESOURCES(DECLARE_RESOURCE_CLASS) #undef DECLARE_RESOURCE_CLASS -class PluginResource : public nacl::RefCounted<PluginResource> { +class PluginResource : public nacl::RefCountedThreadSafe<PluginResource> { public: PluginResource(); - virtual ~PluginResource(); // Returns NULL if the resource is invalid or is a different type. template<typename T> @@ -69,9 +68,13 @@ class PluginResource : public nacl::RefCounted<PluginResource> { template <typename T> T* Cast() { return NULL; } protected: + virtual ~PluginResource(); + virtual bool InitFromBrowserResource(PP_Resource resource) = 0; private: + friend class nacl::RefCountedThreadSafe<PluginResource>; + // Type-specific getters for individual resource types. These will return // NULL if the resource does not match the specified type. Used by the Cast() // function. diff --git a/ppapi/native_client/src/shared/ppapi_proxy/proxy_var.h b/ppapi/native_client/src/shared/ppapi_proxy/proxy_var.h index f5700e6..28c2ae5 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/proxy_var.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/proxy_var.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,7 +19,7 @@ namespace ppapi_proxy { // // Note: this class is intended to be sub-classed to handle specific content // types such as strings, dictionaries, or arrays. -class ProxyVar : public nacl::RefCounted<ProxyVar> { +class ProxyVar : public nacl::RefCountedThreadSafe<ProxyVar> { public: // The type of this cached object. Simple types (int, bool, etc.) are not // cached. @@ -38,15 +38,16 @@ class ProxyVar : public nacl::RefCounted<ProxyVar> { virtual ~ProxyVar() {} private: - friend class nacl::RefCounted<ProxyVar>; + friend class nacl::RefCountedThreadSafe<ProxyVar>; + PP_VarType pp_var_type_; int64_t id_; - ProxyVar(); // Not implemented - do not use. - NACL_DISALLOW_COPY_AND_ASSIGN(ProxyVar); - // A counter for unique ids. static int64_t unique_var_id; + + ProxyVar(); // Not implemented - do not use. + NACL_DISALLOW_COPY_AND_ASSIGN(ProxyVar); }; typedef scoped_refptr<ProxyVar> SharedProxyVar; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/string_proxy_var.h b/ppapi/native_client/src/shared/ppapi_proxy/string_proxy_var.h index 1c1b598..8f90e43 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/string_proxy_var.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/string_proxy_var.h @@ -35,6 +35,9 @@ class StringProxyVar : public ProxyVar { static_cast<StringProxyVar*>(proxy_var.get())); } + protected: + virtual ~StringProxyVar() {} + private: std::string contents_; }; |