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

Unified Diff: ppapi/examples/2d/paint_manager_example.cc

Issue 10909138: Convert the async device ID getter to a chrome resource host (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/examples/2d/paint_manager_example.cc
diff --git a/ppapi/examples/2d/paint_manager_example.cc b/ppapi/examples/2d/paint_manager_example.cc
index 86bdbe79ed8f9f2a8e820cd682f24c57cbb413d7..f85a2c24125c2e2d84a13ff9a454f2763d1ec4eb 100644
--- a/ppapi/examples/2d/paint_manager_example.cc
+++ b/ppapi/examples/2d/paint_manager_example.cc
@@ -8,8 +8,10 @@
#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/private/flash_device_id.h"
yzshen1 2012/09/11 00:53:17 I think you are not going to commit this file, rig
#include "ppapi/cpp/size.h"
#include "ppapi/cpp/view.h"
+#include "ppapi/utility/completion_callback_factory.h"
#include "ppapi/utility/graphics/paint_manager.h"
// Number of pixels to each side of the center of the square that we draw.
@@ -42,13 +44,27 @@ class MyInstance : public pp::Instance, public pp::PaintManager::Client {
paint_manager_(),
last_x_(0),
last_y_(0) {
+ factory_.Initialize(this);
+ device_id_ = pp::flash::DeviceID(this);
+
paint_manager_.Initialize(this, this, false);
RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
}
+ pp::CompletionCallbackFactory<MyInstance> factory_;
+ pp::flash::DeviceID device_id_;
+
+ void GotDeviceID(int32_t result, const pp::Var& id) {
+ std::string value = id.AsString();
+ value.append("");
+ }
+
virtual bool HandleInputEvent(const pp::InputEvent& event) {
switch (event.GetType()) {
case PP_INPUTEVENT_TYPE_MOUSEDOWN: {
+ device_id_.GetDeviceID(factory_.NewCallbackWithOutput(
+ &MyInstance::GotDeviceID));
+
pp::MouseInputEvent mouse_event(event);
// Update the square on a mouse down.
if (mouse_event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_LEFT) {

Powered by Google App Engine
This is Rietveld 408576698