diff options
author | apatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 18:13:38 +0000 |
---|---|---|
committer | apatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 18:13:38 +0000 |
commit | 3b39a1fd53e8d173965431de9709c670c83459f8 (patch) | |
tree | 21e6a730049d7cfc59f4307eb53caadb22126a71 /o3d | |
parent | 5a05dd8983fc0da2adf161509cfdb760592b7fe1 (diff) | |
download | chromium_src-3b39a1fd53e8d173965431de9709c670c83459f8.zip chromium_src-3b39a1fd53e8d173965431de9709c670c83459f8.tar.gz chromium_src-3b39a1fd53e8d173965431de9709c670c83459f8.tar.bz2 |
Fixes for accidental early commit reviewed at URL below.
http://codereview.chromium.org/177060
TEST=none
BUG=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25203 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r-- | o3d/gpu_plugin/gpu_plugin_object.cc | 4 | ||||
-rw-r--r-- | o3d/gpu_plugin/gpu_plugin_object_factory.h | 28 | ||||
-rw-r--r-- | o3d/gpu_plugin/np_utils/np_browser_mock.h | 28 | ||||
-rw-r--r-- | o3d/gpu_plugin/np_utils/np_object_pointer.h | 6 | ||||
-rw-r--r-- | o3d/gpu_plugin/np_utils/np_object_pointer_unittest.cc | 21 | ||||
-rw-r--r-- | o3d/gpu_plugin/np_utils/np_utils.h | 10 |
6 files changed, 91 insertions, 6 deletions
diff --git a/o3d/gpu_plugin/gpu_plugin_object.cc b/o3d/gpu_plugin/gpu_plugin_object.cc index 8191e0a..c83dd03 100644 --- a/o3d/gpu_plugin/gpu_plugin_object.cc +++ b/o3d/gpu_plugin/gpu_plugin_object.cc @@ -10,6 +10,8 @@ namespace o3d { namespace gpu_plugin { +const int32 kCommandBufferSize = 1024; + const NPUTF8 GPUPluginObject::kPluginType[] = "application/vnd.google.chrome.gpu-plugin"; @@ -95,7 +97,7 @@ NPObjectPointer<NPObject> GPUPluginObject::OpenCommandBuffer() { return NPObjectPointer<NPObject>(); } - if (!NPInvoke(npp(), system, "createSharedMemory", 1024, + if (!NPInvoke(npp(), system, "createSharedMemory", kCommandBufferSize, &command_buffer_object_)) { return NPObjectPointer<NPObject>(); } diff --git a/o3d/gpu_plugin/gpu_plugin_object_factory.h b/o3d/gpu_plugin/gpu_plugin_object_factory.h new file mode 100644 index 0000000..de01e64 --- /dev/null +++ b/o3d/gpu_plugin/gpu_plugin_object_factory.h @@ -0,0 +1,28 @@ +// Copyright (c) 2006-2008 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 O3D_GPU_PLUGIN_GPU_PLUGIN_OBJECT_FACTORY_H_ +#define O3D_GPU_PLUGIN_GPU_PLUGIN_OBJECT_FACTORY_H_ + +#include "o3d/gpu_plugin/np_utils/np_plugin_object_factory.h" + +namespace o3d { +namespace gpu_plugin { + +// Plugin object factory for creating the GPUPluginObject. +class GPUPluginObjectFactory : public NPPluginObjectFactory { + public: + GPUPluginObjectFactory(); + virtual ~GPUPluginObjectFactory(); + + virtual PluginObject* CreatePluginObject(NPP npp, NPMIMEType plugin_type); + + private: + DISALLOW_COPY_AND_ASSIGN(GPUPluginObjectFactory); +}; + +} // namespace gpu_plugin +} // namespace o3d + +#endif // O3D_GPU_PLUGIN_GPU_PLUGIN_OBJECT_FACTORY_H_ diff --git a/o3d/gpu_plugin/np_utils/np_browser_mock.h b/o3d/gpu_plugin/np_utils/np_browser_mock.h new file mode 100644 index 0000000..9edb09a --- /dev/null +++ b/o3d/gpu_plugin/np_utils/np_browser_mock.h @@ -0,0 +1,28 @@ +// Copyright (c) 2006-2008 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 O3D_GPU_PLUGIN_NP_UTILS_NP_BROWSER_MOCK_H_ +#define O3D_GPU_PLUGIN_NP_UTILS_NP_BROWSER_MOCK_H_ + +#include "o3d/gpu_plugin/np_utils/np_browser_stub.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace o3d { +namespace gpu_plugin { + +// This mocks certain member functions of the stub browser. Those relating +// to identifiers, memory management, reference counting and forwarding to +// NPObjects are deliberately not mocked so the mock browser can be used as +// normal for these calls. +class MockNPBrowser : public StubNPBrowser { + public: + MOCK_METHOD1(GetWindowNPObject, NPObject*(NPP)); + MOCK_METHOD4(MapSharedMemory, NPSharedMemory*(NPP, NPObject*, size_t, bool)); + MOCK_METHOD2(UnmapSharedMemory, void(NPP, NPSharedMemory*)); +}; + +} // namespace gpu_plugin +} // namespace o3d + +#endif // O3D_GPU_PLUGIN_NP_UTILS_NP_BROWSER_MOCK_H_ diff --git a/o3d/gpu_plugin/np_utils/np_object_pointer.h b/o3d/gpu_plugin/np_utils/np_object_pointer.h index b6e299c..4d687dc 100644 --- a/o3d/gpu_plugin/np_utils/np_object_pointer.h +++ b/o3d/gpu_plugin/np_utils/np_object_pointer.h @@ -37,6 +37,9 @@ class NPObjectPointer { } NPObjectPointer& operator=(const NPObjectPointer& rhs) { + if (object_ == rhs.Get()) + return *this; + Release(); object_ = rhs.object_; Retain(); @@ -45,6 +48,9 @@ class NPObjectPointer { template <typename RHS> NPObjectPointer& operator=(const NPObjectPointer<RHS>& rhs) { + if (object_ == rhs.Get()) + return *this; + Release(); object_ = rhs.Get(); Retain(); diff --git a/o3d/gpu_plugin/np_utils/np_object_pointer_unittest.cc b/o3d/gpu_plugin/np_utils/np_object_pointer_unittest.cc index 344e07b..c1464f7 100644 --- a/o3d/gpu_plugin/np_utils/np_object_pointer_unittest.cc +++ b/o3d/gpu_plugin/np_utils/np_object_pointer_unittest.cc @@ -118,6 +118,15 @@ TEST_F(NPObjectPointerTest, PointerCanBeAssigned) { EXPECT_EQ(2, raw_pointer_->referenceCount); } +TEST_F(NPObjectPointerTest, PointerCanBeAssignedToSelf) { + NPObjectPointer<MockBaseNPObject> p(raw_pointer_); + NPBrowser::get()->ReleaseObject(raw_pointer_); + EXPECT_EQ(1, raw_pointer_->referenceCount); + p = p; + EXPECT_EQ(1, raw_pointer_->referenceCount); + NPBrowser::get()->RetainObject(raw_pointer_); +} + TEST_F(NPObjectPointerTest, PointerCanBeAssignedDerived) { NPObjectPointer<DerivedNPObject> p1(raw_derived_pointer_); EXPECT_EQ(2, raw_derived_pointer_->referenceCount); @@ -138,6 +147,18 @@ TEST_F(NPObjectPointerTest, PointerCanBeAssignedDerived) { EXPECT_EQ(2, raw_derived_pointer_->referenceCount); } +TEST_F(NPObjectPointerTest, DerivedPointerCanBeAssignedToSelf) { + NPObjectPointer<MockBaseNPObject> p1(raw_derived_pointer_); + NPObjectPointer<DerivedNPObject> p2(raw_derived_pointer_); + NPBrowser::get()->ReleaseObject(raw_derived_pointer_); + NPBrowser::get()->ReleaseObject(raw_derived_pointer_); + EXPECT_EQ(1, raw_derived_pointer_->referenceCount); + p1 = p2; + EXPECT_EQ(1, raw_derived_pointer_->referenceCount); + NPBrowser::get()->RetainObject(raw_derived_pointer_); + NPBrowser::get()->RetainObject(raw_derived_pointer_); +} + TEST_F(NPObjectPointerTest, CanComparePointersForEqual) { NPObjectPointer<MockBaseNPObject> p1(raw_pointer_); NPObjectPointer<DerivedNPObject> p2(raw_derived_pointer_); diff --git a/o3d/gpu_plugin/np_utils/np_utils.h b/o3d/gpu_plugin/np_utils/np_utils.h index f2ec2ed..af1555c 100644 --- a/o3d/gpu_plugin/np_utils/np_utils.h +++ b/o3d/gpu_plugin/np_utils/np_utils.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef O3D_GPU_PLUGIN_NP_UTILS_NP_VARIANT_UTILS_H_ -#define O3D_GPU_PLUGIN_NP_UTILS_NP_VARIANT_UTILS_H_ +#ifndef O3D_GPU_PLUGIN_NP_UTILS_NP_UTILS_H_ +#define O3D_GPU_PLUGIN_NP_UTILS_NP_UTILS_H_ #include <string> @@ -73,7 +73,7 @@ void ValueToNPVariant(const NPObjectPointer<T>& value, } } -// NPVariant that autmatically releases in destructor. +// NPVariant that automatically manages lifetime of string and object variants. class SmartNPVariant : public NPVariant { public: SmartNPVariant(); @@ -101,7 +101,7 @@ class SmartNPVariant : public NPVariant { void Release(); -private: + private: void Copy(const NPVariant& rhs); }; @@ -245,4 +245,4 @@ NPObjectPointer<NPObjectType> NPCreateObject(NPP npp) { } // namespace gpu_plugin } // namespace o3d -#endif // O3D_GPU_PLUGIN_NP_UTILS_NP_VARIANT_UTILS_H_ +#endif // O3D_GPU_PLUGIN_NP_UTILS_NP_UTILS_H_ |