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

Side by Side Diff: ppapi/examples/threading/threading.cc

Issue 9097006: First pass at implementing the MessageLoop interface. This includes a simple (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 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
« no previous file with comments | « no previous file | ppapi/ppapi_proxy.gypi » ('j') | ppapi/utility/threading/simple_thread.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
bbudge 2012/01/10 19:40:20 Year
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ppapi/c/dev/ppb_console_dev.h"
bbudge 2012/01/10 19:40:20 Wow, this is a lot of includes. Is that the standa
brettw 2012/01/18 17:53:09 Sorry, copy-n-pasted.
6 #include "ppapi/c/dev/ppb_cursor_control_dev.h"
7 #include "ppapi/c/dev/ppp_printing_dev.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/pp_rect.h"
10 #include "ppapi/cpp/completion_callback.h"
11 #include "ppapi/cpp/dev/memory_dev.h"
12 #include "ppapi/cpp/dev/scriptable_object_deprecated.h"
13 #include "ppapi/cpp/graphics_2d.h"
14 #include "ppapi/cpp/image_data.h"
15 #include "ppapi/cpp/input_event.h"
16 #include "ppapi/cpp/private/instance_private.h"
17 #include "ppapi/cpp/module.h"
18 #include "ppapi/cpp/private/var_private.h"
19 #include "ppapi/cpp/rect.h"
20 #include "ppapi/cpp/url_loader.h"
21 #include "ppapi/cpp/url_request_info.h"
22 #include "ppapi/cpp/var.h"
23 #include "ppapi/cpp/view.h"
24 #include "ppapi/utility/completion_callback_factory.h"
25 #include "ppapi/utility/threading/simple_thread.h"
26
27 class MyInstance : public pp::Instance {
28 public:
29 MyInstance(PP_Instance instance)
30 : pp::Instance(instance),
31 factory_(this),
32 thread_(this) {
bbudge 2012/01/10 19:40:20 I think Visual Studio will complain about using 't
33 RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
34 }
35
36 virtual ~MyInstance() {
37 }
38
39 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) {
40 thread_.Start();
41 thread_.message_loop().PostWork(
42 factory_.NewCallback(&MyInstance::CallOnBackground));
43 return true;
44 }
45
46 virtual bool HandleInputEvent(const pp::InputEvent& event) {
47 switch (event.GetType()) {
48 case PP_INPUTEVENT_TYPE_MOUSEDOWN:
49 return true;
50 case PP_INPUTEVENT_TYPE_MOUSEMOVE:
51 return true;
52 case PP_INPUTEVENT_TYPE_KEYDOWN:
53 return true;
54 default:
55 return false;
56 }
57 }
58
59 virtual void DidChangeView(const pp::View& view) {
60 }
61
62 private:
63 void CallOnBackground(int32_t result) {
64 }
65
66 pp::CompletionCallbackFactory<MyInstance> factory_;
67
68 pp::SimpleThread thread_;
69 };
70
71
72 class MyModule : public pp::Module {
73 public:
74 MyModule() : pp::Module() {}
75 virtual ~MyModule() {}
76
77 virtual pp::Instance* CreateInstance(PP_Instance instance) {
78 return new MyInstance(instance);
79 }
80 };
81
82 namespace pp {
83
84 // Factory function for your specialization of the Module object.
85 Module* CreateModule() {
86 return new MyModule();
87 }
88
89 } // namespace pp
OLDNEW
« no previous file with comments | « no previous file | ppapi/ppapi_proxy.gypi » ('j') | ppapi/utility/threading/simple_thread.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698