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

Unified Diff: mojo/examples/pepper_container_app/pepper_container_app.cc

Issue 607233002: Nukes NativeViewportClient::OnCreated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build Created 6 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
« no previous file with comments | « mojo/examples/compositor_app/compositor_app.cc ('k') | mojo/examples/sample_app/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/examples/pepper_container_app/pepper_container_app.cc
diff --git a/mojo/examples/pepper_container_app/pepper_container_app.cc b/mojo/examples/pepper_container_app/pepper_container_app.cc
index c5f509f080a7b8c29b4db5191d63653caddd9e82..b743f1766d447f5b9702a92ebc3954e3176e604a 100644
--- a/mojo/examples/pepper_container_app/pepper_container_app.cc
+++ b/mojo/examples/pepper_container_app/pepper_container_app.cc
@@ -5,6 +5,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "build/build_config.h"
#include "mojo/application/application_runner_chromium.h"
@@ -29,9 +30,10 @@ class PepperContainerApp: public ApplicationDelegate,
public NativeViewportClient,
public MojoPpapiGlobals::Delegate {
public:
- explicit PepperContainerApp()
+ PepperContainerApp()
: ppapi_globals_(this),
- plugin_module_(new PluginModule) {}
+ plugin_module_(new PluginModule),
+ weak_factory_(this) {}
virtual ~PepperContainerApp() {}
@@ -45,20 +47,13 @@ class PepperContainerApp: public ApplicationDelegate,
SizePtr size(Size::New());
size->width = 800;
size->height = 600;
- viewport_->Create(size.Pass());
+ viewport_->Create(size.Pass(),
+ base::Bind(&PepperContainerApp::OnCreatedNativeViewport,
+ weak_factory_.GetWeakPtr()));
viewport_->Show();
}
// NativeViewportClient implementation.
- virtual void OnCreated(uint64_t native_viewport_id) OVERRIDE {
- native_viewport_id_ = native_viewport_id;
- ppapi::ProxyAutoLock lock;
-
- plugin_instance_ = plugin_module_->CreateInstance().Pass();
- if (!plugin_instance_->DidCreate())
- plugin_instance_.reset();
- }
-
virtual void OnDestroyed() OVERRIDE {
ppapi::ProxyAutoLock lock;
@@ -70,11 +65,13 @@ class PepperContainerApp: public ApplicationDelegate,
base::MessageLoop::current()->Quit();
}
- virtual void OnBoundsChanged(SizePtr bounds) OVERRIDE {
+ virtual void OnSizeChanged(SizePtr size) OVERRIDE {
ppapi::ProxyAutoLock lock;
- if (plugin_instance_)
- plugin_instance_->DidChangeView(bounds.To<PP_Rect>());
+ if (plugin_instance_) {
+ PP_Rect pp_rect = {{0, 0}, {size->width, size->height}};
+ plugin_instance_->DidChangeView(pp_rect);
+ }
}
virtual void OnEvent(EventPtr event,
@@ -100,6 +97,15 @@ class PepperContainerApp: public ApplicationDelegate,
}
private:
+ void OnCreatedNativeViewport(uint64_t native_viewport_id) {
+ native_viewport_id_ = native_viewport_id;
+ ppapi::ProxyAutoLock lock;
+
+ plugin_instance_ = plugin_module_->CreateInstance().Pass();
+ if (!plugin_instance_->DidCreate())
+ plugin_instance_.reset();
+ }
+
MojoPpapiGlobals ppapi_globals_;
uint64_t native_viewport_id_;
@@ -108,6 +114,8 @@ class PepperContainerApp: public ApplicationDelegate,
scoped_refptr<PluginModule> plugin_module_;
scoped_ptr<PluginInstance> plugin_instance_;
+ base::WeakPtrFactory<PepperContainerApp> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(PepperContainerApp);
};
« no previous file with comments | « mojo/examples/compositor_app/compositor_app.cc ('k') | mojo/examples/sample_app/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698