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

Side by Side Diff: mojo/examples/pepper_container_app/mojo_ppapi_globals.cc

Issue 681203002: Remove mojo/examples/pepper_container_app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2014 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 "mojo/examples/pepper_container_app/mojo_ppapi_globals.h"
6
7 #include "base/logging.h"
8 #include "base/macros.h"
9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/time/time.h"
11 #include "mojo/examples/pepper_container_app/plugin_instance.h"
12 #include "ppapi/c/pp_errors.h"
13 #include "ppapi/shared_impl/ppb_message_loop_shared.h"
14
15 namespace mojo {
16 namespace examples {
17
18 namespace {
19
20 const PP_Instance kInstanceId = 1;
21
22 } // namespace
23
24 // A non-abstract subclass of ppapi::MessageLoopShared that represents the
25 // message loop of the main thread.
26 // TODO(yzshen): Build a more general ppapi::MessageLoopShared subclass to fully
27 // support PPB_MessageLoop.
28 class MojoPpapiGlobals::MainThreadMessageLoopResource
29 : public ppapi::MessageLoopShared {
30 public:
31 explicit MainThreadMessageLoopResource(
32 base::MessageLoopProxy* main_thread_message_loop)
33 : MessageLoopShared(ForMainThread()),
34 main_thread_message_loop_(main_thread_message_loop) {}
35
36 // ppapi::MessageLoopShared implementation.
37 virtual void PostClosure(const tracked_objects::Location& from_here,
38 const base::Closure& closure,
39 int64 delay_ms) override {
40 main_thread_message_loop_->PostDelayedTask(
41 from_here, closure, base::TimeDelta::FromMilliseconds(delay_ms));
42 }
43
44 virtual base::MessageLoopProxy* GetMessageLoopProxy() override {
45 return main_thread_message_loop_.get();
46 }
47
48 virtual bool CurrentlyHandlingBlockingMessage() override {
49 return false;
50 }
51
52 // ppapi::thunk::PPB_MessageLoop_API implementation.
53 virtual int32_t AttachToCurrentThread() override {
54 NOTIMPLEMENTED();
55 return PP_ERROR_FAILED;
56 }
57
58 virtual int32_t Run() override {
59 NOTIMPLEMENTED();
60 return PP_ERROR_FAILED;
61 }
62
63 virtual int32_t PostWork(PP_CompletionCallback callback,
64 int64_t delay_ms) override {
65 NOTIMPLEMENTED();
66 return PP_ERROR_FAILED;
67 }
68
69 virtual int32_t PostQuit(PP_Bool should_destroy) override {
70 NOTIMPLEMENTED();
71 return PP_ERROR_FAILED;
72 }
73
74 private:
75 virtual ~MainThreadMessageLoopResource() {}
76
77 scoped_refptr<base::MessageLoopProxy> main_thread_message_loop_;
78 DISALLOW_COPY_AND_ASSIGN(MainThreadMessageLoopResource);
79 };
80
81 MojoPpapiGlobals::MojoPpapiGlobals(Delegate* delegate)
82 : delegate_(delegate),
83 plugin_instance_(NULL),
84 resource_tracker_(ppapi::ResourceTracker::THREAD_SAFE) {}
85
86 MojoPpapiGlobals::~MojoPpapiGlobals() {}
87
88 PP_Instance MojoPpapiGlobals::AddInstance(PluginInstance* instance) {
89 DCHECK(!plugin_instance_);
90 plugin_instance_ = instance;
91 resource_tracker_.DidCreateInstance(kInstanceId);
92 return kInstanceId;
93 }
94
95 void MojoPpapiGlobals::InstanceDeleted(PP_Instance instance) {
96 DCHECK_EQ(instance, kInstanceId);
97 DCHECK(plugin_instance_);
98 resource_tracker_.DidDeleteInstance(instance);
99 plugin_instance_ = NULL;
100 }
101
102 PluginInstance* MojoPpapiGlobals::GetInstance(PP_Instance instance) {
103 if (instance == kInstanceId)
104 return plugin_instance_;
105 return NULL;
106 }
107
108 ScopedMessagePipeHandle MojoPpapiGlobals::CreateGLES2Context() {
109 return delegate_->CreateGLES2Context();
110 }
111
112 ppapi::ResourceTracker* MojoPpapiGlobals::GetResourceTracker() {
113 return &resource_tracker_;
114 }
115
116 ppapi::VarTracker* MojoPpapiGlobals::GetVarTracker() {
117 NOTIMPLEMENTED();
118 return NULL;
119 }
120
121 ppapi::CallbackTracker* MojoPpapiGlobals::GetCallbackTrackerForInstance(
122 PP_Instance instance) {
123 if (instance == kInstanceId && plugin_instance_)
124 return plugin_instance_->plugin_module()->callback_tracker();
125 return NULL;
126 }
127
128 void MojoPpapiGlobals::LogWithSource(PP_Instance instance,
129 PP_LogLevel level,
130 const std::string& source,
131 const std::string& value) {
132 NOTIMPLEMENTED();
133 }
134
135 void MojoPpapiGlobals::BroadcastLogWithSource(PP_Module module,
136 PP_LogLevel level,
137 const std::string& source,
138 const std::string& value) {
139 NOTIMPLEMENTED();
140 }
141
142 ppapi::thunk::PPB_Instance_API* MojoPpapiGlobals::GetInstanceAPI(
143 PP_Instance instance) {
144 if (instance == kInstanceId && plugin_instance_)
145 return plugin_instance_;
146 return NULL;
147 }
148
149 ppapi::thunk::ResourceCreationAPI* MojoPpapiGlobals::GetResourceCreationAPI(
150 PP_Instance instance) {
151 if (instance == kInstanceId && plugin_instance_)
152 return plugin_instance_->resource_creation();
153 return NULL;
154 }
155
156 PP_Module MojoPpapiGlobals::GetModuleForInstance(PP_Instance instance) {
157 NOTIMPLEMENTED();
158 return 0;
159 }
160
161 ppapi::MessageLoopShared* MojoPpapiGlobals::GetCurrentMessageLoop() {
162 if (base::MessageLoopProxy::current().get() == GetMainThreadMessageLoop()) {
163 if (!main_thread_message_loop_resource_.get()) {
164 main_thread_message_loop_resource_ = new MainThreadMessageLoopResource(
165 GetMainThreadMessageLoop());
166 }
167 return main_thread_message_loop_resource_.get();
168 }
169
170 NOTIMPLEMENTED();
171 return NULL;
172 }
173
174 base::TaskRunner* MojoPpapiGlobals::GetFileTaskRunner() {
175 NOTIMPLEMENTED();
176 return NULL;
177 }
178
179 std::string MojoPpapiGlobals::GetCmdLine() {
180 NOTIMPLEMENTED();
181 return std::string();
182 }
183
184 void MojoPpapiGlobals::PreCacheFontForFlash(const void* logfontw) {
185 NOTIMPLEMENTED();
186 }
187
188 } // namespace examples
189 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/examples/pepper_container_app/mojo_ppapi_globals.h ('k') | mojo/examples/pepper_container_app/pepper_container_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698