summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authortommycli <tommycli@chromium.org>2015-06-15 11:10:18 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-15 18:11:01 +0000
commit0a9a5fe4acc84f82314cc7e74f10a3c4348ff0c2 (patch)
treecf3325fff26a54db744b3c56eed0062735044f94 /ppapi
parentf08cb003ea22c8c126279a8de1ac604e4dd13b0f (diff)
downloadchromium_src-0a9a5fe4acc84f82314cc7e74f10a3c4348ff0c2.zip
chromium_src-0a9a5fe4acc84f82314cc7e74f10a3c4348ff0c2.tar.gz
chromium_src-0a9a5fe4acc84f82314cc7e74f10a3c4348ff0c2.tar.bz2
Plugin Power Saver: Fix Dr. Memory leaks in browser tests.
Power Saver Test Plugin triggers Dr. Memory leaks under Windows. Most likely because the test process is destroyed before the out of process test plugin has a chance to free its Pepper resources (an image data). This is because the test plugin is trying to draw new frames as fast as it possibly can. There's no reason for the test plugin to draw so many frames. In fact, it only needs one. Changing the test plugin to draw only one frame fixes the issue for me (locally). BUG=487492 Review URL: https://codereview.chromium.org/1182283002 Cr-Commit-Position: refs/heads/master@{#334407}
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/examples/gamepad/gamepad.cc3
-rw-r--r--ppapi/tests/power_saver_test_plugin.cc13
2 files changed, 9 insertions, 7 deletions
diff --git a/ppapi/examples/gamepad/gamepad.cc b/ppapi/examples/gamepad/gamepad.cc
index d2b0884..bfac65a 100644
--- a/ppapi/examples/gamepad/gamepad.cc
+++ b/ppapi/examples/gamepad/gamepad.cc
@@ -69,6 +69,8 @@ class MyInstance : public pp::Instance {
}
void OnFlush(int32_t) {
+ // This plugin continuously paints because it continously samples the
+ // gamepad and paints its updated state.
Paint();
}
@@ -145,4 +147,3 @@ Module* CreateModule() {
}
} // namespace pp
-
diff --git a/ppapi/tests/power_saver_test_plugin.cc b/ppapi/tests/power_saver_test_plugin.cc
index 44aef4d..521fafa 100644
--- a/ppapi/tests/power_saver_test_plugin.cc
+++ b/ppapi/tests/power_saver_test_plugin.cc
@@ -15,11 +15,14 @@
#undef PostMessage
#endif
+static void DummyCompletionCallback(void*, int32_t) {
+}
+
// This is a simple C++ Pepper plugin that enables Plugin Power Saver tests.
class PowerSaverTestInstance : public pp::Instance {
public:
explicit PowerSaverTestInstance(PP_Instance instance)
- : pp::Instance(instance), callback_factory_(this) {}
+ : pp::Instance(instance) {}
~PowerSaverTestInstance() override {}
bool Init(uint32_t argc, const char* argn[], const char* argv[]) {
@@ -42,11 +45,11 @@ class PowerSaverTestInstance : public pp::Instance {
if (!BindGraphics(device_context_))
return;
+ // Since we draw a static image, we only need to make a new frame when
+ // the device is initialized or the view size changes.
Paint();
}
- void OnFlush(int32_t) { Paint(); }
-
private:
void Paint() {
pp::ImageData image(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
@@ -64,13 +67,11 @@ class PowerSaverTestInstance : public pp::Instance {
device_context_.ReplaceContents(&image);
device_context_.Flush(
- callback_factory_.NewCallback(&PowerSaverTestInstance::OnFlush));
+ pp::CompletionCallback(&DummyCompletionCallback, nullptr));
}
pp::View view_;
pp::Graphics2D device_context_;
-
- pp::CompletionCallbackFactory<PowerSaverTestInstance> callback_factory_;
};
class PowerSaverTestModule : public pp::Module {