Skip to content

Commit

Permalink
Remove unused IPC::Message priority.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bbudge@chromium.org committed Oct 28, 2013
1 parent 85372b0 commit 9ea0ecd
Show file tree
Hide file tree
Showing 28 changed files with 87 additions and 130 deletions.
6 changes: 3 additions & 3 deletions base/pickle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion base/pickle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion cloud_print/service/win/service_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions components/nacl/loader/nacl_ipc_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions components/nacl/loader/nacl_ipc_adapter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 3 additions & 6 deletions content/browser/renderer_host/render_view_host_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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());
}
Expand All @@ -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());
}
Expand Down
4 changes: 2 additions & 2 deletions content/common/cc_messages_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions content/common/common_param_traits_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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));
Expand All @@ -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;
Expand All @@ -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));
Expand All @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions ipc/ipc_channel_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down Expand Up @@ -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.";
}
Expand Down
15 changes: 6 additions & 9 deletions ipc/ipc_channel_posix_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
6 changes: 2 additions & 4 deletions ipc/ipc_channel_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions ipc/ipc_channel_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Loading

0 comments on commit 9ea0ecd

Please sign in to comment.