summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 00:27:04 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 00:27:04 +0000
commit00d320a6e403c645dc00d47217028aef5f2792a0 (patch)
tree4cb1feea9a8c9819c95d1520db3ebd2dff69a3c6 /ppapi
parent2354c0fa1003d87661d20255211306ae4c9cf622 (diff)
downloadchromium_src-00d320a6e403c645dc00d47217028aef5f2792a0.zip
chromium_src-00d320a6e403c645dc00d47217028aef5f2792a0.tar.gz
chromium_src-00d320a6e403c645dc00d47217028aef5f2792a0.tar.bz2
Make a global enum to differentiate impl & proxy.
Use this in resource constructors and remove all the old weird structs that we used to tell which one to call. This removes some extra code we had to deal with this. Review URL: http://codereview.chromium.org/9391013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121781 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/proxy/mock_resource.cc5
-rw-r--r--ppapi/proxy/ppb_audio_input_proxy.cc4
-rw-r--r--ppapi/proxy/ppb_audio_proxy.cc4
-rw-r--r--ppapi/proxy/ppb_broker_proxy.cc4
-rw-r--r--ppapi/proxy/ppb_buffer_proxy.cc4
-rw-r--r--ppapi/proxy/ppb_file_chooser_proxy.cc3
-rw-r--r--ppapi/proxy/ppb_file_ref_proxy.cc4
-rw-r--r--ppapi/proxy/ppb_file_system_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_flash_menu_proxy.cc4
-rw-r--r--ppapi/proxy/ppb_flash_message_loop_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_flash_net_connector_proxy.cc4
-rw-r--r--ppapi/proxy/ppb_graphics_2d_proxy.cc4
-rw-r--r--ppapi/proxy/ppb_image_data_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_message_loop_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_pdf_proxy.cc5
-rw-r--r--ppapi/proxy/ppb_testing_proxy.cc6
-rw-r--r--ppapi/proxy/ppb_url_loader_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_url_response_info_proxy.cc4
-rw-r--r--ppapi/proxy/ppb_video_capture_proxy.cc4
-rw-r--r--ppapi/proxy/ppp_input_event_proxy.cc6
-rw-r--r--ppapi/proxy/ppp_instance_proxy.cc4
-rw-r--r--ppapi/proxy/ppp_instance_proxy_unittest.cc2
-rw-r--r--ppapi/proxy/resource_creation_proxy.cc20
-rw-r--r--ppapi/shared_impl/ppb_audio_config_shared.cc32
-rw-r--r--ppapi/shared_impl/ppb_audio_config_shared.h18
-rw-r--r--ppapi/shared_impl/ppb_device_ref_shared.cc11
-rw-r--r--ppapi/shared_impl/ppb_device_ref_shared.h10
-rw-r--r--ppapi/shared_impl/ppb_file_io_shared.cc6
-rw-r--r--ppapi/shared_impl/ppb_file_ref_shared.cc25
-rw-r--r--ppapi/shared_impl/ppb_file_ref_shared.h9
-rw-r--r--ppapi/shared_impl/ppb_graphics_3d_shared.cc4
-rw-r--r--ppapi/shared_impl/ppb_input_event_shared.cc13
-rw-r--r--ppapi/shared_impl/ppb_input_event_shared.h12
-rw-r--r--ppapi/shared_impl/ppb_resource_array_shared.cc33
-rw-r--r--ppapi/shared_impl/ppb_resource_array_shared.h14
-rw-r--r--ppapi/shared_impl/ppb_url_request_info_shared.cc12
-rw-r--r--ppapi/shared_impl/ppb_url_request_info_shared.h10
-rw-r--r--ppapi/shared_impl/ppb_video_decoder_shared.cc6
-rw-r--r--ppapi/shared_impl/ppb_view_shared.cc13
-rw-r--r--ppapi/shared_impl/ppb_view_shared.h12
-rw-r--r--ppapi/shared_impl/private/ppb_font_shared.cc47
-rw-r--r--ppapi/shared_impl/private/ppb_font_shared.h24
-rw-r--r--ppapi/shared_impl/private/tcp_socket_private_impl.cc6
-rw-r--r--ppapi/shared_impl/private/udp_socket_private_impl.cc6
-rw-r--r--ppapi/shared_impl/resource.cc31
-rw-r--r--ppapi/shared_impl/resource.h45
-rw-r--r--ppapi/shared_impl/resource_tracker_unittest.cc4
-rw-r--r--ppapi/shared_impl/tracked_callback_unittest.cc7
48 files changed, 201 insertions, 310 deletions
diff --git a/ppapi/proxy/mock_resource.cc b/ppapi/proxy/mock_resource.cc
index 06b2292..9662bad 100644
--- a/ppapi/proxy/mock_resource.cc
+++ b/ppapi/proxy/mock_resource.cc
@@ -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.
@@ -7,7 +7,8 @@
namespace ppapi {
namespace proxy {
-MockResource::MockResource(const HostResource& resource) : Resource(resource) {
+MockResource::MockResource(const HostResource& resource)
+ : Resource(OBJECT_IS_PROXY, resource) {
}
MockResource::~MockResource() {
diff --git a/ppapi/proxy/ppb_audio_input_proxy.cc b/ppapi/proxy/ppb_audio_input_proxy.cc
index 5126f7d..d689192 100644
--- a/ppapi/proxy/ppb_audio_input_proxy.cc
+++ b/ppapi/proxy/ppb_audio_input_proxy.cc
@@ -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.
@@ -65,7 +65,7 @@ AudioInput::AudioInput(const HostResource& audio_input_id,
PP_Resource config_id,
PPB_AudioInput_Callback callback,
void* user_data)
- : Resource(audio_input_id),
+ : Resource(OBJECT_IS_PROXY, audio_input_id),
config_(config_id) {
SetCallback(callback, user_data);
PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(config_);
diff --git a/ppapi/proxy/ppb_audio_proxy.cc b/ppapi/proxy/ppb_audio_proxy.cc
index 8e64c85..fe890ae 100644
--- a/ppapi/proxy/ppb_audio_proxy.cc
+++ b/ppapi/proxy/ppb_audio_proxy.cc
@@ -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.
@@ -64,7 +64,7 @@ Audio::Audio(const HostResource& audio_id,
PP_Resource config_id,
PPB_Audio_Callback callback,
void* user_data)
- : Resource(audio_id),
+ : Resource(OBJECT_IS_PROXY, audio_id),
config_(config_id) {
SetCallback(callback, user_data);
PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(config_);
diff --git a/ppapi/proxy/ppb_broker_proxy.cc b/ppapi/proxy/ppb_broker_proxy.cc
index 18065bb..b9549e0 100644
--- a/ppapi/proxy/ppb_broker_proxy.cc
+++ b/ppapi/proxy/ppb_broker_proxy.cc
@@ -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.
@@ -54,7 +54,7 @@ class Broker : public PPB_Broker_API, public Resource {
};
Broker::Broker(const HostResource& resource)
- : Resource(resource),
+ : Resource(OBJECT_IS_PROXY, resource),
called_connect_(false),
socket_handle_(base::kInvalidPlatformFileValue) {
}
diff --git a/ppapi/proxy/ppb_buffer_proxy.cc b/ppapi/proxy/ppb_buffer_proxy.cc
index c7aba70..03a57d5 100644
--- a/ppapi/proxy/ppb_buffer_proxy.cc
+++ b/ppapi/proxy/ppb_buffer_proxy.cc
@@ -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.
@@ -26,7 +26,7 @@ namespace proxy {
Buffer::Buffer(const HostResource& resource,
const base::SharedMemoryHandle& shm_handle,
uint32_t size)
- : Resource(resource),
+ : Resource(OBJECT_IS_PROXY, resource),
shm_(shm_handle, false),
size_(size),
mapped_data_(NULL),
diff --git a/ppapi/proxy/ppb_file_chooser_proxy.cc b/ppapi/proxy/ppb_file_chooser_proxy.cc
index c3914ef..fa8df55 100644
--- a/ppapi/proxy/ppb_file_chooser_proxy.cc
+++ b/ppapi/proxy/ppb_file_chooser_proxy.cc
@@ -73,7 +73,8 @@ class FileChooser : public Resource,
DISALLOW_COPY_AND_ASSIGN(FileChooser);
};
-FileChooser::FileChooser(const HostResource& resource) : Resource(resource) {
+FileChooser::FileChooser(const HostResource& resource)
+ : Resource(OBJECT_IS_PROXY, resource) {
}
FileChooser::~FileChooser() {
diff --git a/ppapi/proxy/ppb_file_ref_proxy.cc b/ppapi/proxy/ppb_file_ref_proxy.cc
index 7c12ea3..9298eb2 100644
--- a/ppapi/proxy/ppb_file_ref_proxy.cc
+++ b/ppapi/proxy/ppb_file_ref_proxy.cc
@@ -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.
@@ -76,7 +76,7 @@ class FileRef : public PPB_FileRef_Shared {
};
FileRef::FileRef(const PPB_FileRef_CreateInfo& info)
- : PPB_FileRef_Shared(PPB_FileRef_Shared::InitAsProxy(), info),
+ : PPB_FileRef_Shared(OBJECT_IS_PROXY, info),
next_callback_id_(1) {
}
diff --git a/ppapi/proxy/ppb_file_system_proxy.cc b/ppapi/proxy/ppb_file_system_proxy.cc
index 48942ee..993c468 100644
--- a/ppapi/proxy/ppb_file_system_proxy.cc
+++ b/ppapi/proxy/ppb_file_system_proxy.cc
@@ -63,7 +63,7 @@ class FileSystem : public Resource, public PPB_FileSystem_API {
FileSystem::FileSystem(const HostResource& host_resource,
PP_FileSystemType type)
- : Resource(host_resource),
+ : Resource(OBJECT_IS_PROXY, host_resource),
type_(type),
called_open_(false) {
}
diff --git a/ppapi/proxy/ppb_flash_menu_proxy.cc b/ppapi/proxy/ppb_flash_menu_proxy.cc
index d2ef2a3..d7f5f16 100644
--- a/ppapi/proxy/ppb_flash_menu_proxy.cc
+++ b/ppapi/proxy/ppb_flash_menu_proxy.cc
@@ -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.
@@ -43,7 +43,7 @@ class FlashMenu : public PPB_Flash_Menu_API, public Resource {
};
FlashMenu::FlashMenu(const HostResource& resource)
- : Resource(resource),
+ : Resource(OBJECT_IS_PROXY, resource),
selected_id_ptr_(NULL) {
}
diff --git a/ppapi/proxy/ppb_flash_message_loop_proxy.cc b/ppapi/proxy/ppb_flash_message_loop_proxy.cc
index a06e8c8..2124e5a 100644
--- a/ppapi/proxy/ppb_flash_message_loop_proxy.cc
+++ b/ppapi/proxy/ppb_flash_message_loop_proxy.cc
@@ -40,7 +40,7 @@ class FlashMessageLoop : public PPB_Flash_MessageLoop_API, public Resource {
};
FlashMessageLoop::FlashMessageLoop(const HostResource& resource)
- : Resource(resource) {
+ : Resource(OBJECT_IS_PROXY, resource) {
}
FlashMessageLoop::~FlashMessageLoop() {
diff --git a/ppapi/proxy/ppb_flash_net_connector_proxy.cc b/ppapi/proxy/ppb_flash_net_connector_proxy.cc
index feaba6a..0b7ba10 100644
--- a/ppapi/proxy/ppb_flash_net_connector_proxy.cc
+++ b/ppapi/proxy/ppb_flash_net_connector_proxy.cc
@@ -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.
@@ -79,7 +79,7 @@ class FlashNetConnector : public PPB_Flash_NetConnector_API,
};
FlashNetConnector::FlashNetConnector(const HostResource& resource)
- : Resource(resource),
+ : Resource(OBJECT_IS_PROXY, resource),
socket_out_(NULL),
local_addr_out_(NULL),
remote_addr_out_(NULL) {
diff --git a/ppapi/proxy/ppb_graphics_2d_proxy.cc b/ppapi/proxy/ppb_graphics_2d_proxy.cc
index b719a6b..0cbd388 100644
--- a/ppapi/proxy/ppb_graphics_2d_proxy.cc
+++ b/ppapi/proxy/ppb_graphics_2d_proxy.cc
@@ -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.
@@ -68,7 +68,7 @@ class Graphics2D : public Resource, public thunk::PPB_Graphics2D_API {
Graphics2D::Graphics2D(const HostResource& host_resource,
const PP_Size& size,
PP_Bool is_always_opaque)
- : Resource(host_resource),
+ : Resource(OBJECT_IS_PROXY, host_resource),
size_(size),
is_always_opaque_(is_always_opaque) {
}
diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc
index bdbeb3f..b380be2 100644
--- a/ppapi/proxy/ppb_image_data_proxy.cc
+++ b/ppapi/proxy/ppb_image_data_proxy.cc
@@ -29,7 +29,7 @@ namespace proxy {
ImageData::ImageData(const HostResource& resource,
const PP_ImageDataDesc& desc,
ImageHandle handle)
- : Resource(resource),
+ : Resource(OBJECT_IS_PROXY, resource),
desc_(desc) {
#if defined(OS_WIN)
transport_dib_.reset(TransportDIB::CreateWithHandle(handle));
diff --git a/ppapi/proxy/ppb_message_loop_proxy.cc b/ppapi/proxy/ppb_message_loop_proxy.cc
index 927e42f..12a48bb 100644
--- a/ppapi/proxy/ppb_message_loop_proxy.cc
+++ b/ppapi/proxy/ppb_message_loop_proxy.cc
@@ -86,7 +86,7 @@ class MessageLoopResource : public Resource, public PPB_MessageLoop_API {
};
MessageLoopResource::MessageLoopResource(PP_Instance instance)
- : Resource(HostResource::MakeInstanceOnly(instance)),
+ : Resource(OBJECT_IS_PROXY, instance),
nested_invocations_(0),
destroyed_(false),
should_destroy_(false) {
diff --git a/ppapi/proxy/ppb_pdf_proxy.cc b/ppapi/proxy/ppb_pdf_proxy.cc
index 7866e41..aee308f 100644
--- a/ppapi/proxy/ppb_pdf_proxy.cc
+++ b/ppapi/proxy/ppb_pdf_proxy.cc
@@ -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.
@@ -27,7 +27,8 @@ namespace proxy {
class PrivateFontFile : public Resource,
public PPB_PDFFont_API {
public:
- PrivateFontFile(const HostResource& resource) : Resource(resource) {
+ PrivateFontFile(const HostResource& resource)
+ : Resource(OBJECT_IS_PROXY, resource) {
}
virtual ~PrivateFontFile() {}
diff --git a/ppapi/proxy/ppb_testing_proxy.cc b/ppapi/proxy/ppb_testing_proxy.cc
index 32d5215..9c0a14b 100644
--- a/ppapi/proxy/ppb_testing_proxy.cc
+++ b/ppapi/proxy/ppb_testing_proxy.cc
@@ -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.
@@ -189,9 +189,7 @@ void PPB_Testing_Proxy::OnMsgSimulateInputEvent(
PP_Instance instance,
const InputEventData& input_event) {
scoped_refptr<PPB_InputEvent_Shared> input_event_impl(
- new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsProxy(),
- instance,
- input_event));
+ new PPB_InputEvent_Shared(OBJECT_IS_PROXY, instance, input_event));
ppb_testing_impl_->SimulateInputEvent(instance,
input_event_impl->pp_resource());
}
diff --git a/ppapi/proxy/ppb_url_loader_proxy.cc b/ppapi/proxy/ppb_url_loader_proxy.cc
index c896050..5303e42 100644
--- a/ppapi/proxy/ppb_url_loader_proxy.cc
+++ b/ppapi/proxy/ppb_url_loader_proxy.cc
@@ -157,7 +157,7 @@ class URLLoader : public Resource, public PPB_URLLoader_API {
};
URLLoader::URLLoader(const HostResource& resource)
- : Resource(resource),
+ : Resource(OBJECT_IS_PROXY, resource),
bytes_sent_(-1),
total_bytes_to_be_sent_(-1),
bytes_received_(-1),
diff --git a/ppapi/proxy/ppb_url_response_info_proxy.cc b/ppapi/proxy/ppb_url_response_info_proxy.cc
index c9da1ef7..c2f0942 100644
--- a/ppapi/proxy/ppb_url_response_info_proxy.cc
+++ b/ppapi/proxy/ppb_url_response_info_proxy.cc
@@ -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.
@@ -39,7 +39,7 @@ class URLResponseInfo : public Resource, public PPB_URLResponseInfo_API {
};
URLResponseInfo::URLResponseInfo(const HostResource& resource)
- : Resource(resource) {
+ : Resource(OBJECT_IS_PROXY, resource) {
}
URLResponseInfo::~URLResponseInfo() {
diff --git a/ppapi/proxy/ppb_video_capture_proxy.cc b/ppapi/proxy/ppb_video_capture_proxy.cc
index 3df4de8..af39587 100644
--- a/ppapi/proxy/ppb_video_capture_proxy.cc
+++ b/ppapi/proxy/ppb_video_capture_proxy.cc
@@ -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.
@@ -249,7 +249,7 @@ class VideoCapture : public ppapi::thunk::PPB_VideoCapture_API,
};
VideoCapture::VideoCapture(const HostResource& resource)
- : Resource(resource),
+ : Resource(OBJECT_IS_PROXY, resource),
status_(PP_VIDEO_CAPTURE_STATUS_STOPPED) {
}
diff --git a/ppapi/proxy/ppp_input_event_proxy.cc b/ppapi/proxy/ppp_input_event_proxy.cc
index cfce397..be58b3ce 100644
--- a/ppapi/proxy/ppp_input_event_proxy.cc
+++ b/ppapi/proxy/ppp_input_event_proxy.cc
@@ -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.
@@ -97,7 +97,7 @@ bool PPP_InputEvent_Proxy::OnMessageReceived(const IPC::Message& msg) {
void PPP_InputEvent_Proxy::OnMsgHandleInputEvent(PP_Instance instance,
const InputEventData& data) {
scoped_refptr<PPB_InputEvent_Shared> resource(new PPB_InputEvent_Shared(
- PPB_InputEvent_Shared::InitAsProxy(), instance, data));
+ OBJECT_IS_PROXY, instance, data));
ppp_input_event_impl_->HandleInputEvent(instance, resource->pp_resource());
}
@@ -106,7 +106,7 @@ void PPP_InputEvent_Proxy::OnMsgHandleFilteredInputEvent(
const InputEventData& data,
PP_Bool* result) {
scoped_refptr<PPB_InputEvent_Shared> resource(new PPB_InputEvent_Shared(
- PPB_InputEvent_Shared::InitAsProxy(), instance, data));
+ OBJECT_IS_PROXY, instance, data));
*result = ppp_input_event_impl_->HandleInputEvent(instance,
resource->pp_resource());
}
diff --git a/ppapi/proxy/ppp_instance_proxy.cc b/ppapi/proxy/ppp_instance_proxy.cc
index 8ad8ae4..083cc91 100644
--- a/ppapi/proxy/ppp_instance_proxy.cc
+++ b/ppapi/proxy/ppp_instance_proxy.cc
@@ -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.
@@ -239,7 +239,7 @@ void PPP_Instance_Proxy::OnPluginMsgDidChangeView(
ScopedPPResource resource(
ScopedPPResource::PassRef(),
- (new PPB_View_Shared(PPB_View_Shared::InitAsProxy(),
+ (new PPB_View_Shared(OBJECT_IS_PROXY,
instance, new_data))->GetReference());
combined_interface_->DidChangeView(instance, resource,
diff --git a/ppapi/proxy/ppp_instance_proxy_unittest.cc b/ppapi/proxy/ppp_instance_proxy_unittest.cc
index 6e53023..199cc51 100644
--- a/ppapi/proxy/ppp_instance_proxy_unittest.cc
+++ b/ppapi/proxy/ppp_instance_proxy_unittest.cc
@@ -164,7 +164,7 @@ TEST_F(PPP_Instance_ProxyTest, PPPInstance1_0) {
ResetReceived();
ScopedPPResource view_resource(
ScopedPPResource::PassRef(),
- (new PPB_View_Shared(PPB_View_Shared::InitAsImpl(),
+ (new PPB_View_Shared(OBJECT_IS_IMPL,
expected_instance, data))->GetReference());
ppp_instance->DidChangeView(expected_instance, view_resource);
did_change_view_called.Wait();
diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc
index c77e3c6..5d8cd4d 100644
--- a/ppapi/proxy/resource_creation_proxy.cc
+++ b/ppapi/proxy/resource_creation_proxy.cc
@@ -76,8 +76,8 @@ PP_Resource ResourceCreationProxy::CreateAudioConfig(
PP_Instance instance,
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count) {
- return PPB_AudioConfig_Shared::CreateAsProxy(
- instance, sample_rate, sample_frame_count);
+ return PPB_AudioConfig_Shared::Create(
+ OBJECT_IS_PROXY, instance, sample_rate, sample_frame_count);
}
PP_Resource ResourceCreationProxy::CreateAudioTrusted(PP_Instance instance) {
@@ -162,8 +162,8 @@ PP_Resource ResourceCreationProxy::CreateFontObject(
PluginDispatcher::GetForInstance(instance);
if (!dispatcher)
return 0;
- return PPB_Font_Shared::CreateAsProxy(instance, *description,
- dispatcher->preferences());
+ return PPB_Font_Shared::Create(OBJECT_IS_PROXY, instance, *description,
+ dispatcher->preferences());
}
PP_Resource ResourceCreationProxy::CreateGraphics2D(PP_Instance instance,
@@ -205,7 +205,7 @@ PP_Resource ResourceCreationProxy::CreateKeyboardInputEvent(
data.character_text = text_str->value();
}
- return (new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsProxy(),
+ return (new PPB_InputEvent_Shared(OBJECT_IS_PROXY,
instance, data))->GetReference();
}
@@ -234,7 +234,7 @@ PP_Resource ResourceCreationProxy::CreateMouseInputEvent(
data.mouse_click_count = click_count;
data.mouse_movement = *mouse_movement;
- return (new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsProxy(),
+ return (new PPB_InputEvent_Shared(OBJECT_IS_PROXY,
instance, data))->GetReference();
}
@@ -260,7 +260,7 @@ PP_Resource ResourceCreationProxy::CreateResourceArray(
const PP_Resource elements[],
uint32_t size) {
PPB_ResourceArray_Shared* object = new PPB_ResourceArray_Shared(
- PPB_ResourceArray_Shared::InitAsProxy(), instance, elements, size);
+ OBJECT_IS_PROXY, instance, elements, size);
return object->GetReference();
}
@@ -294,8 +294,8 @@ PP_Resource ResourceCreationProxy::CreateURLLoader(PP_Instance instance) {
PP_Resource ResourceCreationProxy::CreateURLRequestInfo(
PP_Instance instance,
const PPB_URLRequestInfo_Data& data) {
- return (new PPB_URLRequestInfo_Shared(
- HostResource::MakeInstanceOnly(instance), data))->GetReference();
+ return (new PPB_URLRequestInfo_Shared(OBJECT_IS_PROXY,
+ instance, data))->GetReference();
}
PP_Resource ResourceCreationProxy::CreateVideoCapture(PP_Instance instance) {
@@ -337,7 +337,7 @@ PP_Resource ResourceCreationProxy::CreateWheelInputEvent(
data.wheel_ticks = *wheel_ticks;
data.wheel_scroll_by_page = PP_ToBool(scroll_by_page);
- return (new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsProxy(),
+ return (new PPB_InputEvent_Shared(OBJECT_IS_PROXY,
instance, data))->GetReference();
}
diff --git a/ppapi/shared_impl/ppb_audio_config_shared.cc b/ppapi/shared_impl/ppb_audio_config_shared.cc
index 78df9ad..a866d79 100644
--- a/ppapi/shared_impl/ppb_audio_config_shared.cc
+++ b/ppapi/shared_impl/ppb_audio_config_shared.cc
@@ -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.
@@ -6,15 +6,9 @@
namespace ppapi {
-PPB_AudioConfig_Shared::PPB_AudioConfig_Shared(PP_Instance instance)
- : Resource(instance),
- sample_rate_(PP_AUDIOSAMPLERATE_NONE),
- sample_frame_count_(0) {
-}
-
-PPB_AudioConfig_Shared::PPB_AudioConfig_Shared(
- const HostResource& host_resource)
- : Resource(host_resource),
+PPB_AudioConfig_Shared::PPB_AudioConfig_Shared(ResourceObjectType type,
+ PP_Instance instance)
+ : Resource(type, instance),
sample_rate_(PP_AUDIOSAMPLERATE_NONE),
sample_frame_count_(0) {
}
@@ -22,25 +16,13 @@ PPB_AudioConfig_Shared::PPB_AudioConfig_Shared(
PPB_AudioConfig_Shared::~PPB_AudioConfig_Shared() {
}
-// static
-PP_Resource PPB_AudioConfig_Shared::CreateAsImpl(
+PP_Resource PPB_AudioConfig_Shared::Create(
+ ResourceObjectType type,
PP_Instance instance,
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count) {
scoped_refptr<PPB_AudioConfig_Shared> object(
- new PPB_AudioConfig_Shared(instance));
- if (!object->Init(sample_rate, sample_frame_count))
- return 0;
- return object->GetReference();
-}
-
-// static
-PP_Resource PPB_AudioConfig_Shared::CreateAsProxy(
- PP_Instance instance,
- PP_AudioSampleRate sample_rate,
- uint32_t sample_frame_count) {
- scoped_refptr<PPB_AudioConfig_Shared> object(new PPB_AudioConfig_Shared(
- HostResource::MakeInstanceOnly(instance)));
+ new PPB_AudioConfig_Shared(type, instance));
if (!object->Init(sample_rate, sample_frame_count))
return 0;
return object->GetReference();
diff --git a/ppapi/shared_impl/ppb_audio_config_shared.h b/ppapi/shared_impl/ppb_audio_config_shared.h
index 65e3b2b..410a32a8b 100644
--- a/ppapi/shared_impl/ppb_audio_config_shared.h
+++ b/ppapi/shared_impl/ppb_audio_config_shared.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.
@@ -18,12 +18,10 @@ class PPAPI_SHARED_EXPORT PPB_AudioConfig_Shared
public:
virtual ~PPB_AudioConfig_Shared();
- static PP_Resource CreateAsImpl(PP_Instance instance,
- PP_AudioSampleRate sample_rate,
- uint32_t sample_frame_count);
- static PP_Resource CreateAsProxy(PP_Instance instance,
- PP_AudioSampleRate sample_rate,
- uint32_t sample_frame_count);
+ static PP_Resource Create(ResourceObjectType type,
+ PP_Instance instance,
+ PP_AudioSampleRate sample_rate,
+ uint32_t sample_frame_count);
// Resource overrides.
virtual thunk::PPB_AudioConfig_API* AsPPB_AudioConfig_API() OVERRIDE;
@@ -34,10 +32,8 @@ class PPAPI_SHARED_EXPORT PPB_AudioConfig_Shared
private:
// You must call Init before using this object.
- // Construct as implementation.
- explicit PPB_AudioConfig_Shared(PP_Instance instance);
- // Construct as proxy.
- explicit PPB_AudioConfig_Shared(const HostResource& host_resource);
+ explicit PPB_AudioConfig_Shared(ResourceObjectType type,
+ PP_Instance instance);
// Returns false if the arguments are invalid, the object should not be
// used in this case.
diff --git a/ppapi/shared_impl/ppb_device_ref_shared.cc b/ppapi/shared_impl/ppb_device_ref_shared.cc
index edd01f2..43f758f 100644
--- a/ppapi/shared_impl/ppb_device_ref_shared.cc
+++ b/ppapi/shared_impl/ppb_device_ref_shared.cc
@@ -15,17 +15,10 @@ DeviceRefData::DeviceRefData()
: type(PP_DEVICETYPE_DEV_INVALID) {
}
-PPB_DeviceRef_Shared::PPB_DeviceRef_Shared(const InitAsImpl&,
+PPB_DeviceRef_Shared::PPB_DeviceRef_Shared(ResourceObjectType type,
PP_Instance instance,
const DeviceRefData& data)
- : Resource(instance),
- data_(data) {
-}
-
-PPB_DeviceRef_Shared::PPB_DeviceRef_Shared(const InitAsProxy&,
- PP_Instance instance,
- const DeviceRefData& data)
- : Resource(HostResource::MakeInstanceOnly(instance)),
+ : Resource(type, instance),
data_(data) {
}
diff --git a/ppapi/shared_impl/ppb_device_ref_shared.h b/ppapi/shared_impl/ppb_device_ref_shared.h
index bbdda72..908cace 100644
--- a/ppapi/shared_impl/ppb_device_ref_shared.h
+++ b/ppapi/shared_impl/ppb_device_ref_shared.h
@@ -29,15 +29,7 @@ class PPAPI_SHARED_EXPORT PPB_DeviceRef_Shared
: public Resource,
public thunk::PPB_DeviceRef_API {
public:
- struct InitAsImpl {};
- struct InitAsProxy {};
-
- // The dummy arguments control which version of Resource's constructor is
- // called for this base class.
- PPB_DeviceRef_Shared(const InitAsImpl&,
- PP_Instance instance,
- const DeviceRefData& data);
- PPB_DeviceRef_Shared(const InitAsProxy&,
+ PPB_DeviceRef_Shared(ResourceObjectType type,
PP_Instance instance,
const DeviceRefData& data);
diff --git a/ppapi/shared_impl/ppb_file_io_shared.cc b/ppapi/shared_impl/ppb_file_io_shared.cc
index 7eeab92..63945b5 100644
--- a/ppapi/shared_impl/ppb_file_io_shared.cc
+++ b/ppapi/shared_impl/ppb_file_io_shared.cc
@@ -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.
@@ -36,14 +36,14 @@ PPB_FileIO_Shared::CallbackEntry::~CallbackEntry() {
}
PPB_FileIO_Shared::PPB_FileIO_Shared(PP_Instance instance)
- : Resource(instance),
+ : Resource(OBJECT_IS_IMPL, instance),
file_system_type_(PP_FILESYSTEMTYPE_INVALID),
file_open_(false),
pending_op_(OPERATION_NONE) {
}
PPB_FileIO_Shared::PPB_FileIO_Shared(const HostResource& host_resource)
- : Resource(host_resource),
+ : Resource(OBJECT_IS_PROXY, host_resource),
file_system_type_(PP_FILESYSTEMTYPE_INVALID),
file_open_(false),
pending_op_(OPERATION_NONE) {
diff --git a/ppapi/shared_impl/ppb_file_ref_shared.cc b/ppapi/shared_impl/ppb_file_ref_shared.cc
index 64268b3..b273364 100644
--- a/ppapi/shared_impl/ppb_file_ref_shared.cc
+++ b/ppapi/shared_impl/ppb_file_ref_shared.cc
@@ -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.
@@ -9,23 +9,16 @@
namespace ppapi {
-PPB_FileRef_Shared::PPB_FileRef_Shared(const InitAsImpl&,
+PPB_FileRef_Shared::PPB_FileRef_Shared(ResourceObjectType type,
const PPB_FileRef_CreateInfo& info)
- : Resource(info.resource.instance()),
- create_info_(info) {
- // Should not have been passed a host resource for the trusted constructor.
- DCHECK(info.resource.is_null());
-
- // Resource's constructor assigned a PP_Resource, so we can fill out our
- // host resource now.
- create_info_.resource = host_resource();
- DCHECK(!create_info_.resource.is_null());
-}
-
-PPB_FileRef_Shared::PPB_FileRef_Shared(const InitAsProxy&,
- const PPB_FileRef_CreateInfo& info)
- : Resource(info.resource),
+ : Resource(type, info.resource),
create_info_(info) {
+ if (type == OBJECT_IS_IMPL) {
+ // Resource's constructor assigned a PP_Resource, so we can fill out our
+ // host resource now.
+ create_info_.resource = host_resource();
+ DCHECK(!create_info_.resource.is_null());
+ }
}
PPB_FileRef_Shared::~PPB_FileRef_Shared() {
diff --git a/ppapi/shared_impl/ppb_file_ref_shared.h b/ppapi/shared_impl/ppb_file_ref_shared.h
index 3d0a9f8..5decd7f 100644
--- a/ppapi/shared_impl/ppb_file_ref_shared.h
+++ b/ppapi/shared_impl/ppb_file_ref_shared.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.
@@ -33,11 +33,8 @@ class PPAPI_SHARED_EXPORT PPB_FileRef_Shared
: public Resource,
public thunk::PPB_FileRef_API {
public:
- struct InitAsImpl {};
- struct InitAsProxy {};
-
- PPB_FileRef_Shared(const InitAsImpl&, const PPB_FileRef_CreateInfo& info);
- PPB_FileRef_Shared(const InitAsProxy&, const PPB_FileRef_CreateInfo& info);
+ PPB_FileRef_Shared(ResourceObjectType type,
+ const PPB_FileRef_CreateInfo& info);
virtual ~PPB_FileRef_Shared();
// Resource overrides.
diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.cc b/ppapi/shared_impl/ppb_graphics_3d_shared.cc
index e21b77e..13184eb 100644
--- a/ppapi/shared_impl/ppb_graphics_3d_shared.cc
+++ b/ppapi/shared_impl/ppb_graphics_3d_shared.cc
@@ -13,11 +13,11 @@
namespace ppapi {
PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(PP_Instance instance)
- : Resource(instance) {
+ : Resource(OBJECT_IS_IMPL, instance) {
}
PPB_Graphics3D_Shared::PPB_Graphics3D_Shared(const HostResource& host_resource)
- : Resource(host_resource) {
+ : Resource(OBJECT_IS_PROXY, host_resource) {
}
PPB_Graphics3D_Shared::~PPB_Graphics3D_Shared() {
diff --git a/ppapi/shared_impl/ppb_input_event_shared.cc b/ppapi/shared_impl/ppb_input_event_shared.cc
index 2cffa0f..4f1a4d0 100644
--- a/ppapi/shared_impl/ppb_input_event_shared.cc
+++ b/ppapi/shared_impl/ppb_input_event_shared.cc
@@ -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.
@@ -32,17 +32,10 @@ InputEventData::InputEventData()
InputEventData::~InputEventData() {
}
-PPB_InputEvent_Shared::PPB_InputEvent_Shared(const InitAsImpl&,
+PPB_InputEvent_Shared::PPB_InputEvent_Shared(ResourceObjectType type,
PP_Instance instance,
const InputEventData& data)
- : Resource(instance),
- data_(data) {
-}
-
-PPB_InputEvent_Shared::PPB_InputEvent_Shared(const InitAsProxy&,
- PP_Instance instance,
- const InputEventData& data)
- : Resource(HostResource::MakeInstanceOnly(instance)),
+ : Resource(type, instance),
data_(data) {
}
diff --git a/ppapi/shared_impl/ppb_input_event_shared.h b/ppapi/shared_impl/ppb_input_event_shared.h
index 1a29750..c9ab572 100644
--- a/ppapi/shared_impl/ppb_input_event_shared.h
+++ b/ppapi/shared_impl/ppb_input_event_shared.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.
@@ -55,15 +55,7 @@ class PPAPI_SHARED_EXPORT PPB_InputEvent_Shared
: public Resource,
public thunk::PPB_InputEvent_API {
public:
- struct InitAsImpl {};
- struct InitAsProxy {};
-
- // The dummy arguments control which version of Resource's constructor is
- // called for this base class.
- PPB_InputEvent_Shared(const InitAsImpl&,
- PP_Instance instance,
- const InputEventData& data);
- PPB_InputEvent_Shared(const InitAsProxy&,
+ PPB_InputEvent_Shared(ResourceObjectType type,
PP_Instance instance,
const InputEventData& data);
diff --git a/ppapi/shared_impl/ppb_resource_array_shared.cc b/ppapi/shared_impl/ppb_resource_array_shared.cc
index 9949fd5..f7353f1 100644
--- a/ppapi/shared_impl/ppb_resource_array_shared.cc
+++ b/ppapi/shared_impl/ppb_resource_array_shared.cc
@@ -12,20 +12,20 @@ using ppapi::thunk::PPB_ResourceArray_API;
namespace ppapi {
-PPB_ResourceArray_Shared::PPB_ResourceArray_Shared(const InitAsImpl&,
+PPB_ResourceArray_Shared::PPB_ResourceArray_Shared(ResourceObjectType type,
PP_Instance instance,
const PP_Resource elements[],
uint32_t size)
- : Resource(instance) {
- Initialize(elements, size);
-}
+ : Resource(type, instance) {
+ DCHECK(resources_.empty());
-PPB_ResourceArray_Shared::PPB_ResourceArray_Shared(const InitAsProxy&,
- PP_Instance instance,
- const PP_Resource elements[],
- uint32_t size)
- : Resource(HostResource::MakeInstanceOnly(instance)) {
- Initialize(elements, size);
+ resources_.reserve(size);
+ for (uint32_t index = 0; index < size; ++index) {
+ PP_Resource element = elements[index];
+ if (element)
+ PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(element);
+ resources_.push_back(element);
+ }
}
PPB_ResourceArray_Shared::~PPB_ResourceArray_Shared() {
@@ -48,17 +48,4 @@ PP_Resource PPB_ResourceArray_Shared::GetAt(uint32_t index) {
return index < resources_.size() ? resources_[index] : 0;
}
-void PPB_ResourceArray_Shared::Initialize(const PP_Resource elements[],
- uint32_t size) {
- DCHECK(resources_.empty());
-
- resources_.reserve(size);
- for (uint32_t index = 0; index < size; ++index) {
- PP_Resource element = elements[index];
- if (element)
- PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(element);
- resources_.push_back(element);
- }
-}
-
} // namespace ppapi
diff --git a/ppapi/shared_impl/ppb_resource_array_shared.h b/ppapi/shared_impl/ppb_resource_array_shared.h
index 55342e0..e3d6750 100644
--- a/ppapi/shared_impl/ppb_resource_array_shared.h
+++ b/ppapi/shared_impl/ppb_resource_array_shared.h
@@ -18,20 +18,10 @@ class PPAPI_SHARED_EXPORT PPB_ResourceArray_Shared
: public Resource,
public thunk::PPB_ResourceArray_API {
public:
- struct InitAsImpl {};
- struct InitAsProxy {};
-
- // The dummy arguments control which version of Resource's constructor is
- // called for this base class.
- PPB_ResourceArray_Shared(const InitAsImpl&,
- PP_Instance instance,
- const PP_Resource elements[],
- uint32_t size);
- PPB_ResourceArray_Shared(const InitAsProxy&,
+ PPB_ResourceArray_Shared(ResourceObjectType type,
PP_Instance instance,
const PP_Resource elements[],
uint32_t size);
-
virtual ~PPB_ResourceArray_Shared();
// Resource overrides.
@@ -42,8 +32,6 @@ class PPAPI_SHARED_EXPORT PPB_ResourceArray_Shared
virtual PP_Resource GetAt(uint32_t index) OVERRIDE;
private:
- void Initialize(const PP_Resource elements[], uint32_t size);
-
std::vector<PP_Resource> resources_;
DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_ResourceArray_Shared);
diff --git a/ppapi/shared_impl/ppb_url_request_info_shared.cc b/ppapi/shared_impl/ppb_url_request_info_shared.cc
index f582eac..d7a3ea2 100644
--- a/ppapi/shared_impl/ppb_url_request_info_shared.cc
+++ b/ppapi/shared_impl/ppb_url_request_info_shared.cc
@@ -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.
@@ -71,16 +71,10 @@ PPB_URLRequestInfo_Data::~PPB_URLRequestInfo_Data() {
}
PPB_URLRequestInfo_Shared::PPB_URLRequestInfo_Shared(
+ ResourceObjectType type,
PP_Instance instance,
const PPB_URLRequestInfo_Data& data)
- : Resource(instance),
- data_(data) {
-}
-
-PPB_URLRequestInfo_Shared::PPB_URLRequestInfo_Shared(
- const HostResource& host_resource,
- const PPB_URLRequestInfo_Data& data)
- : Resource(host_resource),
+ : Resource(type, instance),
data_(data) {
}
diff --git a/ppapi/shared_impl/ppb_url_request_info_shared.h b/ppapi/shared_impl/ppb_url_request_info_shared.h
index c07b9c9..7876d23 100644
--- a/ppapi/shared_impl/ppb_url_request_info_shared.h
+++ b/ppapi/shared_impl/ppb_url_request_info_shared.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.
@@ -90,11 +90,9 @@ class PPAPI_SHARED_EXPORT PPB_URLRequestInfo_Shared
: public ::ppapi::Resource,
public ::ppapi::thunk::PPB_URLRequestInfo_API {
public:
- // This constructor initializes the object as a proxy object with the given
- // host resource.
- PPB_URLRequestInfo_Shared(const HostResource& host_resource,
- const PPB_URLRequestInfo_Data& data);
-
+ PPB_URLRequestInfo_Shared(ResourceObjectType type,
+ PP_Instance instance,
+ const PPB_URLRequestInfo_Data& data);
~PPB_URLRequestInfo_Shared();
// Resource overrides.
diff --git a/ppapi/shared_impl/ppb_video_decoder_shared.cc b/ppapi/shared_impl/ppb_video_decoder_shared.cc
index 39a4088..b61567b 100644
--- a/ppapi/shared_impl/ppb_video_decoder_shared.cc
+++ b/ppapi/shared_impl/ppb_video_decoder_shared.cc
@@ -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.
@@ -13,14 +13,14 @@
namespace ppapi {
PPB_VideoDecoder_Shared::PPB_VideoDecoder_Shared(PP_Instance instance)
- : Resource(instance),
+ : Resource(OBJECT_IS_IMPL, instance),
graphics_context_(0),
gles2_impl_(NULL) {
}
PPB_VideoDecoder_Shared::PPB_VideoDecoder_Shared(
const HostResource& host_resource)
- : Resource(host_resource),
+ : Resource(OBJECT_IS_PROXY, host_resource),
graphics_context_(0),
gles2_impl_(NULL) {
}
diff --git a/ppapi/shared_impl/ppb_view_shared.cc b/ppapi/shared_impl/ppb_view_shared.cc
index 8b2f339..1e024a6 100644
--- a/ppapi/shared_impl/ppb_view_shared.cc
+++ b/ppapi/shared_impl/ppb_view_shared.cc
@@ -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.
@@ -27,17 +27,10 @@ bool ViewData::Equals(const ViewData& other) const {
clip_rect.size.height == other.clip_rect.size.height;
}
-PPB_View_Shared::PPB_View_Shared(const InitAsImpl&,
+PPB_View_Shared::PPB_View_Shared(ResourceObjectType type,
PP_Instance instance,
const ViewData& data)
- : Resource(instance),
- data_(data) {
-}
-
-PPB_View_Shared::PPB_View_Shared(const InitAsProxy&,
- PP_Instance instance,
- const ViewData& data)
- : Resource(HostResource::MakeInstanceOnly(instance)),
+ : Resource(type, instance),
data_(data) {
}
diff --git a/ppapi/shared_impl/ppb_view_shared.h b/ppapi/shared_impl/ppb_view_shared.h
index ecfb1a0..59b8e72 100644
--- a/ppapi/shared_impl/ppb_view_shared.h
+++ b/ppapi/shared_impl/ppb_view_shared.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,15 +31,7 @@ class PPAPI_SHARED_EXPORT PPB_View_Shared
: public Resource,
public thunk::PPB_View_API {
public:
- struct InitAsImpl {};
- struct InitAsProxy {};
-
- // The dummy arguments control which version of Resource's constructor is
- // called for this base class.
- PPB_View_Shared(const InitAsImpl&,
- PP_Instance instance,
- const ViewData& data);
- PPB_View_Shared(const InitAsProxy&,
+ PPB_View_Shared(ResourceObjectType type,
PP_Instance instance,
const ViewData& data);
virtual ~PPB_View_Shared();
diff --git a/ppapi/shared_impl/private/ppb_font_shared.cc b/ppapi/shared_impl/private/ppb_font_shared.cc
index 3b4f04b..3918088 100644
--- a/ppapi/shared_impl/private/ppb_font_shared.cc
+++ b/ppapi/shared_impl/private/ppb_font_shared.cc
@@ -302,41 +302,24 @@ bool PPB_Font_Shared::IsPPFontDescriptionValid(
}
// static
-PP_Resource PPB_Font_Shared::CreateAsImpl(
- PP_Instance instance,
- const PP_FontDescription_Dev& description,
- const ::ppapi::Preferences& prefs) {
+PP_Resource PPB_Font_Shared::Create(ResourceObjectType type,
+ PP_Instance instance,
+ const PP_FontDescription_Dev& description,
+ const ::ppapi::Preferences& prefs) {
if (!::ppapi::PPB_Font_Shared::IsPPFontDescriptionValid(description))
return 0;
- return (new PPB_Font_Shared(InitAsImpl(), instance, description,
+ return (new PPB_Font_Shared(type, instance, description,
prefs))->GetReference();
}
-// static
-PP_Resource PPB_Font_Shared::CreateAsProxy(
- PP_Instance instance,
- const PP_FontDescription_Dev& description,
- const ::ppapi::Preferences& prefs) {
- if (!::ppapi::PPB_Font_Shared::IsPPFontDescriptionValid(description))
- return 0;
- return (new PPB_Font_Shared(InitAsProxy(), instance, description,
- prefs))->GetReference();
-}
-
-PPB_Font_Shared::PPB_Font_Shared(const InitAsImpl&,
- PP_Instance pp_instance,
- const PP_FontDescription_Dev& desc,
- const ::ppapi::Preferences& prefs)
- : Resource(pp_instance) {
- Initialize(desc, prefs);
-}
-
-PPB_Font_Shared::PPB_Font_Shared(const InitAsProxy&,
- PP_Instance pp_instance,
+PPB_Font_Shared::PPB_Font_Shared(ResourceObjectType type,
+ PP_Instance instance,
const PP_FontDescription_Dev& desc,
const ::ppapi::Preferences& prefs)
- : Resource(HostResource::MakeInstanceOnly(pp_instance)) {
- Initialize(desc, prefs);
+ : Resource(type, instance) {
+ StringVar* face_name = StringVar::FromPPVar(desc.face);
+ font_impl_.reset(new FontImpl(
+ desc, face_name ? face_name->value() : std::string(), prefs));
}
PPB_Font_Shared::~PPB_Font_Shared() {
@@ -425,13 +408,5 @@ int32_t PPB_Font_Shared::PixelOffsetForCharacter(const PP_TextRun_Dev* text,
return result;
}
-void PPB_Font_Shared::Initialize(const PP_FontDescription_Dev& desc,
- const ::ppapi::Preferences& prefs) {
- StringVar* face_name = StringVar::FromPPVar(desc.face);
-
- font_impl_.reset(new FontImpl(
- desc, face_name ? face_name->value() : std::string(), prefs));
-}
-
} // namespace ppapi
diff --git a/ppapi/shared_impl/private/ppb_font_shared.h b/ppapi/shared_impl/private/ppb_font_shared.h
index ec34215..8e5bebb 100644
--- a/ppapi/shared_impl/private/ppb_font_shared.h
+++ b/ppapi/shared_impl/private/ppb_font_shared.h
@@ -33,12 +33,10 @@ class PPAPI_SHARED_EXPORT PPB_Font_Shared
virtual ~PPB_Font_Shared();
- static PP_Resource CreateAsImpl(PP_Instance instance,
- const PP_FontDescription_Dev& description,
- const ::ppapi::Preferences& prefs);
- static PP_Resource CreateAsProxy(PP_Instance instance,
- const PP_FontDescription_Dev& description,
- const ::ppapi::Preferences& prefs);
+ static PP_Resource Create(ResourceObjectType type,
+ PP_Instance instance,
+ const PP_FontDescription_Dev& description,
+ const ::ppapi::Preferences& prefs);
// Resource.
virtual ::ppapi::thunk::PPB_Font_API* AsPPB_Font_API() OVERRIDE;
@@ -59,23 +57,11 @@ class PPAPI_SHARED_EXPORT PPB_Font_Shared
uint32_t char_offset) OVERRIDE;
private:
- struct InitAsImpl {};
- struct InitAsProxy {};
-
- // The dummy arguments control which version of Resource's constructor is
- // called for this base class.
- PPB_Font_Shared(const InitAsImpl&,
- PP_Instance instance,
- const PP_FontDescription_Dev& desc,
- const ::ppapi::Preferences& prefs);
- PPB_Font_Shared(const InitAsProxy&,
+ PPB_Font_Shared(ResourceObjectType type,
PP_Instance instance,
const PP_FontDescription_Dev& desc,
const ::ppapi::Preferences& prefs);
- void Initialize(const PP_FontDescription_Dev& desc,
- const ::ppapi::Preferences& prefs);
-
scoped_ptr< ::ppapi::WebKitForwarding::Font> font_impl_;
DISALLOW_COPY_AND_ASSIGN(PPB_Font_Shared);
diff --git a/ppapi/shared_impl/private/tcp_socket_private_impl.cc b/ppapi/shared_impl/private/tcp_socket_private_impl.cc
index a268801..de99e20 100644
--- a/ppapi/shared_impl/private/tcp_socket_private_impl.cc
+++ b/ppapi/shared_impl/private/tcp_socket_private_impl.cc
@@ -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.
@@ -22,13 +22,13 @@ const int32_t TCPSocketPrivateImpl::kMaxWriteSize = 1024 * 1024;
TCPSocketPrivateImpl::TCPSocketPrivateImpl(PP_Instance instance,
uint32 socket_id)
- : Resource(instance) {
+ : Resource(OBJECT_IS_IMPL, instance) {
Init(socket_id);
}
TCPSocketPrivateImpl::TCPSocketPrivateImpl(const HostResource& resource,
uint32 socket_id)
- : Resource(resource) {
+ : Resource(OBJECT_IS_PROXY, resource) {
Init(socket_id);
}
diff --git a/ppapi/shared_impl/private/udp_socket_private_impl.cc b/ppapi/shared_impl/private/udp_socket_private_impl.cc
index 23f125d..d596b02 100644
--- a/ppapi/shared_impl/private/udp_socket_private_impl.cc
+++ b/ppapi/shared_impl/private/udp_socket_private_impl.cc
@@ -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.
@@ -22,13 +22,13 @@ const int32_t UDPSocketPrivateImpl::kMaxWriteSize = 1024 * 1024;
UDPSocketPrivateImpl::UDPSocketPrivateImpl(const HostResource& resource,
uint32 socket_id)
- : Resource(resource) {
+ : Resource(OBJECT_IS_PROXY, resource) {
Init(socket_id);
}
UDPSocketPrivateImpl::UDPSocketPrivateImpl(PP_Instance instance,
uint32 socket_id)
- : Resource(instance) {
+ : Resource(OBJECT_IS_IMPL, instance) {
Init(socket_id);
}
diff --git a/ppapi/shared_impl/resource.cc b/ppapi/shared_impl/resource.cc
index 35add15..b8dd315 100644
--- a/ppapi/shared_impl/resource.cc
+++ b/ppapi/shared_impl/resource.cc
@@ -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.
@@ -10,23 +10,34 @@
namespace ppapi {
-Resource::Resource(PP_Instance instance) {
+Resource::Resource(ResourceObjectType type, PP_Instance instance)
+ : host_resource_(HostResource::MakeInstanceOnly(instance)) {
// The instance should always be valid (nonzero).
DCHECK(instance);
- // For the in-process case, the host resource and resource are the same.
- //
- // AddResource needs our instance() getter to work, and that goes through
- // the host resource, so we need to fill that first even though we don't
- // have a resource ID yet, then fill the resource in later.
- host_resource_ = HostResource::MakeInstanceOnly(instance);
pp_resource_ = PpapiGlobals::Get()->GetResourceTracker()->AddResource(this);
- host_resource_.SetHostResource(instance, pp_resource_);
+ if (type == OBJECT_IS_IMPL) {
+ // For the in-process case, the host resource and resource are the same.
+ //
+ // Note that we need to have set the instance above (in the initializer
+ // list) since AddResource needs our instance() getter to work, and that
+ // goes through the host resource. When we get the "real" resource ID,
+ // we re-set the host_resource.
+ host_resource_.SetHostResource(instance, pp_resource_);
+ }
}
-Resource::Resource(const HostResource& host_resource)
+Resource::Resource(ResourceObjectType type, const HostResource& host_resource)
: host_resource_(host_resource) {
pp_resource_ = PpapiGlobals::Get()->GetResourceTracker()->AddResource(this);
+ if (type == OBJECT_IS_IMPL) {
+ // When using this constructor for the implementation, the resource ID
+ // should not have been passed in.
+ DCHECK(host_resource_.host_resource() == 0);
+
+ // See previous constructor.
+ host_resource_.SetHostResource(host_resource.instance(), pp_resource_);
+ }
}
Resource::~Resource() {
diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h
index 4b26d28..b0876a2 100644
--- a/ppapi/shared_impl/resource.h
+++ b/ppapi/shared_impl/resource.h
@@ -69,17 +69,44 @@ FOR_ALL_PPAPI_RESOURCE_APIS(DECLARE_RESOURCE_CLASS)
#undef DECLARE_RESOURCE_CLASS
} // namespace thunk
+// Resources have slightly different registration behaviors when the're an
+// in-process ("impl") resource in the host (renderer) process, or when they're
+// a proxied resource in the plugin process. This enum differentiates those
+// cases.
+enum ResourceObjectType {
+ OBJECT_IS_IMPL,
+ OBJECT_IS_PROXY
+};
+
class PPAPI_SHARED_EXPORT Resource : public base::RefCounted<Resource> {
public:
- // For constructing non-proxied objects. This just takes the associated
- // instance, and generates a new resource ID. The host resource will be the
- // same as the newly-generated resource ID.
- explicit Resource(PP_Instance instance);
-
- // For constructing proxied objects. This takes the resource generated in
- // the host side, stores it, and allocates a "local" resource ID for use in
- // the current process.
- explicit Resource(const HostResource& host_resource);
+ // Constructor for impl and non-proxied, instance-only objects.
+ //
+ // For constructing "impl" (non-proxied) objects, this just takes the
+ // associated instance, and generates a new resource ID. The host resource
+ // will be the same as the newly-generated resource ID. For all objects in
+ // the renderer (host) process, you'll use this constructor and call it with
+ // OBJECT_IS_IMPL.
+ //
+ // For proxied objects, this will create an "instance-only" object which
+ // lives only in the plugin and doesn't have a corresponding object in the
+ // host. If you have a host resource ID, use the constructor below which
+ // takes that HostResource value.
+ explicit Resource(ResourceObjectType type, PP_Instance instance);
+
+ // For constructing given a host resource.
+ //
+ // For OBJECT_IS_PROXY objects, this takes the resource generated in the host
+ // side, stores it, and allocates a "local" resource ID for use in the
+ // current process.
+ //
+ // For OBJECT_IS_IMPL, the host resource ID must be 0, since there should be
+ // no host resource generated (impl objects should generate their own). The
+ // reason for supporting this constructor at all for the IMPL case is that
+ // some shared objects use a host resource for both modes to keep things the
+ // same.
+ explicit Resource(ResourceObjectType type,
+ const HostResource& host_resource);
virtual ~Resource();
diff --git a/ppapi/shared_impl/resource_tracker_unittest.cc b/ppapi/shared_impl/resource_tracker_unittest.cc
index a77dc78..26d02c3 100644
--- a/ppapi/shared_impl/resource_tracker_unittest.cc
+++ b/ppapi/shared_impl/resource_tracker_unittest.cc
@@ -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 @@ int instance_was_deleted_count = 0;
class MyMockResource : public Resource {
public:
- MyMockResource(PP_Instance instance) : Resource(instance) {
+ MyMockResource(PP_Instance instance) : Resource(OBJECT_IS_IMPL, instance) {
mock_resource_alive_count++;
}
virtual ~MyMockResource() {
diff --git a/ppapi/shared_impl/tracked_callback_unittest.cc b/ppapi/shared_impl/tracked_callback_unittest.cc
index 62da396..ca4d3b1 100644
--- a/ppapi/shared_impl/tracked_callback_unittest.cc
+++ b/ppapi/shared_impl/tracked_callback_unittest.cc
@@ -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.
@@ -80,7 +80,7 @@ class CallbackShutdownTest : public TrackedCallbackTest {
// Tests that callbacks are properly aborted on module shutdown.
TEST_F(CallbackShutdownTest, AbortOnShutdown) {
- scoped_refptr<Resource> resource(new Resource(pp_instance()));
+ scoped_refptr<Resource> resource(new Resource(OBJECT_IS_IMPL, pp_instance()));
// Set up case (1) (see above).
EXPECT_EQ(0U, info_did_run().run_count);
@@ -133,7 +133,8 @@ class CallbackResourceTest : public TrackedCallbackTest {
class CallbackMockResource : public Resource {
public:
- CallbackMockResource(PP_Instance instance) : Resource(instance) {}
+ CallbackMockResource(PP_Instance instance)
+ : Resource(OBJECT_IS_IMPL, instance) {}
~CallbackMockResource() {}
PP_Resource SetupForTest() {