| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_SHARED_IMPL_TEST_GLOBALS_H_ | 5 #ifndef PPAPI_SHARED_IMPL_TEST_GLOBALS_H_ |
| 6 #define PPAPI_SHARED_IMPL_TEST_GLOBALS_H_ | 6 #define PPAPI_SHARED_IMPL_TEST_GLOBALS_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "ppapi/shared_impl/callback_tracker.h" | 10 #include "ppapi/shared_impl/callback_tracker.h" |
| 11 #include "ppapi/shared_impl/ppapi_globals.h" | 11 #include "ppapi/shared_impl/ppapi_globals.h" |
| 12 #include "ppapi/shared_impl/resource_tracker.h" | 12 #include "ppapi/shared_impl/resource_tracker.h" |
| 13 #include "ppapi/shared_impl/var_tracker.h" | 13 #include "ppapi/shared_impl/var_tracker.h" |
| 14 | 14 |
| 15 namespace ppapi { | 15 namespace ppapi { |
| 16 | 16 |
| 17 class TestVarTracker : public VarTracker { | 17 class TestVarTracker : public VarTracker { |
| 18 public: | 18 public: |
| 19 TestVarTracker() : VarTracker(THREAD_SAFE) {} | 19 TestVarTracker() : VarTracker(THREAD_SAFE) {} |
| 20 virtual ~TestVarTracker() {} | 20 ~TestVarTracker() override {} |
| 21 virtual PP_Var MakeResourcePPVarFromMessage( | 21 PP_Var MakeResourcePPVarFromMessage( |
| 22 PP_Instance instance, | 22 PP_Instance instance, |
| 23 const IPC::Message& creation_message, | 23 const IPC::Message& creation_message, |
| 24 int pending_renderer_id, | 24 int pending_renderer_id, |
| 25 int pending_browser_id) override { | 25 int pending_browser_id) override { |
| 26 return PP_MakeNull(); | 26 return PP_MakeNull(); |
| 27 } | 27 } |
| 28 virtual ResourceVar* MakeResourceVar(PP_Resource pp_resource) override { | 28 ResourceVar* MakeResourceVar(PP_Resource pp_resource) override { |
| 29 return NULL; | 29 return NULL; |
| 30 } | 30 } |
| 31 virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) override { | 31 ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) override { |
| 32 return NULL; | 32 return NULL; |
| 33 } | 33 } |
| 34 virtual ArrayBufferVar* CreateShmArrayBuffer(uint32 size_in_bytes, | 34 ArrayBufferVar* CreateShmArrayBuffer( |
| 35 base::SharedMemoryHandle handle) | 35 uint32 size_in_bytes, |
| 36 override { | 36 base::SharedMemoryHandle handle) override { |
| 37 return NULL; | 37 return NULL; |
| 38 } | 38 } |
| 39 virtual void DidDeleteInstance(PP_Instance instance) override {} | 39 void DidDeleteInstance(PP_Instance instance) override {} |
| 40 virtual int TrackSharedMemoryHandle(PP_Instance instance, | 40 int TrackSharedMemoryHandle(PP_Instance instance, |
| 41 base::SharedMemoryHandle handle, | 41 base::SharedMemoryHandle handle, |
| 42 uint32 size_in_bytes) override { | 42 uint32 size_in_bytes) override { |
| 43 return -1; | 43 return -1; |
| 44 } | 44 } |
| 45 virtual bool StopTrackingSharedMemoryHandle(int id, | 45 bool StopTrackingSharedMemoryHandle(int id, |
| 46 PP_Instance instance, | 46 PP_Instance instance, |
| 47 base::SharedMemoryHandle* handle, | 47 base::SharedMemoryHandle* handle, |
| 48 uint32* size_in_bytes) override { | 48 uint32* size_in_bytes) override { |
| 49 return false; | 49 return false; |
| 50 } | 50 } |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 // Implementation of PpapiGlobals for tests that don't need either the host- or | 53 // Implementation of PpapiGlobals for tests that don't need either the host- or |
| 54 // plugin-specific implementations. | 54 // plugin-specific implementations. |
| 55 class TestGlobals : public PpapiGlobals { | 55 class TestGlobals : public PpapiGlobals { |
| 56 public: | 56 public: |
| 57 TestGlobals(); | 57 TestGlobals(); |
| 58 explicit TestGlobals(PpapiGlobals::PerThreadForTest); | 58 explicit TestGlobals(PpapiGlobals::PerThreadForTest); |
| 59 virtual ~TestGlobals(); | 59 ~TestGlobals() override; |
| 60 | 60 |
| 61 // PpapiGlobals implementation. | 61 // PpapiGlobals implementation. |
| 62 virtual ResourceTracker* GetResourceTracker() override; | 62 ResourceTracker* GetResourceTracker() override; |
| 63 virtual VarTracker* GetVarTracker() override; | 63 VarTracker* GetVarTracker() override; |
| 64 virtual CallbackTracker* GetCallbackTrackerForInstance(PP_Instance instance) | 64 CallbackTracker* GetCallbackTrackerForInstance(PP_Instance instance) override; |
| 65 override; | 65 thunk::PPB_Instance_API* GetInstanceAPI(PP_Instance instance) override; |
| 66 virtual thunk::PPB_Instance_API* GetInstanceAPI(PP_Instance instance) | 66 thunk::ResourceCreationAPI* GetResourceCreationAPI( |
| 67 override; | |
| 68 virtual thunk::ResourceCreationAPI* GetResourceCreationAPI( | |
| 69 PP_Instance instance) override; | 67 PP_Instance instance) override; |
| 70 virtual PP_Module GetModuleForInstance(PP_Instance instance) override; | 68 PP_Module GetModuleForInstance(PP_Instance instance) override; |
| 71 virtual std::string GetCmdLine() override; | 69 std::string GetCmdLine() override; |
| 72 virtual void PreCacheFontForFlash(const void* logfontw) override; | 70 void PreCacheFontForFlash(const void* logfontw) override; |
| 73 virtual void LogWithSource(PP_Instance instance, | 71 void LogWithSource(PP_Instance instance, |
| 74 PP_LogLevel level, | 72 PP_LogLevel level, |
| 75 const std::string& source, | 73 const std::string& source, |
| 76 const std::string& value) override; | 74 const std::string& value) override; |
| 77 virtual void BroadcastLogWithSource(PP_Module module, | 75 void BroadcastLogWithSource(PP_Module module, |
| 78 PP_LogLevel level, | 76 PP_LogLevel level, |
| 79 const std::string& source, | 77 const std::string& source, |
| 80 const std::string& value) override; | 78 const std::string& value) override; |
| 81 virtual MessageLoopShared* GetCurrentMessageLoop() override; | 79 MessageLoopShared* GetCurrentMessageLoop() override; |
| 82 virtual base::TaskRunner* GetFileTaskRunner() override; | 80 base::TaskRunner* GetFileTaskRunner() override; |
| 83 | 81 |
| 84 // PpapiGlobals overrides: | 82 // PpapiGlobals overrides: |
| 85 virtual bool IsHostGlobals() const override; | 83 bool IsHostGlobals() const override; |
| 86 | 84 |
| 87 private: | 85 private: |
| 88 ResourceTracker resource_tracker_; | 86 ResourceTracker resource_tracker_; |
| 89 TestVarTracker var_tracker_; | 87 TestVarTracker var_tracker_; |
| 90 scoped_refptr<CallbackTracker> callback_tracker_; | 88 scoped_refptr<CallbackTracker> callback_tracker_; |
| 91 | 89 |
| 92 DISALLOW_COPY_AND_ASSIGN(TestGlobals); | 90 DISALLOW_COPY_AND_ASSIGN(TestGlobals); |
| 93 }; | 91 }; |
| 94 | 92 |
| 95 } // namespace ppapi | 93 } // namespace ppapi |
| 96 | 94 |
| 97 #endif // PPAPI_SHARED_IMPL_TEST_GLOBALS_H_ | 95 #endif // PPAPI_SHARED_IMPL_TEST_GLOBALS_H_ |
| OLD | NEW |