| Index: content/browser/shared_worker/shared_worker_host.cc
|
| diff --git a/content/browser/shared_worker/shared_worker_host.cc b/content/browser/shared_worker/shared_worker_host.cc
|
| index d3f4e1d711748d28ce68c6e7be3db250fa5a5527..f392a2ceb372a6189efeec117ec435ceb08574f0 100644
|
| --- a/content/browser/shared_worker/shared_worker_host.cc
|
| +++ b/content/browser/shared_worker/shared_worker_host.cc
|
| @@ -75,12 +75,10 @@ SharedWorkerHost::~SharedWorkerHost() {
|
| worker_process_id_, worker_route_id_);
|
| }
|
|
|
| -bool SharedWorkerHost::Send(IPC::Message* message) {
|
| - if (!container_render_filter_) {
|
| - delete message;
|
| +bool SharedWorkerHost::Send(std::unique_ptr<IPC::Message> message) {
|
| + if (!container_render_filter_)
|
| return false;
|
| - }
|
| - return container_render_filter_->Send(message);
|
| + return container_render_filter_->Send(message.release());
|
| }
|
|
|
| void SharedWorkerHost::Start(bool pause_on_start) {
|
| @@ -92,12 +90,10 @@ void SharedWorkerHost::Start(bool pause_on_start) {
|
| params.creation_address_space = instance_->creation_address_space();
|
| params.pause_on_start = pause_on_start;
|
| params.route_id = worker_route_id_;
|
| - Send(new WorkerProcessMsg_CreateWorker(params));
|
| + Send(base::MakeUnique<WorkerProcessMsg_CreateWorker>(params));
|
|
|
| - for (FilterList::const_iterator i = filters_.begin(); i != filters_.end();
|
| - ++i) {
|
| - i->filter()->Send(new ViewMsg_WorkerCreated(i->route_id()));
|
| - }
|
| + for (const FilterInfo& info : filters_)
|
| + info.filter()->Send(new ViewMsg_WorkerCreated(info.route_id()));
|
| }
|
|
|
| bool SharedWorkerHost::FilterMessage(const IPC::Message& message,
|
| @@ -177,20 +173,17 @@ void SharedWorkerHost::WorkerScriptLoadFailed() {
|
| base::TimeTicks::Now() - creation_time_);
|
| if (!instance_)
|
| return;
|
| - for (FilterList::const_iterator i = filters_.begin(); i != filters_.end();
|
| - ++i) {
|
| - i->filter()->Send(new ViewMsg_WorkerScriptLoadFailed(i->route_id()));
|
| - }
|
| + for (const FilterInfo& info : filters_)
|
| + info.filter()->Send(new ViewMsg_WorkerScriptLoadFailed(info.route_id()));
|
| }
|
|
|
| void SharedWorkerHost::WorkerConnected(int message_port_id) {
|
| if (!instance_)
|
| return;
|
| - for (FilterList::const_iterator i = filters_.begin(); i != filters_.end();
|
| - ++i) {
|
| - if (i->message_port_id() != message_port_id)
|
| + for (const FilterInfo& info : filters_) {
|
| + if (info.message_port_id() != message_port_id)
|
| continue;
|
| - i->filter()->Send(new ViewMsg_WorkerConnected(i->route_id()));
|
| + info.filter()->Send(new ViewMsg_WorkerConnected(info.route_id()));
|
| return;
|
| }
|
| }
|
| @@ -215,7 +208,7 @@ void SharedWorkerHost::AllowFileSystemResponse(
|
| WorkerProcessHostMsg_RequestFileSystemAccessSync::WriteReplyParams(
|
| reply_msg.get(),
|
| allowed);
|
| - Send(reply_msg.release());
|
| + Send(std::move(reply_msg));
|
| }
|
|
|
| void SharedWorkerHost::AllowIndexedDB(const GURL& url,
|
| @@ -249,16 +242,17 @@ void SharedWorkerHost::RelayMessage(
|
| SetMessagePortID(
|
| incoming_filter, message.routing_id(), sent_message_port_id);
|
| // Resend the message with the new routing id.
|
| - Send(new WorkerMsg_Connect(
|
| + Send(base::MakeUnique<WorkerMsg_Connect>(
|
| worker_route_id_, sent_message_port_id, new_routing_id));
|
|
|
| // Send any queued messages for the sent port.
|
| MessagePortService::GetInstance()->SendQueuedMessagesIfPossible(
|
| sent_message_port_id);
|
| } else {
|
| - IPC::Message* new_message = new IPC::Message(message);
|
| + std::unique_ptr<IPC::Message> new_message =
|
| + base::MakeUnique<IPC::Message>(message);
|
| new_message->set_routing_id(worker_route_id_);
|
| - Send(new_message);
|
| + Send(std::move(new_message));
|
| return;
|
| }
|
| }
|
| @@ -267,7 +261,7 @@ void SharedWorkerHost::TerminateWorker() {
|
| termination_message_sent_ = true;
|
| if (!closed_)
|
| NotifyWorkerDestroyed(worker_process_id_, worker_route_id_);
|
| - Send(new WorkerMsg_TerminateWorkerContext(worker_route_id_));
|
| + Send(base::MakeUnique<WorkerMsg_TerminateWorkerContext>(worker_route_id_));
|
| }
|
|
|
| std::vector<std::pair<int, int> >
|
| @@ -277,12 +271,9 @@ SharedWorkerHost::GetRenderFrameIDsForWorker() {
|
| return result;
|
| const WorkerDocumentSet::DocumentInfoSet& documents =
|
| worker_document_set_->documents();
|
| - for (WorkerDocumentSet::DocumentInfoSet::const_iterator doc =
|
| - documents.begin();
|
| - doc != documents.end();
|
| - ++doc) {
|
| + for (const WorkerDocumentSet::DocumentInfo& doc : documents) {
|
| result.push_back(
|
| - std::make_pair(doc->render_process_id(), doc->render_frame_id()));
|
| + std::make_pair(doc.render_process_id(), doc.render_frame_id()));
|
| }
|
| return result;
|
| }
|
|
|