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

Unified Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 2426423004: Remove some linked_ptr from /content (Closed)
Patch Set: return owned pointer Created 4 years, 2 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: content/browser/browser_plugin/browser_plugin_guest.cc
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index bcb8464383290287d0f6998aa759a6589b3020f2..d7624f45a9f15b5bdb26fbc55fe79ca151af8ebe 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -9,6 +9,7 @@
#include <algorithm>
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/pickle.h"
#include "base/strings/utf_string_conversions.h"
@@ -217,8 +218,8 @@ void BrowserPluginGuest::SetTooltipText(const base::string16& tooltip_text) {
return;
current_tooltip_text_ = tooltip_text;
- SendMessageToEmbedder(new BrowserPluginMsg_SetTooltipText(
- browser_plugin_instance_id_, tooltip_text));
+ SendMessageToEmbedder(base::WrapUnique(new BrowserPluginMsg_SetTooltipText(
Avi (use Gerrit) 2016/10/20 15:08:12 SendMessageToEmbedder(base::MakeUnique<BrowserPlug
limasdf 2016/10/20 15:56:19 Done.
+ browser_plugin_instance_id_, tooltip_text)));
}
bool BrowserPluginGuest::LockMouse(bool allowed) {
@@ -393,8 +394,8 @@ void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) {
}
void BrowserPluginGuest::PointerLockPermissionResponse(bool allow) {
- SendMessageToEmbedder(
- new BrowserPluginMsg_SetMouseLock(browser_plugin_instance_id(), allow));
+ SendMessageToEmbedder(base::WrapUnique(
+ new BrowserPluginMsg_SetMouseLock(browser_plugin_instance_id(), allow)));
Avi (use Gerrit) 2016/10/20 15:08:12 base::MakeUnique here too
limasdf 2016/10/20 15:56:19 Done.
}
void BrowserPluginGuest::SetChildFrameSurface(
@@ -403,9 +404,10 @@ void BrowserPluginGuest::SetChildFrameSurface(
float scale_factor,
const cc::SurfaceSequence& sequence) {
has_attached_since_surface_set_ = false;
- SendMessageToEmbedder(new BrowserPluginMsg_SetChildFrameSurface(
- browser_plugin_instance_id(), surface_id, frame_size, scale_factor,
- sequence));
+ SendMessageToEmbedder(
+ base::WrapUnique(new BrowserPluginMsg_SetChildFrameSurface(
Avi (use Gerrit) 2016/10/20 15:08:12 base::MakeUnique here too
limasdf 2016/10/20 15:56:19 Done.
+ browser_plugin_instance_id(), surface_id, frame_size, scale_factor,
+ sequence)));
}
void BrowserPluginGuest::OnSatisfySequence(
@@ -492,7 +494,8 @@ gfx::Point BrowserPluginGuest::GetScreenCoordinates(
return screen_pos;
}
-void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
+void BrowserPluginGuest::SendMessageToEmbedder(
+ std::unique_ptr<IPC::Message> msg) {
// During tests, attache() may be true when there is no owner_web_contents_;
// in this case just queue any messages we receive.
if (!attached() || !owner_web_contents_) {
@@ -501,10 +504,10 @@ void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
// As a result, we must save all these IPCs until attachment and then
// forward them so that the embedder gets a chance to see and process
// the load events.
- pending_messages_.push_back(linked_ptr<IPC::Message>(msg));
+ pending_messages_.push_back(std::move(msg));
return;
}
- owner_web_contents_->Send(msg);
+ owner_web_contents_->Send(msg.release());
}
void BrowserPluginGuest::DragSourceEndedAt(int client_x, int client_y,
@@ -555,12 +558,12 @@ void BrowserPluginGuest::EmbedderSystemDragEnded() {
// TODO(wjmaclean): Replace this approach with ones based on std::function
// as in https://codereview.chromium.org/1404353004/ once all Chrome platforms
// support this. https://crbug.com/544212
-IPC::Message* BrowserPluginGuest::UpdateInstanceIdIfNecessary(
- IPC::Message* msg) const {
- DCHECK(msg);
+std::unique_ptr<IPC::Message> BrowserPluginGuest::UpdateInstanceIdIfNecessary(
+ std::unique_ptr<IPC::Message> msg) const {
+ DCHECK(msg.get());
int msg_browser_plugin_instance_id = browser_plugin::kInstanceIDNone;
- base::PickleIterator iter(*msg);
+ base::PickleIterator iter(*msg.get());
if (!iter.ReadInt(&msg_browser_plugin_instance_id) ||
msg_browser_plugin_instance_id != browser_plugin::kInstanceIDNone) {
return msg;
@@ -588,8 +591,7 @@ IPC::Message* BrowserPluginGuest::UpdateInstanceIdIfNecessary(
CHECK(write_success)
<< "Unexpected failure writing remaining IPC::Message payload.";
- delete msg;
- return new_msg.release();
+ return new_msg;
}
void BrowserPluginGuest::SendQueuedMessages() {
@@ -597,10 +599,10 @@ void BrowserPluginGuest::SendQueuedMessages() {
return;
while (!pending_messages_.empty()) {
- linked_ptr<IPC::Message> message_ptr = pending_messages_.front();
+ std::unique_ptr<IPC::Message> message_ptr =
+ std::move(pending_messages_.front());
pending_messages_.pop_front();
- SendMessageToEmbedder(
- UpdateInstanceIdIfNecessary(message_ptr.release()));
+ SendMessageToEmbedder(UpdateInstanceIdIfNecessary(std::move(message_ptr)));
}
}
@@ -643,8 +645,8 @@ void BrowserPluginGuest::RenderViewReady() {
// associated BrowserPlugin know. We only need to send this if we're attached,
// as guest_crashed_ is cleared automatically on attach anyways.
if (attached()) {
- SendMessageToEmbedder(
- new BrowserPluginMsg_GuestReady(browser_plugin_instance_id()));
+ SendMessageToEmbedder(base::WrapUnique(
+ new BrowserPluginMsg_GuestReady(browser_plugin_instance_id())));
Avi (use Gerrit) 2016/10/20 15:08:12 MakeUnique
limasdf 2016/10/20 15:56:19 Done.
}
RenderWidgetHostImpl::From(rvh->GetWidget())
@@ -653,8 +655,8 @@ void BrowserPluginGuest::RenderViewReady() {
}
void BrowserPluginGuest::RenderProcessGone(base::TerminationStatus status) {
- SendMessageToEmbedder(
- new BrowserPluginMsg_GuestGone(browser_plugin_instance_id()));
+ SendMessageToEmbedder(base::WrapUnique(
+ new BrowserPluginMsg_GuestGone(browser_plugin_instance_id())));
Avi (use Gerrit) 2016/10/20 15:08:12 MakeUnique
limasdf 2016/10/20 15:56:20 Done.
switch (status) {
#if defined(OS_CHROMEOS)
case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM:
@@ -955,8 +957,8 @@ void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id,
}
void BrowserPluginGuest::OnUnlockMouse() {
- SendMessageToEmbedder(
- new BrowserPluginMsg_SetMouseLock(browser_plugin_instance_id(), false));
+ SendMessageToEmbedder(base::WrapUnique(
+ new BrowserPluginMsg_SetMouseLock(browser_plugin_instance_id(), false)));
Avi (use Gerrit) 2016/10/20 15:08:12 MakeUnique
limasdf 2016/10/20 15:56:19 Done.
}
void BrowserPluginGuest::OnUnlockMouseAck(int browser_plugin_instance_id) {
@@ -978,8 +980,8 @@ void BrowserPluginGuest::OnUpdateGeometry(int browser_plugin_instance_id,
void BrowserPluginGuest::OnHasTouchEventHandlers(bool accept) {
SendMessageToEmbedder(
- new BrowserPluginMsg_ShouldAcceptTouchEvents(
- browser_plugin_instance_id(), accept));
+ base::WrapUnique(new BrowserPluginMsg_ShouldAcceptTouchEvents(
+ browser_plugin_instance_id(), accept)));
Avi (use Gerrit) 2016/10/20 15:08:12 MakeUnique
limasdf 2016/10/20 15:56:19 Done.
}
#if defined(OS_MACOSX)
@@ -1007,8 +1009,8 @@ void BrowserPluginGuest::OnShowWidget(int route_id,
}
void BrowserPluginGuest::OnTakeFocus(bool reverse) {
- SendMessageToEmbedder(
- new BrowserPluginMsg_AdvanceFocus(browser_plugin_instance_id(), reverse));
+ SendMessageToEmbedder(base::WrapUnique(new BrowserPluginMsg_AdvanceFocus(
Avi (use Gerrit) 2016/10/20 15:08:12 MakeUnique
limasdf 2016/10/20 15:56:19 Done.
+ browser_plugin_instance_id(), reverse)));
}
void BrowserPluginGuest::OnTextInputStateChanged(const TextInputState& params) {

Powered by Google App Engine
This is Rietveld 408576698