Save errno for logging before potentially overwriting it.
[chromium-blink-merge.git] / ppapi / shared_impl / test_globals.h
blobc4d4aa1d229bf831efcc19dc04dcbe1def34a0e7
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"
15 namespace ppapi {
17 class TestVarTracker : public VarTracker {
18 public:
19 TestVarTracker() : VarTracker(THREAD_SAFE) {}
20 virtual ~TestVarTracker() {}
21 virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) OVERRIDE {
22 return NULL;
24 virtual ArrayBufferVar* CreateShmArrayBuffer(
25 uint32 size_in_bytes,
26 base::SharedMemoryHandle handle) OVERRIDE {
27 return NULL;
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 {
34 return -1;
36 virtual bool StopTrackingSharedMemoryHandle(int id,
37 PP_Instance instance,
38 base::SharedMemoryHandle* handle,
39 uint32* size_in_bytes) OVERRIDE {
40 return false;
44 // Implementation of PpapiGlobals for tests that don't need either the host- or
45 // plugin-specific implementations.
46 class TestGlobals : public PpapiGlobals {
47 public:
48 TestGlobals();
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,
66 PP_LogLevel level,
67 const std::string& source,
68 const std::string& value) OVERRIDE;
69 virtual void BroadcastLogWithSource(PP_Module module,
70 PP_LogLevel level,
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;
78 private:
79 ResourceTracker resource_tracker_;
80 TestVarTracker var_tracker_;
81 scoped_refptr<CallbackTracker> callback_tracker_;
83 DISALLOW_COPY_AND_ASSIGN(TestGlobals);
86 } // namespace ppapi
88 #endif // PPAPI_SHARED_IMPL_TEST_GLOBALS_H_