OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/glue/plugins/pepper_plugin_module.h" | 5 #include "webkit/glue/plugins/pepper_plugin_module.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop.h" |
10 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
13 #include "base/time.h" | 14 #include "base/time.h" |
14 #include "third_party/ppapi/c/ppb_core.h" | 15 #include "third_party/ppapi/c/ppb_core.h" |
15 #include "third_party/ppapi/c/ppb_device_context_2d.h" | 16 #include "third_party/ppapi/c/ppb_device_context_2d.h" |
16 #include "third_party/ppapi/c/ppb_image_data.h" | 17 #include "third_party/ppapi/c/ppb_image_data.h" |
17 #include "third_party/ppapi/c/ppb_instance.h" | 18 #include "third_party/ppapi/c/ppb_instance.h" |
18 #include "third_party/ppapi/c/ppb_testing.h" | 19 #include "third_party/ppapi/c/ppb_testing.h" |
19 #include "third_party/ppapi/c/ppb_var.h" | 20 #include "third_party/ppapi/c/ppb_var.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 bool ReadImageData(PP_Resource device_context_2d, | 104 bool ReadImageData(PP_Resource device_context_2d, |
104 PP_Resource image, | 105 PP_Resource image, |
105 int32_t x, int32_t y) { | 106 int32_t x, int32_t y) { |
106 scoped_refptr<DeviceContext2D> context( | 107 scoped_refptr<DeviceContext2D> context( |
107 ResourceTracker::Get()->GetAsDeviceContext2D(device_context_2d)); | 108 ResourceTracker::Get()->GetAsDeviceContext2D(device_context_2d)); |
108 if (!context.get()) | 109 if (!context.get()) |
109 return false; | 110 return false; |
110 return context->ReadImageData(image, x, y); | 111 return context->ReadImageData(image, x, y); |
111 } | 112 } |
112 | 113 |
| 114 void RunMessageLoop() { |
| 115 bool old_state = MessageLoop::current()->NestableTasksAllowed(); |
| 116 MessageLoop::current()->SetNestableTasksAllowed(true); |
| 117 MessageLoop::current()->Run(); |
| 118 MessageLoop::current()->SetNestableTasksAllowed(old_state); |
| 119 } |
| 120 |
| 121 void QuitMessageLoop() { |
| 122 MessageLoop::current()->Quit(); |
| 123 } |
| 124 |
113 const PPB_Testing testing_interface = { | 125 const PPB_Testing testing_interface = { |
114 &ReadImageData | 126 &ReadImageData, |
| 127 &RunMessageLoop, |
| 128 &QuitMessageLoop, |
115 }; | 129 }; |
116 | 130 |
117 // GetInterface ---------------------------------------------------------------- | 131 // GetInterface ---------------------------------------------------------------- |
118 | 132 |
119 const void* GetInterface(const char* name) { | 133 const void* GetInterface(const char* name) { |
120 if (strcmp(name, PPB_CORE_INTERFACE) == 0) | 134 if (strcmp(name, PPB_CORE_INTERFACE) == 0) |
121 return &core_interface; | 135 return &core_interface; |
122 if (strcmp(name, PPB_VAR_INTERFACE) == 0) | 136 if (strcmp(name, PPB_VAR_INTERFACE) == 0) |
123 return GetVarInterface(); | 137 return GetVarInterface(); |
124 if (strcmp(name, PPB_INSTANCE_INTERFACE) == 0) | 138 if (strcmp(name, PPB_INSTANCE_INTERFACE) == 0) |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 267 |
254 void PluginModule::InstanceCreated(PluginInstance* instance) { | 268 void PluginModule::InstanceCreated(PluginInstance* instance) { |
255 instances_.insert(instance); | 269 instances_.insert(instance); |
256 } | 270 } |
257 | 271 |
258 void PluginModule::InstanceDeleted(PluginInstance* instance) { | 272 void PluginModule::InstanceDeleted(PluginInstance* instance) { |
259 instances_.erase(instance); | 273 instances_.erase(instance); |
260 } | 274 } |
261 | 275 |
262 } // namespace pepper | 276 } // namespace pepper |
OLD | NEW |