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

Side by Side Diff: webkit/plugins/ppapi/plugin_module.cc

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export AssertLockHeld Created 8 years, 6 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 | « webkit/plugins/ppapi/file_callbacks.cc ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/plugins/ppapi/plugin_module.h" 5 #include "webkit/plugins/ppapi/plugin_module.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 // Maintains all currently loaded plugin libs for validating PP_Module 148 // Maintains all currently loaded plugin libs for validating PP_Module
149 // identifiers. 149 // identifiers.
150 typedef std::set<PluginModule*> PluginModuleSet; 150 typedef std::set<PluginModule*> PluginModuleSet;
151 151
152 PluginModuleSet* GetLivePluginSet() { 152 PluginModuleSet* GetLivePluginSet() {
153 CR_DEFINE_STATIC_LOCAL(PluginModuleSet, live_plugin_libs, ()); 153 CR_DEFINE_STATIC_LOCAL(PluginModuleSet, live_plugin_libs, ());
154 return &live_plugin_libs; 154 return &live_plugin_libs;
155 } 155 }
156 156
157 base::MessageLoopProxy* GetMainThreadMessageLoop() {
158 CR_DEFINE_STATIC_LOCAL(scoped_refptr<base::MessageLoopProxy>, proxy,
159 (base::MessageLoopProxy::current()));
160 return proxy.get();
161 }
162
163 // PPB_Core -------------------------------------------------------------------- 157 // PPB_Core --------------------------------------------------------------------
164 158
165 void AddRefResource(PP_Resource resource) { 159 void AddRefResource(PP_Resource resource) {
166 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(resource); 160 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(resource);
167 } 161 }
168 162
169 void ReleaseResource(PP_Resource resource) { 163 void ReleaseResource(PP_Resource resource) {
170 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(resource); 164 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(resource);
171 } 165 }
172 166
173 PP_Time GetTime() { 167 PP_Time GetTime() {
174 return TimeToPPTime(base::Time::Now()); 168 return TimeToPPTime(base::Time::Now());
175 } 169 }
176 170
177 PP_TimeTicks GetTickTime() { 171 PP_TimeTicks GetTickTime() {
178 return TimeTicksToPPTimeTicks(base::TimeTicks::Now()); 172 return TimeTicksToPPTimeTicks(base::TimeTicks::Now());
179 } 173 }
180 174
181 void CallOnMainThread(int delay_in_msec, 175 void CallOnMainThread(int delay_in_msec,
182 PP_CompletionCallback callback, 176 PP_CompletionCallback callback,
183 int32_t result) { 177 int32_t result) {
184 if (callback.func) { 178 if (callback.func) {
185 GetMainThreadMessageLoop()->PostDelayedTask( 179 PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostDelayedTask(
186 FROM_HERE, 180 FROM_HERE,
187 base::Bind(callback.func, callback.user_data, result), 181 base::Bind(callback.func, callback.user_data, result),
188 base::TimeDelta::FromMilliseconds(delay_in_msec)); 182 base::TimeDelta::FromMilliseconds(delay_in_msec));
189 } 183 }
190 } 184 }
191 185
192 PP_Bool IsMainThread() { 186 PP_Bool IsMainThread() {
193 return BoolToPPBool(GetMainThreadMessageLoop()->BelongsToCurrentThread()); 187 return BoolToPPBool(PpapiGlobals::Get()->
188 GetMainThreadMessageLoop()->BelongsToCurrentThread());
194 } 189 }
195 190
196 const PPB_Core core_interface = { 191 const PPB_Core core_interface = {
197 &AddRefResource, 192 &AddRefResource,
198 &ReleaseResource, 193 &ReleaseResource,
199 &GetTime, 194 &GetTime,
200 &GetTickTime, 195 &GetTickTime,
201 &CallOnMainThread, 196 &CallOnMainThread,
202 &IsMainThread 197 &IsMainThread
203 }; 198 };
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 name_(name), 415 name_(name),
421 path_(path), 416 path_(path),
422 reserve_instance_id_(NULL), 417 reserve_instance_id_(NULL),
423 nacl_ipc_proxy_(false) { 418 nacl_ipc_proxy_(false) {
424 // Ensure the globals object is created. 419 // Ensure the globals object is created.
425 if (!host_globals) 420 if (!host_globals)
426 host_globals = new HostGlobals; 421 host_globals = new HostGlobals;
427 422
428 memset(&entry_points_, 0, sizeof(entry_points_)); 423 memset(&entry_points_, 0, sizeof(entry_points_));
429 pp_module_ = HostGlobals::Get()->AddModule(this); 424 pp_module_ = HostGlobals::Get()->AddModule(this);
430 GetMainThreadMessageLoop(); // Initialize the main thread message loop. 425 // Initialize the main thread message loop.
426 PpapiGlobals::Get()->GetMainThreadMessageLoop();
431 GetLivePluginSet()->insert(this); 427 GetLivePluginSet()->insert(this);
432 } 428 }
433 429
434 PluginModule::~PluginModule() { 430 PluginModule::~PluginModule() {
435 // In the past there have been crashes reentering the plugin module 431 // In the past there have been crashes reentering the plugin module
436 // destructor. Catch if that happens again earlier. 432 // destructor. Catch if that happens again earlier.
437 CHECK(!is_in_destructor_); 433 CHECK(!is_in_destructor_);
438 is_in_destructor_ = true; 434 is_in_destructor_ = true;
439 435
440 // When the module is being deleted, there should be no more instances still 436 // When the module is being deleted, there should be no more instances still
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 int retval = entry_points.initialize_module(pp_module(), &GetInterface); 612 int retval = entry_points.initialize_module(pp_module(), &GetInterface);
617 if (retval != 0) { 613 if (retval != 0) {
618 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; 614 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval;
619 return false; 615 return false;
620 } 616 }
621 return true; 617 return true;
622 } 618 }
623 619
624 } // namespace ppapi 620 } // namespace ppapi
625 } // namespace webkit 621 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/file_callbacks.cc ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698