| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_message_service.h" | 5 #include "chrome/browser/extensions/extension_message_service.h" |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 const content::NotificationDetails& details) { | 352 const content::NotificationDetails& details) { |
| 353 switch (type) { | 353 switch (type) { |
| 354 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: | 354 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: |
| 355 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { | 355 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { |
| 356 content::RenderProcessHost* renderer = | 356 content::RenderProcessHost* renderer = |
| 357 content::Source<content::RenderProcessHost>(source).ptr(); | 357 content::Source<content::RenderProcessHost>(source).ptr(); |
| 358 OnSenderClosed(renderer); | 358 OnSenderClosed(renderer); |
| 359 break; | 359 break; |
| 360 } | 360 } |
| 361 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: | 361 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: |
| 362 OnSenderClosed(content::Source<RenderViewHost>(source).ptr()); | 362 OnSenderClosed(content::Source<content::RenderViewHost>(source).ptr()); |
| 363 break; | 363 break; |
| 364 default: | 364 default: |
| 365 NOTREACHED(); | 365 NOTREACHED(); |
| 366 return; | 366 return; |
| 367 } | 367 } |
| 368 } | 368 } |
| 369 | 369 |
| 370 void ExtensionMessageService::OnSenderClosed(IPC::Message::Sender* sender) { | 370 void ExtensionMessageService::OnSenderClosed(IPC::Message::Sender* sender) { |
| 371 // Close any channels that share this renderer. We notify the opposite | 371 // Close any channels that share this renderer. We notify the opposite |
| 372 // port that his pair has closed. | 372 // port that his pair has closed. |
| 373 for (MessageChannelMap::iterator it = channels_.begin(); | 373 for (MessageChannelMap::iterator it = channels_.begin(); |
| 374 it != channels_.end(); ) { | 374 it != channels_.end(); ) { |
| 375 MessageChannelMap::iterator current = it++; | 375 MessageChannelMap::iterator current = it++; |
| 376 // If both sides are the same renderer, and it is closing, there is no | 376 // If both sides are the same renderer, and it is closing, there is no |
| 377 // "other" port, so there's no need to notify it. | 377 // "other" port, so there's no need to notify it. |
| 378 bool notify_other_port = | 378 bool notify_other_port = |
| 379 current->second->opener.sender != current->second->receiver.sender; | 379 current->second->opener.sender != current->second->receiver.sender; |
| 380 | 380 |
| 381 if (current->second->opener.sender == sender) { | 381 if (current->second->opener.sender == sender) { |
| 382 CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first), | 382 CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first), |
| 383 notify_other_port); | 383 notify_other_port); |
| 384 } else if (current->second->receiver.sender == sender) { | 384 } else if (current->second->receiver.sender == sender) { |
| 385 CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first), | 385 CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first), |
| 386 notify_other_port); | 386 notify_other_port); |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 } | 389 } |
| OLD | NEW |