diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 00:50:36 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 00:50:36 +0000 |
commit | 396b3f093cee5da4867dc6e93924ed8ab062f940 (patch) | |
tree | 094316b86df0c55cd51b029c45b93d6b86546d6c /mojo/common | |
parent | 4cbafd3a738558dd71be58737ce3502595d43a7d (diff) | |
download | chromium_src-396b3f093cee5da4867dc6e93924ed8ab062f940.zip chromium_src-396b3f093cee5da4867dc6e93924ed8ab062f940.tar.gz chromium_src-396b3f093cee5da4867dc6e93924ed8ab062f940.tar.bz2 |
Remove "ScopedHandleBase<H>::operator H() const"
Reason: it is too easy to misuse this and end up leaking a handle.
R=viettrungluu@chromium.org
Review URL: https://codereview.chromium.org/99913002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238252 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/common')
-rw-r--r-- | mojo/common/handle_watcher_unittest.cc | 44 | ||||
-rw-r--r-- | mojo/common/message_pump_mojo.cc | 6 |
2 files changed, 25 insertions, 25 deletions
diff --git a/mojo/common/handle_watcher_unittest.cc b/mojo/common/handle_watcher_unittest.cc index fc168a2..1f19316 100644 --- a/mojo/common/handle_watcher_unittest.cc +++ b/mojo/common/handle_watcher_unittest.cc @@ -135,10 +135,10 @@ TEST_F(HandleWatcherTest, SingleHandler) { ASSERT_TRUE(test_pipe.handle_0.is_valid()); CallbackHelper callback_helper; HandleWatcher watcher; - callback_helper.Start(&watcher, test_pipe.handle_0); + callback_helper.Start(&watcher, test_pipe.handle_0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper.got_callback()); - EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe.handle_1)); + EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe.handle_1.get())); callback_helper.RunUntilGotCallback(); EXPECT_TRUE(callback_helper.got_callback()); } @@ -157,28 +157,28 @@ TEST_F(HandleWatcherTest, ThreeHandles) { ASSERT_TRUE(test_pipe3.handle_0.is_valid()); HandleWatcher watcher1; - callback_helper1.Start(&watcher1, test_pipe1.handle_0); + callback_helper1.Start(&watcher1, test_pipe1.handle_0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); EXPECT_FALSE(callback_helper3.got_callback()); HandleWatcher watcher2; - callback_helper2.Start(&watcher2, test_pipe2.handle_0); + callback_helper2.Start(&watcher2, test_pipe2.handle_0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); EXPECT_FALSE(callback_helper3.got_callback()); HandleWatcher watcher3; - callback_helper3.Start(&watcher3, test_pipe3.handle_0); + callback_helper3.Start(&watcher3, test_pipe3.handle_0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); EXPECT_FALSE(callback_helper3.got_callback()); // Write to 3 and make sure it's notified. - EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe3.handle_1)); + EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe3.handle_1.get())); callback_helper3.RunUntilGotCallback(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); @@ -187,8 +187,8 @@ TEST_F(HandleWatcherTest, ThreeHandles) { // Write to 1 and 3. Only 1 should be notified since 3 was is no longer // running. - EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe1.handle_1)); - EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe3.handle_1)); + EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe1.handle_1.get())); + EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe3.handle_1.get())); callback_helper1.RunUntilGotCallback(); EXPECT_TRUE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); @@ -196,8 +196,8 @@ TEST_F(HandleWatcherTest, ThreeHandles) { callback_helper1.clear_callback(); // Write to 1 and 2. Only 2 should be notified (since 1 was already notified). - EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe1.handle_1)); - EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe2.handle_1)); + EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe1.handle_1.get())); + EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe2.handle_1.get())); callback_helper2.RunUntilGotCallback(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_TRUE(callback_helper2.got_callback()); @@ -214,40 +214,40 @@ TEST_F(HandleWatcherTest, Restart) { ASSERT_TRUE(test_pipe2.handle_0.is_valid()); HandleWatcher watcher1; - callback_helper1.Start(&watcher1, test_pipe1.handle_0); + callback_helper1.Start(&watcher1, test_pipe1.handle_0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); HandleWatcher watcher2; - callback_helper2.Start(&watcher2, test_pipe2.handle_0); + callback_helper2.Start(&watcher2, test_pipe2.handle_0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); // Write to 1 and make sure it's notified. - EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe1.handle_1)); + EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe1.handle_1.get())); callback_helper1.RunUntilGotCallback(); EXPECT_TRUE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); callback_helper1.clear_callback(); - EXPECT_EQ(MOJO_RESULT_OK, ReadFromHandle(test_pipe1.handle_0)); + EXPECT_EQ(MOJO_RESULT_OK, ReadFromHandle(test_pipe1.handle_0.get())); // Write to 2 and make sure it's notified. - EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe2.handle_1)); + EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe2.handle_1.get())); callback_helper2.RunUntilGotCallback(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_TRUE(callback_helper2.got_callback()); callback_helper2.clear_callback(); // Listen on 1 again. - callback_helper1.Start(&watcher1, test_pipe1.handle_0); + callback_helper1.Start(&watcher1, test_pipe1.handle_0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); // Write to 1 and make sure it's notified. - EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe1.handle_1)); + EXPECT_EQ(MOJO_RESULT_OK, WriteToHandle(test_pipe1.handle_1.get())); callback_helper1.RunUntilGotCallback(); EXPECT_TRUE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); @@ -269,7 +269,7 @@ TEST_F(HandleWatcherTest, Deadline) { // Add a watcher with an infinite timeout. HandleWatcher watcher1; - callback_helper1.Start(&watcher1, test_pipe1.handle_0); + callback_helper1.Start(&watcher1, test_pipe1.handle_0.get()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); EXPECT_FALSE(callback_helper2.got_callback()); @@ -277,7 +277,7 @@ TEST_F(HandleWatcherTest, Deadline) { // Add another watcher wth a timeout of 500 microseconds. HandleWatcher watcher2; - watcher2.Start(test_pipe2.handle_0, MOJO_WAIT_FLAG_READABLE, 500, + watcher2.Start(test_pipe2.handle_0.get(), MOJO_WAIT_FLAG_READABLE, 500, callback_helper2.GetCallback()); RunUntilIdle(); EXPECT_FALSE(callback_helper1.got_callback()); @@ -289,7 +289,7 @@ TEST_F(HandleWatcherTest, Deadline) { tick_clock_.Advance(base::TimeDelta::FromMicroseconds(501)); HandleWatcher watcher3; - callback_helper3.Start(&watcher3, test_pipe3.handle_0); + callback_helper3.Start(&watcher3, test_pipe3.handle_0.get()); callback_helper2.RunUntilGotCallback(); EXPECT_FALSE(callback_helper1.got_callback()); @@ -302,11 +302,11 @@ TEST_F(HandleWatcherTest, DeleteInCallback) { CallbackHelper callback_helper; HandleWatcher* watcher = new HandleWatcher(); - callback_helper.StartWithCallback(watcher, test_pipe.handle_1, + callback_helper.StartWithCallback(watcher, test_pipe.handle_1.get(), base::Bind(&DeleteWatcherAndForwardResult, watcher, callback_helper.GetCallback())); - WriteToHandle(test_pipe.handle_0); + WriteToHandle(test_pipe.handle_0.get()); callback_helper.RunUntilGotCallback(); EXPECT_TRUE(callback_helper.got_callback()); } diff --git a/mojo/common/message_pump_mojo.cc b/mojo/common/message_pump_mojo.cc index 18787ab..78b2bc1 100644 --- a/mojo/common/message_pump_mojo.cc +++ b/mojo/common/message_pump_mojo.cc @@ -125,7 +125,7 @@ void MessagePumpMojo::DoInternalWork(bool block) { if (result == 0) { // Control pipe was written to. uint32_t num_bytes = 0; - ReadMessageRaw(run_state_->read_handle, NULL, &num_bytes, NULL, NULL, + ReadMessageRaw(run_state_->read_handle.get(), NULL, &num_bytes, NULL, NULL, MOJO_READ_MESSAGE_FLAG_MAY_DISCARD); } else if (result > 0) { const size_t index = static_cast<size_t>(result); @@ -187,13 +187,13 @@ void MessagePumpMojo::SignalControlPipe() { return; // TODO(sky): deal with error? - WriteMessageRaw(run_state_->write_handle, NULL, 0, NULL, 0, + WriteMessageRaw(run_state_->write_handle.get(), NULL, 0, NULL, 0, MOJO_WRITE_MESSAGE_FLAG_NONE); } MessagePumpMojo::WaitState MessagePumpMojo::GetWaitState() const { WaitState wait_state; - wait_state.handles.push_back(run_state_->read_handle); + wait_state.handles.push_back(run_state_->read_handle.get()); wait_state.wait_flags.push_back(MOJO_WAIT_FLAG_READABLE); for (HandleToHandler::const_iterator i = handlers_.begin(); |