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
3 // found in the LICENSE file.
5 #ifndef PPAPI_SHARED_IMPL_TEST_GLOBALS_H_
6 #define PPAPI_SHARED_IMPL_TEST_GLOBALS_H_
8 #include "base/compiler_specific.h"
9 #include "base/shared_memory.h"
10 #include "ppapi/shared_impl/callback_tracker.h"
11 #include "ppapi/shared_impl/ppapi_globals.h"
12 #include "ppapi/shared_impl/resource_tracker.h"
13 #include "ppapi/shared_impl/var_tracker.h"
17 class TestVarTracker
: public VarTracker
{
19 TestVarTracker() : VarTracker(THREAD_SAFE
) {}
20 virtual ~TestVarTracker() {}
21 virtual ArrayBufferVar
* CreateArrayBuffer(uint32 size_in_bytes
) OVERRIDE
{
24 virtual ArrayBufferVar
* CreateShmArrayBuffer(
26 base::SharedMemoryHandle handle
) OVERRIDE
{
29 virtual void DidDeleteInstance(PP_Instance instance
) OVERRIDE
{
31 virtual int TrackSharedMemoryHandle(PP_Instance instance
,
32 base::SharedMemoryHandle handle
,
33 uint32 size_in_bytes
) OVERRIDE
{
36 virtual bool StopTrackingSharedMemoryHandle(int id
,
38 base::SharedMemoryHandle
* handle
,
39 uint32
* size_in_bytes
) OVERRIDE
{
44 // Implementation of PpapiGlobals for tests that don't need either the host- or
45 // plugin-specific implementations.
46 class TestGlobals
: public PpapiGlobals
{
49 explicit TestGlobals(PpapiGlobals::PerThreadForTest
);
50 virtual ~TestGlobals();
52 // PpapiGlobals implementation.
53 virtual ResourceTracker
* GetResourceTracker() OVERRIDE
;
54 virtual VarTracker
* GetVarTracker() OVERRIDE
;
55 virtual CallbackTracker
* GetCallbackTrackerForInstance(
56 PP_Instance instance
) OVERRIDE
;
57 virtual thunk::PPB_Instance_API
* GetInstanceAPI(
58 PP_Instance instance
) OVERRIDE
;
59 virtual thunk::ResourceCreationAPI
* GetResourceCreationAPI(
60 PP_Instance instance
) OVERRIDE
;
61 virtual PP_Module
GetModuleForInstance(PP_Instance instance
) OVERRIDE
;
62 virtual std::string
GetCmdLine() OVERRIDE
;
63 virtual void PreCacheFontForFlash(const void* logfontw
) OVERRIDE
;
64 virtual base::Lock
* GetProxyLock() OVERRIDE
;
65 virtual void LogWithSource(PP_Instance instance
,
67 const std::string
& source
,
68 const std::string
& value
) OVERRIDE
;
69 virtual void BroadcastLogWithSource(PP_Module module
,
71 const std::string
& source
,
72 const std::string
& value
) OVERRIDE
;
73 virtual MessageLoopShared
* GetCurrentMessageLoop() OVERRIDE
;
75 // PpapiGlobals overrides:
76 virtual bool IsHostGlobals() const OVERRIDE
;
79 ResourceTracker resource_tracker_
;
80 TestVarTracker var_tracker_
;
81 scoped_refptr
<CallbackTracker
> callback_tracker_
;
83 DISALLOW_COPY_AND_ASSIGN(TestGlobals
);
88 #endif // PPAPI_SHARED_IMPL_TEST_GLOBALS_H_