Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: native_client_sdk/src/libraries/ppapi_simple/ps_instance.h

Issue 15011003: ppapi_simple (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix enums Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/ppapi_simple/ps_instance.h
diff --git a/native_client_sdk/src/libraries/ppapi_simple/ps_instance.h b/native_client_sdk/src/libraries/ppapi_simple/ps_instance.h
new file mode 100644
index 0000000000000000000000000000000000000000..b2018f109e2d0db83997c1b78026264df2dc174b
--- /dev/null
+++ b/native_client_sdk/src/libraries/ppapi_simple/ps_instance.h
@@ -0,0 +1,122 @@
+// Copyright (c) 2013 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 PPAPI_SIMPLE_PS_INSTANCE_H_
+#define PPAPI_SIMPLE_PS_INSTANCE_H_
+
+#include <map>
+
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_stdint.h"
+#include "ppapi/c/ppb_core.h"
+#include "ppapi/c/ppb_var.h"
+#include "ppapi/c/ppb_view.h"
+
+#include "ppapi/cpp/fullscreen.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/message_loop.h"
+#include "ppapi/cpp/mouse_lock.h"
+
+#include "ppapi/utility/completion_callback_factory.h"
+
+#include "ppapi_simple/ps_event.h"
+#include "ppapi_simple/ps_main.h"
+
+#include "utils/thread_safe_queue.h"
+
+
+typedef std::map<std::string, std::string> PropertyMap_t;
+
+class PSInstance : public pp::Instance {
+ public:
+ enum Verbosity {
+ PSV_SILENT,
+ PSV_ERROR,
+ PSV_WARN,
+ PSV_LOG,
+ };
+
+ // Returns a pointer to the global instance
+ static PSInstance* GetInstance();
+
+ PSInstance(PP_Instance inst, const char *argv[]);
+ virtual ~PSInstance();
+
+ // Set a function which will be called on a new thread once initialized.
+ // NOTE: This must be called by the Factory, once Init is called, this
+ // function will have no effect.
+ void SetMain(PSMainFunc_t func);
+
+ // Returns value based on KEY or default.
+ const char* GetProperty(const char* key, const char* def = NULL);
+
+ // Started on Init, a thread which can be safely blocked.
+ virtual int MainThread(int argc, const char* argv[]);
binji 2013/05/30 05:07:50 private/protected? Nothing should call this except
noelallen1 2013/05/30 18:07:19 Done.
+
+ // Logging F
+ void SetVerbosity(Verbosity verbosity);
+ void Log(const char *fmt, ...);
+ void Warn(const char *fmt, ...);
+ void Error(const char *fmt, ...);
+
+ // Event Functions
+ void SetEnabledEvents(uint32_t mask);
+ void PostEvent(PSEventType type);
+ void PostEvent(PSEventType type, PP_Bool bool_value);
+ void PostEvent(PSEventType type, PP_Resource resource);
+ void PostEvent(PSEventType type, const PP_Var& var);
+
+ PSEvent* TryAcquireEvent();
+ PSEvent* WaitAcquireEvent();
+ void ReleaseEvent(PSEvent* event);
+//
binji 2013/05/30 05:07:50 remove //
noelallen1 2013/05/30 18:07:19 Done.
+ protected:
+ //
+ // Callback functions triggered by Pepepr
binji 2013/05/30 05:07:50 sp: Pepper
noelallen1 2013/05/30 18:07:19 Done.
+ //
+ // These functions are called on the main pepper thread, so they must
+ // not block.
+ //
+ // Called by the browser when the NaCl module is loaded and all ready to go.
+ // This function will create a new thread which will run the pseudo main.
+ virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]);
+
+ // Called whenever the in-browser window changes size, it will pass a
+ // context change request to whichever thread is handling rendering.
+ virtual void DidChangeView(const pp::View& view);
+
+ // Called by the browser when the NaCl canvas gets or loses focus.
+ virtual void DidChangeFocus(bool has_focus);
+
+ // Called by the browser to handle the postMessage() call in Javascript.
+ virtual void HandleMessage(const pp::Var& message);
+
+ // Called by the browser to handle incoming input events. Events are Q'd
+ // and can later be processed on a sperate processing thread.
+ virtual bool HandleInputEvent(const pp::InputEvent& event);
+
+ // Called by Init to processes default and embed tag arguments prior to
+ // launching the 'ppapi_main' thread.
+ virtual bool ProcessProperties();
+
+ static void* MainThreadThunk(void *start_info);
+
+
+ protected:
+ pp::MessageLoop* main_loop_;
+
+ PropertyMap_t properties_;
+ ThreadSafeQueue<PSEvent> event_queue_;
+ uint32_t events_enabled_;
+ uint32_t verbosity_;
binji 2013/05/30 05:07:50 Why not Verbosity verbosity_
noelallen1 2013/05/30 18:07:19 Done.
+
+ PSMainFunc_t main_cb_;
+
+ const PPB_Core* ppb_core_;
+ const PPB_Var* ppb_var_;
+ const PPB_View* ppb_view_;
+};
+
+#endif // PPAPI_MAIN_PS_INSTANCE_H_
+

Powered by Google App Engine
This is Rietveld 408576698