OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 19 matching lines...) Expand all Loading... |
30 // Port1 is always even, port2 is always odd. | 30 // Port1 is always even, port2 is always odd. |
31 #define IS_OPENER_PORT_ID(port_id) (((port_id) & 1) == 0) | 31 #define IS_OPENER_PORT_ID(port_id) (((port_id) & 1) == 0) |
32 | 32 |
33 // Change even to odd and vice versa, to get the other side of a given channel. | 33 // Change even to odd and vice versa, to get the other side of a given channel. |
34 #define GET_OPPOSITE_PORT_ID(source_port_id) ((source_port_id) ^ 1) | 34 #define GET_OPPOSITE_PORT_ID(source_port_id) ((source_port_id) ^ 1) |
35 | 35 |
36 struct ExtensionMessageService::MessagePort { | 36 struct ExtensionMessageService::MessagePort { |
37 IPC::Message::Sender* sender; | 37 IPC::Message::Sender* sender; |
38 int routing_id; | 38 int routing_id; |
39 explicit MessagePort(IPC::Message::Sender* sender = NULL, | 39 explicit MessagePort(IPC::Message::Sender* sender = NULL, |
40 int routing_id = MSG_ROUTING_CONTROL) | 40 int routing_id = MSG_ROUTING_CONTROL) |
41 : sender(sender), routing_id(routing_id) {} | 41 : sender(sender), routing_id(routing_id) {} |
42 }; | 42 }; |
43 | 43 |
44 struct ExtensionMessageService::MessageChannel { | 44 struct ExtensionMessageService::MessageChannel { |
45 ExtensionMessageService::MessagePort opener; | 45 ExtensionMessageService::MessagePort opener; |
46 ExtensionMessageService::MessagePort receiver; | 46 ExtensionMessageService::MessagePort receiver; |
47 }; | 47 }; |
48 | 48 |
49 const char ExtensionMessageService::kDispatchOnConnect[] = | 49 const char ExtensionMessageService::kDispatchOnConnect[] = |
50 "Port.dispatchOnConnect"; | 50 "Port.dispatchOnConnect"; |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 356 |
357 if (current->second->opener.sender == sender) { | 357 if (current->second->opener.sender == sender) { |
358 CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first), | 358 CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first), |
359 notify_other_port); | 359 notify_other_port); |
360 } else if (current->second->receiver.sender == sender) { | 360 } else if (current->second->receiver.sender == sender) { |
361 CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first), | 361 CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first), |
362 notify_other_port); | 362 notify_other_port); |
363 } | 363 } |
364 } | 364 } |
365 } | 365 } |
OLD | NEW |