Memory leaks during re-creating NaCl modules

This patch fixes one of three memory leaks found when page reloads
NaCl module(s).

In PepperPluginInstanceImpl ctor
FrameHostMsg_DidCreateInProcessInstance message is sent to browser
process, however message FrameHostMsg_DidDeleteInProcessInstance
isn't sent from dtor.  This is because PepperPluginInstanceImpl
is created for unproxied module and later reinitialized as proxied
one, which causes that
PepperBrowserConnection::DidCreateInProcessInstance method is
called in PepperPluginInstanceImpl ctor, however
PepperBrowserConnection::DidDeleteInProcessInstance isn't called in
PepperPluginInstanceImpl dtor.

Bug: 922925
Change-Id: Ifb80108a99f591e7d30ec8013e94cef6d176eca3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1679692
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689031}
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc
index 6ed65a0..6474efe 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc
@@ -540,6 +540,7 @@
       isolate_(v8::Isolate::GetCurrent()),
       is_deleted_(false),
       initialized_(false),
+      created_in_process_instance_(false),
       audio_controller_(std::make_unique<PepperAudioController>(this)) {
   pp_instance_ = HostGlobals::Get()->AddInstance(this);
 
@@ -555,6 +556,7 @@
     SetContentAreaFocus(render_frame_->GetLocalRootRenderWidget()->has_focus());
 
     if (!module_->IsProxied()) {
+      created_in_process_instance_ = true;
       PepperBrowserConnection* browser_connection =
           PepperBrowserConnection::Get(render_frame_);
       browser_connection->DidCreateInProcessInstance(
@@ -600,7 +602,7 @@
   if (render_frame_)
     render_frame_->PepperInstanceDeleted(this);
 
-  if (!module_->IsProxied() && render_frame_) {
+  if (created_in_process_instance_) {
     PepperBrowserConnection* browser_connection =
         PepperBrowserConnection::Get(render_frame_);
     browser_connection->DidDeleteInProcessInstance(pp_instance());
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.h b/content/renderer/pepper/pepper_plugin_instance_impl.h
index 28b65dd6..a348280 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.h
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.h
@@ -913,6 +913,7 @@
   std::vector<MailboxRefCount> texture_ref_counts_;
 
   bool initialized_;
+  bool created_in_process_instance_;
 
   // The controller for all active audios of this pepper instance.
   std::unique_ptr<PepperAudioController> audio_controller_;