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 #include "ppapi/c/pp_errors.h"
6 #include "ppapi/cpp/input_event.h"
7 #include "ppapi/cpp/instance.h"
8 #include "ppapi/cpp/module.h"
9 #include "ppapi/utility/completion_callback_factory.h"
10 #include "ppapi/utility/threading/simple_thread.h"
12 class MyInstance
: public pp::Instance
{
14 MyInstance(PP_Instance instance
) : pp::Instance(instance
) {
15 thread_
= new pp::SimpleThread(this);
16 factory_
.Initialize(this);
19 virtual ~MyInstance() {
23 virtual bool Init(uint32_t argc
, const char* argn
[], const char* argv
[]) {
25 thread_
->message_loop().PostWork(
26 factory_
.NewCallback(&MyInstance::CallOnBackground
));
30 virtual void DidChangeView(const pp::View
& view
) {
34 void CallOnBackground(int32_t result
) {
37 pp::CompletionCallbackFactory
<MyInstance
> factory_
;
39 pp::SimpleThread
* thread_
;
43 class MyModule
: public pp::Module
{
45 MyModule() : pp::Module() {}
46 virtual ~MyModule() {}
48 virtual pp::Instance
* CreateInstance(PP_Instance instance
) {
49 return new MyInstance(instance
);
55 // Factory function for your specialization of the Module object.
56 Module
* CreateModule() {
57 return new MyModule();