Remove unused IPC::Message priority.
Removes the PriorityValue enum and field from IPC::Message. This doesn't appear to be used anywhere. Changes the data message ctor to take a size_t data_len parameter. This works around an ambiguity problem with the main ctor, which has a similar signature and would require lots of futzing with our test code to fix. To make this work, the matching Pickle constructor is also changed to take a size_t data_len parameter. BUG=194304 Review URL: https://codereview.chromium.org/35643005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231330 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
base
chrome/browser
automation
spellchecker
cloud_print/service/win
components/nacl/loader
content
browser
renderer_host
common
ipc
ipc_channel_posix.ccipc_channel_posix_unittest.ccipc_channel_unittest.ccipc_channel_win.ccipc_fuzzing_tests.ccipc_logging.ccipc_message.ccipc_message.hipc_message_macros.hipc_message_unittest.ccipc_message_utils_unittest.ccipc_perftests.ccipc_send_fds_test.ccipc_sync_message.ccipc_sync_message.h
ppapi
@ -170,15 +170,15 @@ Pickle::Pickle(int header_size)
|
||||
header_->payload_size = 0;
|
||||
}
|
||||
|
||||
Pickle::Pickle(const char* data, int data_len)
|
||||
Pickle::Pickle(const char* data, size_t data_len)
|
||||
: header_(reinterpret_cast<Header*>(const_cast<char*>(data))),
|
||||
header_size_(0),
|
||||
capacity_(kCapacityReadOnly),
|
||||
variable_buffer_offset_(0) {
|
||||
if (data_len >= static_cast<int>(sizeof(Header)))
|
||||
if (data_len >= sizeof(Header))
|
||||
header_size_ = data_len - header_->payload_size;
|
||||
|
||||
if (header_size_ > static_cast<unsigned int>(data_len))
|
||||
if (header_size_ > data_len)
|
||||
header_size_ = 0;
|
||||
|
||||
if (header_size_ != AlignInt(header_size_, sizeof(uint32)))
|
||||
|
@ -114,7 +114,7 @@ class BASE_EXPORT Pickle {
|
||||
// instead the data is merely referenced by this Pickle. Only const methods
|
||||
// should be used on the Pickle when initialized this way. The header
|
||||
// padding size is deduced from the data length.
|
||||
Pickle(const char* data, int data_len);
|
||||
Pickle(const char* data, size_t data_len);
|
||||
|
||||
// Initializes a Pickle as a deep copy of another Pickle.
|
||||
Pickle(const Pickle& other);
|
||||
|
@ -35,7 +35,7 @@ TEST_F(AutomationProviderTest, TestInvalidChromeFrameMessage) {
|
||||
base::MessageLoop message_loop;
|
||||
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
|
||||
|
||||
IPC::Message bad_msg(1, -1, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message bad_msg(1, -1);
|
||||
|
||||
scoped_refptr<MockChromeFrameAutomationProvider>
|
||||
mock(new MockChromeFrameAutomationProvider(NULL));
|
||||
|
@ -52,8 +52,7 @@ TEST(SpellCheckMessageFilterMacTest, TestOverrideThread) {
|
||||
content::BrowserThread::ID thread;
|
||||
IPC::Message message;
|
||||
for (size_t i = 0; i < arraysize(kSpellcheckMessages); ++i) {
|
||||
message.SetHeaderValues(
|
||||
0, kSpellcheckMessages[i], IPC::Message::PRIORITY_NORMAL);
|
||||
message.SetHeaderValues(0, kSpellcheckMessages[i], 0 /* flags */);
|
||||
thread = content::BrowserThread::IO;
|
||||
filter->OverrideThreadForMessage(message, &thread);
|
||||
EXPECT_EQ(content::BrowserThread::UI, thread);
|
||||
|
@ -66,8 +66,7 @@ TEST(SpellCheckMessageFilterTest, TestOverrideThread) {
|
||||
scoped_refptr<TestingSpellCheckMessageFilter> filter(
|
||||
new TestingSpellCheckMessageFilter);
|
||||
for (size_t i = 0; i < arraysize(kSpellcheckMessages); ++i) {
|
||||
message.SetHeaderValues(
|
||||
0, kSpellcheckMessages[i], IPC::Message::PRIORITY_NORMAL);
|
||||
message.SetHeaderValues(0, kSpellcheckMessages[i], 0 /* flags */);
|
||||
thread = content::BrowserThread::IO;
|
||||
filter->OverrideThreadForMessage(message, &thread);
|
||||
EXPECT_EQ(content::BrowserThread::UI, thread);
|
||||
|
@ -75,7 +75,7 @@ bool ServiceListener::OnMessageReceived(const IPC::Message& msg) {
|
||||
}
|
||||
|
||||
void ServiceListener::OnChannelConnected(int32 peer_pid) {
|
||||
IPC::Message* message = new IPC::Message(0, 0, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message* message = new IPC::Message(0, 0);
|
||||
message->WriteString(GetEnvironment(user_data_dir_));
|
||||
channel_->Send(message);
|
||||
}
|
||||
|
@ -515,8 +515,7 @@ bool NaClIPCAdapter::SendCompleteMessage(const char* buffer,
|
||||
// We actually discard the flags and only copy the ones we care about. This
|
||||
// is just because message doesn't have a constructor that takes raw flags.
|
||||
scoped_ptr<IPC::Message> msg(
|
||||
new IPC::Message(header->routing, header->type,
|
||||
IPC::Message::PRIORITY_NORMAL));
|
||||
new IPC::Message(header->routing, header->type));
|
||||
if (header->flags & IPC::Message::SYNC_BIT)
|
||||
msg->set_sync();
|
||||
if (header->flags & IPC::Message::REPLY_BIT)
|
||||
|
@ -75,7 +75,7 @@ class NaClIPCAdapterTest : public testing::Test {
|
||||
TEST_F(NaClIPCAdapterTest, SimpleReceiveRewriting) {
|
||||
int routing_id = 0x89898989;
|
||||
uint32 type = 0x55555555;
|
||||
IPC::Message input(routing_id, type, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message input(routing_id, type);
|
||||
uint32 flags = input.flags();
|
||||
|
||||
int value = 0x12345678;
|
||||
@ -175,14 +175,14 @@ TEST_F(NaClIPCAdapterTest, SendRewriting) {
|
||||
TEST_F(NaClIPCAdapterTest, PartialReceive) {
|
||||
int routing_id_1 = 0x89898989;
|
||||
uint32 type_1 = 0x55555555;
|
||||
IPC::Message input_1(routing_id_1, type_1, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message input_1(routing_id_1, type_1);
|
||||
int value_1 = 0x12121212;
|
||||
input_1.WriteInt(value_1);
|
||||
adapter_->OnMessageReceived(input_1);
|
||||
|
||||
int routing_id_2 = 0x90909090;
|
||||
uint32 type_2 = 0x66666666;
|
||||
IPC::Message input_2(routing_id_2, type_2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message input_2(routing_id_2, type_2);
|
||||
int value_2 = 0x23232323;
|
||||
input_2.WriteInt(value_2);
|
||||
adapter_->OnMessageReceived(input_2);
|
||||
|
@ -226,8 +226,7 @@ TEST_F(RenderViewHostTest, BadMessageHandlerRenderViewHost) {
|
||||
EXPECT_EQ(0, process()->bad_msg_count());
|
||||
// craft an incorrect ViewHostMsg_UpdateTargetURL message. The real one has
|
||||
// two payload items but the one we construct has none.
|
||||
IPC::Message message(0, ViewHostMsg_UpdateTargetURL::ID,
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message message(0, ViewHostMsg_UpdateTargetURL::ID);
|
||||
test_rvh()->OnMessageReceived(message);
|
||||
EXPECT_EQ(1, process()->bad_msg_count());
|
||||
}
|
||||
@ -238,8 +237,7 @@ TEST_F(RenderViewHostTest, BadMessageHandlerRenderWidgetHost) {
|
||||
EXPECT_EQ(0, process()->bad_msg_count());
|
||||
// craft an incorrect ViewHostMsg_UpdateRect message. The real one has
|
||||
// one payload item but the one we construct has none.
|
||||
IPC::Message message(0, ViewHostMsg_UpdateRect::ID,
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message message(0, ViewHostMsg_UpdateRect::ID);
|
||||
test_rvh()->OnMessageReceived(message);
|
||||
EXPECT_EQ(1, process()->bad_msg_count());
|
||||
}
|
||||
@ -251,8 +249,7 @@ TEST_F(RenderViewHostTest, BadMessageHandlerInputEventAck) {
|
||||
// the code actually expects it to have at least one int para, this this
|
||||
// bogus message will not fail at de-serialization but should fail in
|
||||
// OnInputEventAck() processing.
|
||||
IPC::Message message(0, InputHostMsg_HandleInputEvent_ACK::ID,
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message message(0, InputHostMsg_HandleInputEvent_ACK::ID);
|
||||
test_rvh()->OnMessageReceived(message);
|
||||
EXPECT_EQ(1, process()->bad_msg_count());
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ TEST_F(CCMessagesTest, AllQuads) {
|
||||
if (!command_line.HasSwitch(switches::kAllowFiltersOverIPC))
|
||||
command_line.AppendSwitch(switches::kAllowFiltersOverIPC);
|
||||
|
||||
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message msg(1, 2);
|
||||
|
||||
Transform arbitrary_matrix;
|
||||
arbitrary_matrix.Scale(3, 3);
|
||||
@ -497,7 +497,7 @@ TEST_F(CCMessagesTest, AllQuads) {
|
||||
}
|
||||
|
||||
TEST_F(CCMessagesTest, Resources) {
|
||||
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message msg(1, 2);
|
||||
gfx::Size arbitrary_size(757, 1281);
|
||||
unsigned int arbitrary_uint1 = 71234838;
|
||||
unsigned int arbitrary_uint2 = 53589793;
|
||||
|
@ -27,7 +27,7 @@ TEST(IPCMessageTest, Serialize) {
|
||||
|
||||
for (size_t i = 0; i < arraysize(serialize_cases); i++) {
|
||||
GURL input(serialize_cases[i]);
|
||||
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message msg(1, 2);
|
||||
IPC::ParamTraits<GURL>::Write(&msg, input);
|
||||
|
||||
GURL output;
|
||||
@ -58,7 +58,7 @@ TEST(IPCMessageTest, Serialize) {
|
||||
}
|
||||
|
||||
// Also test the corrupt case.
|
||||
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message msg(1, 2);
|
||||
msg.WriteInt(99);
|
||||
GURL output;
|
||||
PickleIterator iter(msg);
|
||||
@ -70,7 +70,7 @@ TEST(IPCMessageTest, Pair) {
|
||||
typedef std::pair<std::string, std::string> TestPair;
|
||||
|
||||
TestPair input("foo", "bar");
|
||||
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message msg(1, 2);
|
||||
IPC::ParamTraits<TestPair>::Write(&msg, input);
|
||||
|
||||
TestPair output;
|
||||
@ -88,7 +88,7 @@ TEST(IPCMessageTest, Bitmap) {
|
||||
bitmap.allocPixels();
|
||||
memset(bitmap.getPixels(), 'A', bitmap.getSize());
|
||||
|
||||
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message msg(1, 2);
|
||||
IPC::ParamTraits<SkBitmap>::Write(&msg, bitmap);
|
||||
|
||||
SkBitmap output;
|
||||
@ -104,7 +104,7 @@ TEST(IPCMessageTest, Bitmap) {
|
||||
0);
|
||||
|
||||
// Also test the corrupt case.
|
||||
IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message bad_msg(1, 2);
|
||||
// Copy the first message block over to |bad_msg|.
|
||||
const char* fixed_data;
|
||||
int fixed_data_size;
|
||||
@ -128,7 +128,7 @@ TEST(IPCMessageTest, ListValue) {
|
||||
input.Set(1, new base::StringValue("forty"));
|
||||
input.Set(2, base::Value::CreateNullValue());
|
||||
|
||||
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message msg(1, 2);
|
||||
IPC::WriteParam(&msg, input);
|
||||
|
||||
base::ListValue output;
|
||||
@ -138,7 +138,7 @@ TEST(IPCMessageTest, ListValue) {
|
||||
EXPECT_TRUE(input.Equals(&output));
|
||||
|
||||
// Also test the corrupt case.
|
||||
IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message bad_msg(1, 2);
|
||||
bad_msg.WriteInt(99);
|
||||
iter = PickleIterator(bad_msg);
|
||||
EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output));
|
||||
@ -162,7 +162,7 @@ TEST(IPCMessageTest, DictionaryValue) {
|
||||
|
||||
input.Set("dict", subdict.release());
|
||||
|
||||
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message msg(1, 2);
|
||||
IPC::WriteParam(&msg, input);
|
||||
|
||||
base::DictionaryValue output;
|
||||
@ -172,7 +172,7 @@ TEST(IPCMessageTest, DictionaryValue) {
|
||||
EXPECT_TRUE(input.Equals(&output));
|
||||
|
||||
// Also test the corrupt case.
|
||||
IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message bad_msg(1, 2);
|
||||
bad_msg.WriteInt(99);
|
||||
iter = PickleIterator(bad_msg);
|
||||
EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output));
|
||||
@ -182,7 +182,7 @@ TEST(IPCMessageTest, DictionaryValue) {
|
||||
TEST(IPCMessageTest, HostPortPair) {
|
||||
net::HostPortPair input("host.com", 12345);
|
||||
|
||||
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message msg(1, 2);
|
||||
IPC::ParamTraits<net::HostPortPair>::Write(&msg, input);
|
||||
|
||||
net::HostPortPair output;
|
||||
|
@ -745,8 +745,7 @@ int Channel::ChannelImpl::GetHelloMessageProcId() {
|
||||
void Channel::ChannelImpl::QueueHelloMessage() {
|
||||
// Create the Hello message
|
||||
scoped_ptr<Message> msg(new Message(MSG_ROUTING_NONE,
|
||||
HELLO_MESSAGE_TYPE,
|
||||
IPC::Message::PRIORITY_NORMAL));
|
||||
HELLO_MESSAGE_TYPE));
|
||||
if (!msg->WriteInt(GetHelloMessageProcId())) {
|
||||
NOTREACHED() << "Unable to pickle hello message proc id";
|
||||
}
|
||||
@ -939,8 +938,7 @@ void Channel::ChannelImpl::QueueCloseFDMessage(int fd, int hops) {
|
||||
case 2: {
|
||||
// Create the message
|
||||
scoped_ptr<Message> msg(new Message(MSG_ROUTING_NONE,
|
||||
CLOSE_FD_MESSAGE_TYPE,
|
||||
IPC::Message::PRIORITY_NORMAL));
|
||||
CLOSE_FD_MESSAGE_TYPE));
|
||||
if (!msg->WriteInt(hops - 1) || !msg->WriteInt(fd)) {
|
||||
NOTREACHED() << "Unable to pickle close fd.";
|
||||
}
|
||||
|
@ -244,9 +244,8 @@ TEST_F(IPCChannelPosixTest, AdvancedConnected) {
|
||||
SpinRunLoop(TestTimeouts::action_max_timeout());
|
||||
ASSERT_EQ(IPCChannelPosixTestListener::CONNECTED, listener.status());
|
||||
ASSERT_TRUE(channel.HasAcceptedConnection());
|
||||
IPC::Message* message = new IPC::Message(0, // routing_id
|
||||
kQuitMessage, // message type
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message* message = new IPC::Message(0, /* routing_id */
|
||||
kQuitMessage /* message type */);
|
||||
channel.Send(message);
|
||||
SpinRunLoop(TestTimeouts::action_timeout());
|
||||
int exit_code = 0;
|
||||
@ -283,9 +282,8 @@ TEST_F(IPCChannelPosixTest, ResetState) {
|
||||
SpinRunLoop(TestTimeouts::action_max_timeout());
|
||||
ASSERT_EQ(IPCChannelPosixTestListener::CONNECTED, listener.status());
|
||||
ASSERT_TRUE(channel.HasAcceptedConnection());
|
||||
IPC::Message* message = new IPC::Message(0, // routing_id
|
||||
kQuitMessage, // message type
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message* message = new IPC::Message(0, /* routing_id */
|
||||
kQuitMessage /* message type */);
|
||||
channel.Send(message);
|
||||
SpinRunLoop(TestTimeouts::action_timeout());
|
||||
EXPECT_TRUE(base::KillProcess(handle, 0, false));
|
||||
@ -342,9 +340,8 @@ TEST_F(IPCChannelPosixTest, MultiConnection) {
|
||||
EXPECT_EQ(exit_code, 0);
|
||||
ASSERT_EQ(IPCChannelPosixTestListener::DENIED, listener.status());
|
||||
ASSERT_TRUE(channel.HasAcceptedConnection());
|
||||
IPC::Message* message = new IPC::Message(0, // routing_id
|
||||
kQuitMessage, // message type
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message* message = new IPC::Message(0, /* routing_id */
|
||||
kQuitMessage /* message type */);
|
||||
channel.Send(message);
|
||||
SpinRunLoop(TestTimeouts::action_timeout());
|
||||
EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code));
|
||||
|
@ -23,9 +23,7 @@ const size_t kLongMessageStringNumBytes = 50000;
|
||||
static void Send(IPC::Sender* sender, const char* text) {
|
||||
static int message_index = 0;
|
||||
|
||||
IPC::Message* message = new IPC::Message(0,
|
||||
2,
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message* message = new IPC::Message(0, 2);
|
||||
message->WriteInt(message_index++);
|
||||
message->WriteString(std::string(text));
|
||||
|
||||
@ -94,7 +92,7 @@ TEST_F(IPCChannelTest, BasicMessageTest) {
|
||||
std::string v2("foobar");
|
||||
std::wstring v3(L"hello world");
|
||||
|
||||
IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message m(0, 1);
|
||||
EXPECT_TRUE(m.WriteInt(v1));
|
||||
EXPECT_TRUE(m.WriteString(v2));
|
||||
EXPECT_TRUE(m.WriteWString(v3));
|
||||
|
@ -269,8 +269,7 @@ bool Channel::ChannelImpl::CreatePipe(const IPC::ChannelHandle &channel_handle,
|
||||
|
||||
// Create the Hello message to be sent when Connect is called
|
||||
scoped_ptr<Message> m(new Message(MSG_ROUTING_NONE,
|
||||
HELLO_MESSAGE_TYPE,
|
||||
IPC::Message::PRIORITY_NORMAL));
|
||||
HELLO_MESSAGE_TYPE));
|
||||
|
||||
// Don't send the secret to the untrusted process, and don't send a secret
|
||||
// if the value is zero (for IPC backwards compatability).
|
||||
|
@ -38,7 +38,7 @@ TEST(IPCMessageIntegrity, ReadBeyondBufferStr) {
|
||||
//This was BUG 984408.
|
||||
uint32 v1 = kuint32max - 1;
|
||||
int v2 = 666;
|
||||
IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message m(0, 1);
|
||||
EXPECT_TRUE(m.WriteInt(v1));
|
||||
EXPECT_TRUE(m.WriteInt(v2));
|
||||
|
||||
@ -51,7 +51,7 @@ TEST(IPCMessageIntegrity, ReadBeyondBufferWStr) {
|
||||
//This was BUG 984408.
|
||||
uint32 v1 = kuint32max - 1;
|
||||
int v2 = 777;
|
||||
IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message m(0, 1);
|
||||
EXPECT_TRUE(m.WriteInt(v1));
|
||||
EXPECT_TRUE(m.WriteInt(v2));
|
||||
|
||||
@ -62,7 +62,7 @@ TEST(IPCMessageIntegrity, ReadBeyondBufferWStr) {
|
||||
|
||||
TEST(IPCMessageIntegrity, ReadBytesBadIterator) {
|
||||
// This was BUG 1035467.
|
||||
IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message m(0, 1);
|
||||
EXPECT_TRUE(m.WriteInt(1));
|
||||
EXPECT_TRUE(m.WriteInt(2));
|
||||
|
||||
@ -75,7 +75,7 @@ TEST(IPCMessageIntegrity, ReadVectorNegativeSize) {
|
||||
// A slight variation of BUG 984408. Note that the pickling of vector<char>
|
||||
// has a specialized template which is not vulnerable to this bug. So here
|
||||
// try to hit the non-specialized case vector<P>.
|
||||
IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message m(0, 1);
|
||||
EXPECT_TRUE(m.WriteInt(-1)); // This is the count of elements.
|
||||
EXPECT_TRUE(m.WriteInt(1));
|
||||
EXPECT_TRUE(m.WriteInt(2));
|
||||
@ -89,7 +89,7 @@ TEST(IPCMessageIntegrity, ReadVectorNegativeSize) {
|
||||
TEST(IPCMessageIntegrity, ReadVectorTooLarge1) {
|
||||
// This was BUG 1006367. This is the large but positive length case. Again
|
||||
// we try to hit the non-specialized case vector<P>.
|
||||
IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message m(0, 1);
|
||||
EXPECT_TRUE(m.WriteInt(0x21000003)); // This is the count of elements.
|
||||
EXPECT_TRUE(m.WriteInt64(1));
|
||||
EXPECT_TRUE(m.WriteInt64(2));
|
||||
@ -103,7 +103,7 @@ TEST(IPCMessageIntegrity, ReadVectorTooLarge2) {
|
||||
// This was BUG 1006367. This is the large but positive with an additional
|
||||
// integer overflow when computing the actual byte size. Again we try to hit
|
||||
// the non-specialized case vector<P>.
|
||||
IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message m(0, 1);
|
||||
EXPECT_TRUE(m.WriteInt(0x71000000)); // This is the count of elements.
|
||||
EXPECT_TRUE(m.WriteInt64(1));
|
||||
EXPECT_TRUE(m.WriteInt64(2));
|
||||
@ -164,8 +164,7 @@ class FuzzerServerListener : public SimpleListener {
|
||||
}
|
||||
|
||||
bool RoundtripAckReply(int routing, uint32 type_id, int reply) {
|
||||
IPC::Message* message = new IPC::Message(routing, type_id,
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message* message = new IPC::Message(routing, type_id);
|
||||
message->WriteInt(reply + 1);
|
||||
message->WriteInt(reply);
|
||||
return other_->Send(message);
|
||||
@ -298,8 +297,7 @@ TEST_F(IPCFuzzingTest, MsgBadPayloadShort) {
|
||||
ASSERT_TRUE(ConnectChannel());
|
||||
ASSERT_TRUE(StartClient());
|
||||
|
||||
IPC::Message* msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassIS::ID,
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message* msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassIS::ID);
|
||||
msg->WriteInt(666);
|
||||
sender()->Send(msg);
|
||||
EXPECT_TRUE(listener.ExpectMsgNotHandled(MsgClassIS::ID));
|
||||
@ -326,8 +324,7 @@ TEST_F(IPCFuzzingTest, MsgBadPayloadArgs) {
|
||||
ASSERT_TRUE(ConnectChannel());
|
||||
ASSERT_TRUE(StartClient());
|
||||
|
||||
IPC::Message* msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassSI::ID,
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message* msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassSI::ID);
|
||||
msg->WriteWString(L"d");
|
||||
msg->WriteInt(0);
|
||||
msg->WriteInt(0x65); // Extra argument.
|
||||
@ -393,14 +390,12 @@ TEST_F(IPCFuzzingTest, MsgMapExMacro) {
|
||||
|
||||
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
|
||||
// Test a bad message.
|
||||
msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassSI::ID,
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassSI::ID);
|
||||
msg->WriteInt(2);
|
||||
EXPECT_FALSE(server.OnMessageReceived(*msg));
|
||||
delete msg;
|
||||
|
||||
msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassIS::ID,
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassIS::ID);
|
||||
msg->WriteInt(0x64);
|
||||
msg->WriteInt(0x32);
|
||||
EXPECT_FALSE(server.OnMessageReceived(*msg));
|
||||
|
@ -96,8 +96,7 @@ void Logging::OnSendLogs() {
|
||||
if (!sender_)
|
||||
return;
|
||||
|
||||
Message* msg = new Message(
|
||||
MSG_ROUTING_CONTROL, IPC_LOGGING_ID, Message::PRIORITY_NORMAL);
|
||||
Message* msg = new Message(MSG_ROUTING_CONTROL, IPC_LOGGING_ID);
|
||||
WriteParam(msg, queued_logs_);
|
||||
queued_logs_.clear();
|
||||
sender_->Send(msg);
|
||||
|
@ -50,12 +50,11 @@ Message::Message()
|
||||
InitLoggingVariables();
|
||||
}
|
||||
|
||||
Message::Message(int32 routing_id, uint32 type, PriorityValue priority)
|
||||
Message::Message(int32 routing_id, uint32 type)
|
||||
: Pickle(sizeof(Header)) {
|
||||
header()->routing = routing_id;
|
||||
header()->type = type;
|
||||
DCHECK((priority & 0xffffff00) == 0);
|
||||
header()->flags = priority | GetRefNumUpper24();
|
||||
header()->flags = GetRefNumUpper24();
|
||||
#if defined(OS_POSIX)
|
||||
header()->num_fds = 0;
|
||||
header()->pad = 0;
|
||||
@ -63,7 +62,8 @@ Message::Message(int32 routing_id, uint32 type, PriorityValue priority)
|
||||
InitLoggingVariables();
|
||||
}
|
||||
|
||||
Message::Message(const char* data, int data_len) : Pickle(data, data_len) {
|
||||
Message::Message(const char* data, size_t data_len)
|
||||
: Pickle(data, data_len) {
|
||||
InitLoggingVariables();
|
||||
}
|
||||
|
||||
|
@ -34,17 +34,11 @@ struct LogData;
|
||||
|
||||
class IPC_EXPORT Message : public Pickle {
|
||||
public:
|
||||
enum PriorityValue {
|
||||
PRIORITY_LOW = 1,
|
||||
PRIORITY_NORMAL,
|
||||
PRIORITY_HIGH
|
||||
};
|
||||
|
||||
// Bit values used in the flags field.
|
||||
// Upper 24 bits of flags store a reference number, so this enum is limited to
|
||||
// 8 bits.
|
||||
enum {
|
||||
PRIORITY_MASK = 0x03, // Low 2 bits of store the priority value.
|
||||
UNUSED = 0x03, // Low 2 bits are not used.
|
||||
SYNC_BIT = 0x04,
|
||||
REPLY_BIT = 0x08,
|
||||
REPLY_ERROR_BIT = 0x10,
|
||||
@ -57,22 +51,17 @@ class IPC_EXPORT Message : public Pickle {
|
||||
|
||||
Message();
|
||||
|
||||
// Initialize a message with a user-defined type, priority value, and
|
||||
// destination WebView ID.
|
||||
Message(int32 routing_id, uint32 type, PriorityValue priority);
|
||||
// Initialize a message with routing ID and a user-defined type.
|
||||
Message(int32 routing_id, uint32 type);
|
||||
|
||||
// Initializes a message from a const block of data. The data is not copied;
|
||||
// instead the data is merely referenced by this message. Only const methods
|
||||
// should be used on the message when initialized this way.
|
||||
Message(const char* data, int data_len);
|
||||
Message(const char* data, size_t data_len);
|
||||
|
||||
Message(const Message& other);
|
||||
Message& operator=(const Message& other);
|
||||
|
||||
PriorityValue priority() const {
|
||||
return static_cast<PriorityValue>(header()->flags & PRIORITY_MASK);
|
||||
}
|
||||
|
||||
// True if this is a synchronous message.
|
||||
void set_sync() {
|
||||
header()->flags |= SYNC_BIT;
|
||||
|
@ -614,7 +614,7 @@
|
||||
public: \
|
||||
typedef IPC::Message Schema; \
|
||||
enum { ID = IPC_MESSAGE_ID() }; \
|
||||
msg_class() : IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL) {} \
|
||||
msg_class() : IPC::Message(MSG_ROUTING_CONTROL, ID) {} \
|
||||
static void Log(std::string* name, const Message* msg, std::string* l); \
|
||||
};
|
||||
|
||||
@ -624,7 +624,7 @@
|
||||
typedef IPC::Message Schema; \
|
||||
enum { ID = IPC_MESSAGE_ID() }; \
|
||||
msg_class(int32 routing_id) \
|
||||
: IPC::Message(routing_id, ID, PRIORITY_NORMAL) {} \
|
||||
: IPC::Message(routing_id, ID) {} \
|
||||
static void Log(std::string* name, const Message* msg, std::string* l); \
|
||||
};
|
||||
|
||||
@ -713,7 +713,7 @@
|
||||
|
||||
#define IPC_ASYNC_CONTROL_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \
|
||||
msg_class::msg_class(IPC_TYPE_IN_##in_cnt in_list) : \
|
||||
IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL) { \
|
||||
IPC::Message(MSG_ROUTING_CONTROL, ID) { \
|
||||
Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \
|
||||
} \
|
||||
msg_class::~msg_class() {} \
|
||||
@ -724,7 +724,7 @@
|
||||
#define IPC_ASYNC_ROUTED_IMPL(msg_class, in_cnt, out_cnt, in_list, out_list) \
|
||||
msg_class::msg_class(int32 routing_id IPC_COMMA_##in_cnt \
|
||||
IPC_TYPE_IN_##in_cnt in_list) : \
|
||||
IPC::Message(routing_id, ID, PRIORITY_NORMAL) { \
|
||||
IPC::Message(routing_id, ID) { \
|
||||
Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \
|
||||
} \
|
||||
msg_class::~msg_class() {} \
|
||||
@ -736,7 +736,7 @@
|
||||
msg_class::msg_class(IPC_TYPE_IN_##in_cnt in_list \
|
||||
IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \
|
||||
IPC_TYPE_OUT_##out_cnt out_list) : \
|
||||
IPC::SyncMessage(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL, \
|
||||
IPC::SyncMessage(MSG_ROUTING_CONTROL, ID, \
|
||||
new IPC::ParamDeserializer<Schema::ReplyParam>( \
|
||||
IPC_NAME_OUT_##out_cnt out_list)) { \
|
||||
Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \
|
||||
@ -756,7 +756,7 @@
|
||||
IPC_TYPE_IN_##in_cnt in_list \
|
||||
IPC_COMMA_AND_##in_cnt(IPC_COMMA_##out_cnt) \
|
||||
IPC_TYPE_OUT_##out_cnt out_list) : \
|
||||
IPC::SyncMessage(routing_id, ID, PRIORITY_NORMAL, \
|
||||
IPC::SyncMessage(routing_id, ID, \
|
||||
new IPC::ParamDeserializer<Schema::ReplyParam>( \
|
||||
IPC_NAME_OUT_##out_cnt out_list)) { \
|
||||
Schema::Write(this, IPC_NAME_IN_##in_cnt in_list); \
|
||||
|
@ -19,7 +19,7 @@ TEST(IPCMessageTest, ListValue) {
|
||||
input.Set(1, new base::StringValue("forty"));
|
||||
input.Set(2, base::Value::CreateNullValue());
|
||||
|
||||
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message msg(1, 2);
|
||||
IPC::WriteParam(&msg, input);
|
||||
|
||||
base::ListValue output;
|
||||
@ -29,7 +29,7 @@ TEST(IPCMessageTest, ListValue) {
|
||||
EXPECT_TRUE(input.Equals(&output));
|
||||
|
||||
// Also test the corrupt case.
|
||||
IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message bad_msg(1, 2);
|
||||
bad_msg.WriteInt(99);
|
||||
iter = PickleIterator(bad_msg);
|
||||
EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output));
|
||||
@ -54,7 +54,7 @@ TEST(IPCMessageTest, DictionaryValue) {
|
||||
|
||||
input.Set("dict", subdict.release());
|
||||
|
||||
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message msg(1, 2);
|
||||
IPC::WriteParam(&msg, input);
|
||||
|
||||
base::DictionaryValue output;
|
||||
@ -64,7 +64,7 @@ TEST(IPCMessageTest, DictionaryValue) {
|
||||
EXPECT_TRUE(input.Equals(&output));
|
||||
|
||||
// Also test the corrupt case.
|
||||
IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message bad_msg(1, 2);
|
||||
bad_msg.WriteInt(99);
|
||||
iter = PickleIterator(bad_msg);
|
||||
EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output));
|
||||
|
@ -16,16 +16,14 @@ TEST(IPCMessageUtilsTest, NestedMessages) {
|
||||
int32 nested_routing = 12;
|
||||
uint32 nested_type = 78;
|
||||
int nested_content = 456789;
|
||||
Message::PriorityValue nested_priority = Message::PRIORITY_HIGH;
|
||||
Message nested_msg(nested_routing, nested_type, nested_priority);
|
||||
Message nested_msg(nested_routing, nested_type);
|
||||
nested_msg.set_sync();
|
||||
ParamTraits<int>::Write(&nested_msg, nested_content);
|
||||
|
||||
// Outer message contains the nested one as its parameter.
|
||||
int32 outer_routing = 91;
|
||||
uint32 outer_type = 88;
|
||||
Message::PriorityValue outer_priority = Message::PRIORITY_NORMAL;
|
||||
Message outer_msg(outer_routing, outer_type, outer_priority);
|
||||
Message outer_msg(outer_routing, outer_type);
|
||||
ParamTraits<Message>::Write(&outer_msg, nested_msg);
|
||||
|
||||
// Read back the nested message.
|
||||
@ -36,7 +34,6 @@ TEST(IPCMessageUtilsTest, NestedMessages) {
|
||||
// Verify nested message headers.
|
||||
EXPECT_EQ(nested_msg.routing_id(), result_msg.routing_id());
|
||||
EXPECT_EQ(nested_msg.type(), result_msg.type());
|
||||
EXPECT_EQ(nested_msg.priority(), result_msg.priority());
|
||||
EXPECT_EQ(nested_msg.flags(), result_msg.flags());
|
||||
|
||||
// Verify nested message content
|
||||
|
@ -122,7 +122,7 @@ class ChannelReflectorListener : public IPC::Listener {
|
||||
base::TimeTicks::FromInternalValue(time_internal), now);
|
||||
}
|
||||
|
||||
IPC::Message* msg = new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message* msg = new IPC::Message(0, 2);
|
||||
msg->WriteInt64(base::TimeTicks::Now().ToInternalValue());
|
||||
msg->WriteInt(msgid);
|
||||
msg->WriteString(payload);
|
||||
@ -201,7 +201,7 @@ class PerformanceChannelListener : public IPC::Listener {
|
||||
}
|
||||
}
|
||||
|
||||
IPC::Message* msg = new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message* msg = new IPC::Message(0, 2);
|
||||
msg->WriteInt64(base::TimeTicks::Now().ToInternalValue());
|
||||
msg->WriteInt(count_down_);
|
||||
msg->WriteString(payload_);
|
||||
@ -239,7 +239,7 @@ TEST_F(IPCChannelPerfTest, Performance) {
|
||||
|
||||
// This initial message will kick-start the ping-pong of messages.
|
||||
IPC::Message* message =
|
||||
new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
new IPC::Message(0, 2);
|
||||
message->WriteInt64(base::TimeTicks::Now().ToInternalValue());
|
||||
message->WriteInt(-1);
|
||||
message->WriteString("hello");
|
||||
@ -252,7 +252,7 @@ TEST_F(IPCChannelPerfTest, Performance) {
|
||||
}
|
||||
|
||||
// Send quit message.
|
||||
IPC::Message* message = new IPC::Message(0, 2, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message* message = new IPC::Message(0, 2);
|
||||
message->WriteInt64(base::TimeTicks::Now().ToInternalValue());
|
||||
message->WriteInt(-1);
|
||||
message->WriteString("quit");
|
||||
|
@ -106,8 +106,7 @@ class IPCSendFdsTest : public IPCTestBase {
|
||||
ASSERT_GE(fd, 0);
|
||||
base::FileDescriptor descriptor(fd, true);
|
||||
|
||||
IPC::Message* message =
|
||||
new IPC::Message(0, 3, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message* message = new IPC::Message(0, 3);
|
||||
IPC::ParamTraits<base::FileDescriptor>::Write(message, descriptor);
|
||||
ASSERT_TRUE(sender()->Send(message));
|
||||
}
|
||||
@ -280,8 +279,7 @@ class PipeChannelHelper {
|
||||
ASSERT_GE(fd, 0);
|
||||
base::FileDescriptor descriptor(fd, true);
|
||||
|
||||
IPC::Message* message =
|
||||
new IPC::Message(0, 3, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message* message = new IPC::Message(0, 3);
|
||||
IPC::ParamTraits<base::FileDescriptor>::Write(message, descriptor);
|
||||
ASSERT_TRUE(in->Send(message));
|
||||
}
|
||||
|
@ -39,9 +39,8 @@ namespace IPC {
|
||||
SyncMessage::SyncMessage(
|
||||
int32 routing_id,
|
||||
uint32 type,
|
||||
PriorityValue priority,
|
||||
MessageReplyDeserializer* deserializer)
|
||||
: Message(routing_id, type, priority),
|
||||
: Message(routing_id, type),
|
||||
deserializer_(deserializer),
|
||||
pump_messages_event_(NULL)
|
||||
{
|
||||
@ -96,8 +95,7 @@ int SyncMessage::GetMessageId(const Message& msg) {
|
||||
Message* SyncMessage::GenerateReply(const Message* msg) {
|
||||
DCHECK(msg->is_sync());
|
||||
|
||||
Message* reply = new Message(msg->routing_id(), IPC_REPLY_ID,
|
||||
msg->priority());
|
||||
Message* reply = new Message(msg->routing_id(), IPC_REPLY_ID);
|
||||
reply->set_reply();
|
||||
|
||||
SyncHeader header;
|
||||
|
@ -23,7 +23,7 @@ class MessageReplyDeserializer;
|
||||
|
||||
class IPC_EXPORT SyncMessage : public Message {
|
||||
public:
|
||||
SyncMessage(int32 routing_id, uint32 type, PriorityValue priority,
|
||||
SyncMessage(int32 routing_id, uint32 type,
|
||||
MessageReplyDeserializer* deserializer);
|
||||
virtual ~SyncMessage();
|
||||
|
||||
|
@ -64,8 +64,7 @@ class MyResourceHost : public ResourceHost {
|
||||
HostMessageContext* context) OVERRIDE {
|
||||
last_handled_msg_ = msg;
|
||||
if (msg.type() == msg_type_) {
|
||||
context->reply_msg = IPC::Message(0, reply_msg_type_,
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
context->reply_msg = IPC::Message(0, reply_msg_type_);
|
||||
return PP_OK;
|
||||
}
|
||||
return PP_ERROR_FAILED;
|
||||
@ -123,8 +122,7 @@ class MyResourceFilter : public ResourceMessageFilter {
|
||||
last_handled_msg_ = msg;
|
||||
last_message_loop_ = base::MessageLoop::current();
|
||||
if (msg.type() == msg_type_) {
|
||||
context->reply_msg = IPC::Message(0, reply_msg_type_,
|
||||
IPC::Message::PRIORITY_NORMAL);
|
||||
context->reply_msg = IPC::Message(0, reply_msg_type_);
|
||||
return PP_OK;
|
||||
}
|
||||
return PP_ERROR_FAILED;
|
||||
@ -166,9 +164,9 @@ TEST_F(ResourceMessageFilterTest, TestHandleMessage) {
|
||||
proxy::ResourceMessageCallParams params(resource, 1);
|
||||
params.set_has_callback();
|
||||
HostMessageContext context(params);
|
||||
IPC::Message message1(0, MSG1_TYPE, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message message2(0, MSG2_TYPE, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message message3(0, MSG3_TYPE, IPC::Message::PRIORITY_NORMAL);
|
||||
IPC::Message message1(0, MSG1_TYPE);
|
||||
IPC::Message message2(0, MSG2_TYPE);
|
||||
IPC::Message message3(0, MSG3_TYPE);
|
||||
|
||||
// Message 1 handled by the first filter.
|
||||
host.HandleMessage(message1, &context);
|
||||
|
@ -227,17 +227,14 @@ bool HandleConverter::ConvertNativeHandlesToPosix(
|
||||
// compatible with Windows IPC deserialization code; it is intended to be
|
||||
// passed to NaCl.
|
||||
#if defined(OS_WIN)
|
||||
new_msg_ptr->reset(
|
||||
new IPC::Message(msg.routing_id(), msg.type(), msg.priority()));
|
||||
new_msg_ptr->reset(new IPC::Message(msg.routing_id(), msg.type()));
|
||||
#else
|
||||
// Even on POSIX, we have to rewrite messages to create channels, because
|
||||
// these contain a handle with an invalid (place holder) descriptor. The
|
||||
// message sending code sees this and doesn't pass the descriptor over
|
||||
// correctly.
|
||||
if (msg.type() == PpapiMsg_CreateNaClChannel::ID) {
|
||||
new_msg_ptr->reset(
|
||||
new IPC::Message(msg.routing_id(), msg.type(), msg.priority()));
|
||||
}
|
||||
if (msg.type() == PpapiMsg_CreateNaClChannel::ID)
|
||||
new_msg_ptr->reset(new IPC::Message(msg.routing_id(), msg.type()));
|
||||
#endif
|
||||
|
||||
switch (msg.type()) {
|
||||
|
Reference in New Issue
Block a user