Home | History | Annotate | Download | only in pepper_container_app
      1 // Copyright 2014 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.
      4 
      5 #ifndef MOJO_EXAMPLES_PEPPER_CONTAINER_APP_MOJO_PPAPI_GLOBALS_H_
      6 #define MOJO_EXAMPLES_PEPPER_CONTAINER_APP_MOJO_PPAPI_GLOBALS_H_
      7 
      8 #include "base/compiler_specific.h"
      9 #include "base/macros.h"
     10 #include "base/memory/ref_counted.h"
     11 #include "mojo/public/cpp/system/core.h"
     12 #include "ppapi/shared_impl/ppapi_globals.h"
     13 #include "ppapi/shared_impl/resource_tracker.h"
     14 
     15 namespace base {
     16 class MessageLoopProxy;
     17 }
     18 
     19 namespace mojo {
     20 namespace examples {
     21 
     22 class PluginInstance;
     23 
     24 class MojoPpapiGlobals : public ppapi::PpapiGlobals {
     25  public:
     26   class Delegate {
     27    public:
     28     virtual ~Delegate() {}
     29 
     30     virtual ScopedMessagePipeHandle CreateGLES2Context() = 0;
     31   };
     32 
     33   // |delegate| must live longer than this object.
     34   explicit MojoPpapiGlobals(Delegate* delegate);
     35   virtual ~MojoPpapiGlobals();
     36 
     37   inline static MojoPpapiGlobals* Get() {
     38     return static_cast<MojoPpapiGlobals*>(PpapiGlobals::Get());
     39   }
     40 
     41   PP_Instance AddInstance(PluginInstance* instance);
     42   void InstanceDeleted(PP_Instance instance);
     43   PluginInstance* GetInstance(PP_Instance instance);
     44 
     45   ScopedMessagePipeHandle CreateGLES2Context();
     46 
     47   // ppapi::PpapiGlobals implementation.
     48   virtual ppapi::ResourceTracker* GetResourceTracker() OVERRIDE;
     49   virtual ppapi::VarTracker* GetVarTracker() OVERRIDE;
     50   virtual ppapi::CallbackTracker* GetCallbackTrackerForInstance(
     51       PP_Instance instance) OVERRIDE;
     52   virtual void LogWithSource(PP_Instance instance,
     53                              PP_LogLevel level,
     54                              const std::string& source,
     55                              const std::string& value) OVERRIDE;
     56   virtual void BroadcastLogWithSource(PP_Module module,
     57                                       PP_LogLevel level,
     58                                       const std::string& source,
     59                                       const std::string& value) OVERRIDE;
     60   virtual ppapi::thunk::PPB_Instance_API* GetInstanceAPI(
     61       PP_Instance instance) OVERRIDE;
     62   virtual ppapi::thunk::ResourceCreationAPI* GetResourceCreationAPI(
     63       PP_Instance instance) OVERRIDE;
     64   virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE;
     65   virtual ppapi::MessageLoopShared* GetCurrentMessageLoop() OVERRIDE;
     66   virtual base::TaskRunner* GetFileTaskRunner() OVERRIDE;
     67   virtual std::string GetCmdLine() OVERRIDE;
     68   virtual void PreCacheFontForFlash(const void* logfontw) OVERRIDE;
     69 
     70  private:
     71   class MainThreadMessageLoopResource;
     72 
     73   // Non-owning pointer.
     74   Delegate* const delegate_;
     75 
     76   // Non-owning pointer.
     77   PluginInstance* plugin_instance_;
     78 
     79   ppapi::ResourceTracker resource_tracker_;
     80 
     81   scoped_refptr<MainThreadMessageLoopResource>
     82       main_thread_message_loop_resource_;
     83 
     84   DISALLOW_COPY_AND_ASSIGN(MojoPpapiGlobals);
     85 };
     86 
     87 }  // namespace examples
     88 }  // namespace mojo
     89 
     90 #endif  // MOJO_EXAMPLES_PEPPER_CONTAINER_APP_MOJO_PPAPI_GLOBALS_H_
     91