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

Side by Side Diff: native_client_sdk/src/libraries/ppapi_simple/ppapi_simple_instance.h

Issue 15011003: ppapi_simple (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove raw 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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 PPAPI_SIMPLE_PPAPI_SIMPLE_INSTANCE_H_
6 #define PPAPI_SIMPLE_PPAPI_SIMPLE_INSTANCE_H_
7
8 #include <map>
9
10 #include "ppapi/c/pp_instance.h"
11 #include "ppapi/c/pp_stdint.h"
12 #include "ppapi/c/ppb_core.h"
13 #include "ppapi/c/ppb_var.h"
14 #include "ppapi/c/ppb_view.h"
15
16 #include "ppapi/cpp/fullscreen.h"
17 #include "ppapi/cpp/instance.h"
18 #include "ppapi/cpp/message_loop.h"
19 #include "ppapi/cpp/mouse_lock.h"
20
21 #include "ppapi/utility/completion_callback_factory.h"
22
23 #include "ppapi_simple/ppapi_event.h"
24 #include "ppapi_simple/ppapi_simple_main.h"
25
26 #include "utils/thread_safe_queue.h"
27
28
29 typedef std::map<std::string, std::string> PropertyMap_t;
30
31 class PSInstance : public pp::Instance {
32 public:
33 enum Verbosity {
34 PS_SILENT_VERBOSITY,
35 PS_ERROR_VERBOSITY,
36 PS_WARN_VERBOSITY,
37 PS_LOG_VERBOSITY,
38 };
39
40 // Returns a pointer to the global instance
41 static PSInstance* GetInstance();
42
43 PSInstance(PP_Instance inst, const char *argv[]);
44 virtual ~PSInstance();
45
46 // Set a function which will be called on a new thread once initialized.
47 // NOTE: This must be called by the Factory, once Init is called, this
48 // function will have no effect.
49 void SetMain(PSMainFunc_t func);
50
51 // Returns value based on KEY or default.
52 const char* GetProperty(const char* key, const char* def = NULL);
53
54 // Started on Init, a thread which can be safely blocked.
55 virtual int MainThread(int argc, const char* argv[]);
56
57 // Logging F
58 void SetVerbosity(Verbosity verbosity);
59 void Log(const char *fmt, ...);
Sam Clegg 2013/05/29 04:48:25 IIRC you can mark these functions with GCC attribu
noelallen_use_chromium 2013/05/30 00:25:07 Unfortunately __attribute__ is not available on wi
60 void Warn(const char *fmt, ...);
61 void Error(const char *fmt, ...);
62
63 // Event Functions
64 void SetEnabledEvents(uint32_t mask);
65 void PostEvent(PSEventType type);
66 void PostEvent(PSEventType type, PP_Bool bool_value);
67 void PostEvent(PSEventType type, PP_Resource resource);
68 void PostEvent(PSEventType type, const PP_Var& var);
69
70 PSEvent* TryAcquireEvent();
71 PSEvent* WaitAcquireEvent();
72 void ReleaseEvent(PSEvent* event);
73 //
74 protected:
75 //
76 // Callback functions triggered by Pepepr
77 //
78 // These functions are called on the main pepper thread, so they must
79 // not block.
80 //
81 // Called by the browser when the NaCl module is loaded and all ready to go.
82 // This function will create a new thread which will run the pseudo main.
83 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]);
84
85 // Called whenever the in-browser window changes size, it will pass a
86 // context change request to whichever thread is handling rendering.
87 virtual void DidChangeView(const pp::View& view);
88
89 // Called by the browser when the NaCl canvas gets or loses focus.
90 virtual void DidChangeFocus(bool has_focus);
91
92 // Called by the browser to handle the postMessage() call in Javascript.
93 virtual void HandleMessage(const pp::Var& message);
94
95 // Called by the browser to handle incoming input events. Events are Q'd
96 // and can later be processed on a sperate processing thread.
97 virtual bool HandleInputEvent(const pp::InputEvent& event);
98
99 // Called by Init to processes default and embed tag arguments prior to
100 // launching the 'ppapi_main' thread.
101 virtual bool ProcessProperties();
102
103 static void* MainThreadThunk(void *start_info);
104
105
106 protected:
107 pp::MessageLoop* main_loop_;
108
109 PropertyMap_t properties_;
110 ThreadSafeQueue<PSEvent> event_queue_;
111 uint32_t events_enabled_;
112 uint32_t verbosity_;
113
114 PSMainFunc_t main_cb_;
115
116 const PPB_Core* ppb_core_;
117 const PPB_Var* ppb_var_;
118 const PPB_View* ppb_view_;
119 };
120
121 #endif // PPAPI_MAIN_PPAPI_INSTANCE_H_
122
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698