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

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

Issue 9290040: Revert 119198 - 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') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
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"
11
12 class MyInstance : public pp::Instance {
13 public:
14 MyInstance(PP_Instance instance) : pp::Instance(instance) {
15 thread_ = new pp::SimpleThread(this);
16 factory_.Initialize(this);
17 }
18
19 virtual ~MyInstance() {
20 delete thread_;
21 }
22
23 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) {
24 thread_->Start();
25 thread_->message_loop().PostWork(
26 factory_.NewCallback(&MyInstance::CallOnBackground));
27 return true;
28 }
29
30 virtual void DidChangeView(const pp::View& view) {
31 }
32
33 private:
34 void CallOnBackground(int32_t result) {
35 }
36
37 pp::CompletionCallbackFactory<MyInstance> factory_;
38
39 pp::SimpleThread* thread_;
40 };
41
42
43 class MyModule : public pp::Module {
44 public:
45 MyModule() : pp::Module() {}
46 virtual ~MyModule() {}
47
48 virtual pp::Instance* CreateInstance(PP_Instance instance) {
49 return new MyInstance(instance);
50 }
51 };
52
53 namespace pp {
54
55 // Factory function for your specialization of the Module object.
56 Module* CreateModule() {
57 return new MyModule();
58 }
59
60 } // namespace pp
OLDNEW
« no previous file with comments | « no previous file | ppapi/ppapi_proxy.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698