summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-04 20:54:20 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-04 20:54:20 +0000
commiteab9d01a2f673428cf1b8633e0a88697ae688408 (patch)
treec3796aad7c4ef9dcd559b759e7ca9386ca3554c7
parent35e10e96455d71f04bf4756872290cc3563e74e7 (diff)
downloadchromium_src-eab9d01a2f673428cf1b8633e0a88697ae688408.zip
chromium_src-eab9d01a2f673428cf1b8633e0a88697ae688408.tar.gz
chromium_src-eab9d01a2f673428cf1b8633e0a88697ae688408.tar.bz2
Fix even more remaining uses of WeakPtr<T>'s operator T* conversion
These cases weren't caught by the automated pass and/or needed to be solved in another way than using .get(). BUG=245942 TBR=darin@chromium.org Review URL: https://codereview.chromium.org/16226028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204036 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/memory/weak_ptr_unittest.cc2
-rw-r--r--chrome/browser/extensions/extension_action_unittest.cc22
-rw-r--r--chrome/browser/sync/glue/shared_change_processor_unittest.cc2
-rw-r--r--gpu/command_buffer/service/context_group.cc17
-rw-r--r--net/http/http_cache_unittest.cc4
-rw-r--r--net/spdy/spdy_write_queue.cc2
-rw-r--r--net/url_request/url_request_ftp_job_unittest.cc10
-rw-r--r--net/url_request/url_request_http_job_unittest.cc10
-rw-r--r--sync/internal_api/public/util/weak_handle.h10
-rw-r--r--sync/internal_api/public/util/weak_handle_unittest.cc4
-rw-r--r--webkit/browser/quota/quota_manager.cc6
11 files changed, 52 insertions, 37 deletions
diff --git a/base/memory/weak_ptr_unittest.cc b/base/memory/weak_ptr_unittest.cc
index 97cfb5f..8cf020a 100644
--- a/base/memory/weak_ptr_unittest.cc
+++ b/base/memory/weak_ptr_unittest.cc
@@ -189,7 +189,7 @@ TEST(WeakPtrFactoryTest, Comparison) {
WeakPtrFactory<int> factory(&data);
WeakPtr<int> ptr = factory.GetWeakPtr();
WeakPtr<int> ptr2 = ptr;
- EXPECT_EQ(ptr, ptr2);
+ EXPECT_EQ(ptr.get(), ptr2.get());
}
TEST(WeakPtrFactoryTest, OutOfScope) {
diff --git a/chrome/browser/extensions/extension_action_unittest.cc b/chrome/browser/extensions/extension_action_unittest.cc
index 2aba574..c1868ea 100644
--- a/chrome/browser/extensions/extension_action_unittest.cc
+++ b/chrome/browser/extensions/extension_action_unittest.cc
@@ -45,7 +45,7 @@ TEST(ExtensionActionTest, Visibility) {
action.SetAppearance(100, ExtensionAction::ACTIVE);
ASSERT_FALSE(action.GetIsVisible(1));
ASSERT_TRUE(action.GetIsVisible(100));
- EXPECT_FALSE(action.GetIconAnimation(100))
+ EXPECT_FALSE(action.GetIconAnimation(100).get())
<< "Page actions should not animate.";
action.ClearAllValuesForTab(100);
@@ -63,22 +63,24 @@ TEST(ExtensionActionTest, ScriptBadgeAnimation) {
ExtensionAction script_badge(
std::string(), ActionInfo::TYPE_SCRIPT_BADGE, ActionInfo());
- EXPECT_FALSE(script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId));
+ EXPECT_FALSE(
+ script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId).get());
script_badge.SetAppearance(ExtensionAction::kDefaultTabId,
ExtensionAction::ACTIVE);
- EXPECT_FALSE(script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId))
+ EXPECT_FALSE(
+ script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId).get())
<< "Showing the default tab should not animate script badges.";
script_badge.SetAppearance(ExtensionAction::kDefaultTabId,
ExtensionAction::INVISIBLE);
- EXPECT_FALSE(script_badge.GetIconAnimation(1))
+ EXPECT_FALSE(script_badge.GetIconAnimation(1).get())
<< "Making a script badge invisible should not show its animation.";
script_badge.SetAppearance(1, ExtensionAction::ACTIVE);
- EXPECT_TRUE(script_badge.GetIconAnimation(1))
+ EXPECT_TRUE(script_badge.GetIconAnimation(1).get())
<< "Making a script badge visible should show its animation.";
script_badge.ClearAllValuesForTab(1);
- EXPECT_FALSE(script_badge.GetIconAnimation(100));
+ EXPECT_FALSE(script_badge.GetIconAnimation(100).get());
}
TEST(ExtensionActionTest, GetAttention) {
@@ -88,18 +90,18 @@ TEST(ExtensionActionTest, GetAttention) {
ExtensionAction script_badge(
std::string(), ActionInfo::TYPE_SCRIPT_BADGE, ActionInfo());
EXPECT_FALSE(script_badge.GetIsVisible(1));
- EXPECT_FALSE(script_badge.GetIconAnimation(1));
+ EXPECT_FALSE(script_badge.GetIconAnimation(1).get());
script_badge.SetAppearance(1, ExtensionAction::WANTS_ATTENTION);
EXPECT_TRUE(script_badge.GetIsVisible(1));
- EXPECT_TRUE(script_badge.GetIconAnimation(1));
+ EXPECT_TRUE(script_badge.GetIconAnimation(1).get());
// Simulate waiting long enough for the animation to end.
message_loop.reset(); // Can't have 2 MessageLoops alive at once.
message_loop.reset(new base::MessageLoop);
- EXPECT_FALSE(script_badge.GetIconAnimation(1)); // Sanity check.
+ EXPECT_FALSE(script_badge.GetIconAnimation(1).get()); // Sanity check.
script_badge.SetAppearance(1, ExtensionAction::ACTIVE);
- EXPECT_FALSE(script_badge.GetIconAnimation(1))
+ EXPECT_FALSE(script_badge.GetIconAnimation(1).get())
<< "The animation should not play again if the icon was already visible.";
}
diff --git a/chrome/browser/sync/glue/shared_change_processor_unittest.cc b/chrome/browser/sync/glue/shared_change_processor_unittest.cc
index 795d738..30137e9 100644
--- a/chrome/browser/sync/glue/shared_change_processor_unittest.cc
+++ b/chrome/browser/sync/glue/shared_change_processor_unittest.cc
@@ -109,7 +109,7 @@ class SyncSharedChangeProcessorTest : public testing::Test {
&sync_service_,
&error_handler_,
syncer::AUTOFILL,
- base::WeakPtr<syncer::SyncMergeResult>()));
+ base::WeakPtr<syncer::SyncMergeResult>()).get());
}
base::MessageLoopForUI ui_loop_;
diff --git a/gpu/command_buffer/service/context_group.cc b/gpu/command_buffer/service/context_group.cc
index b34f992..4f61b85 100644
--- a/gpu/command_buffer/service/context_group.cc
+++ b/gpu/command_buffer/service/context_group.cc
@@ -242,6 +242,19 @@ bool IsNull(const base::WeakPtr<gles2::GLES2Decoder>& decoder) {
return !decoder.get();
}
+template <typename T>
+class WeakPtrEquals {
+ public:
+ explicit WeakPtrEquals(T* t) : t_(t) {}
+
+ bool operator()(const base::WeakPtr<T>& t) {
+ return t.get() == t_;
+ }
+
+ private:
+ T* const t_;
+};
+
} // namespace anonymous
bool ContextGroup::HaveContexts() {
@@ -251,8 +264,8 @@ bool ContextGroup::HaveContexts() {
}
void ContextGroup::Destroy(GLES2Decoder* decoder, bool have_context) {
- decoders_.erase(std::remove(decoders_.begin(), decoders_.end(),
- decoder->AsWeakPtr()),
+ decoders_.erase(std::remove_if(decoders_.begin(), decoders_.end(),
+ WeakPtrEquals<gles2::GLES2Decoder>(decoder)),
decoders_.end());
// If we still have contexts do nothing.
if (HaveContexts()) {
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index 2a686f2..3b41de6 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -5925,7 +5925,7 @@ TEST(HttpCache, SetPriority) {
// Shouldn't crash, but doesn't do anything either.
trans->SetPriority(net::LOW);
- EXPECT_FALSE(cache.network_layer()->last_transaction());
+ EXPECT_FALSE(cache.network_layer()->last_transaction().get());
EXPECT_EQ(net::DEFAULT_PRIORITY,
cache.network_layer()->last_create_transaction_priority());
@@ -5935,7 +5935,7 @@ TEST(HttpCache, SetPriority) {
EXPECT_EQ(net::ERR_IO_PENDING,
trans->Start(&info, callback.callback(), net::BoundNetLog()));
- ASSERT_TRUE(cache.network_layer()->last_transaction());
+ ASSERT_TRUE(cache.network_layer()->last_transaction().get());
EXPECT_EQ(net::LOW,
cache.network_layer()->last_create_transaction_priority());
EXPECT_EQ(net::LOW,
diff --git a/net/spdy/spdy_write_queue.cc b/net/spdy/spdy_write_queue.cc
index 2e17977..c793aab 100644
--- a/net/spdy/spdy_write_queue.cc
+++ b/net/spdy/spdy_write_queue.cc
@@ -71,7 +71,7 @@ void SpdyWriteQueue::RemovePendingWritesForStream(
continue;
for (std::deque<PendingWrite>::const_iterator it = queue_[i].begin();
it != queue_[i].end(); ++it) {
- DCHECK_NE(it->stream, stream);
+ DCHECK_NE(it->stream.get(), stream.get());
}
}
}
diff --git a/net/url_request/url_request_ftp_job_unittest.cc b/net/url_request/url_request_ftp_job_unittest.cc
index 3b4a790..a642abe 100644
--- a/net/url_request/url_request_ftp_job_unittest.cc
+++ b/net/url_request/url_request_ftp_job_unittest.cc
@@ -162,11 +162,11 @@ TEST_F(URLRequestFtpJobPriorityTest, SetTransactionPriorityOnStart) {
&req_, &ftp_factory_, &ftp_auth_cache_));
job->SetPriority(LOW);
- EXPECT_FALSE(network_layer_.last_transaction());
+ EXPECT_FALSE(network_layer_.last_transaction().get());
job->Start();
- ASSERT_TRUE(network_layer_.last_transaction());
+ ASSERT_TRUE(network_layer_.last_transaction().get());
EXPECT_EQ(LOW, network_layer_.last_transaction()->priority());
}
@@ -177,7 +177,7 @@ TEST_F(URLRequestFtpJobPriorityTest, SetTransactionPriority) {
&req_, &ftp_factory_, &ftp_auth_cache_));
job->SetPriority(LOW);
job->Start();
- ASSERT_TRUE(network_layer_.last_transaction());
+ ASSERT_TRUE(network_layer_.last_transaction().get());
EXPECT_EQ(LOW, network_layer_.last_transaction()->priority());
job->SetPriority(HIGHEST);
@@ -192,7 +192,7 @@ TEST_F(URLRequestFtpJobPriorityTest, SetSubsequentTransactionPriority) {
job->Start();
job->SetPriority(LOW);
- ASSERT_TRUE(network_layer_.last_transaction());
+ ASSERT_TRUE(network_layer_.last_transaction().get());
EXPECT_EQ(LOW, network_layer_.last_transaction()->priority());
job->Kill();
@@ -200,7 +200,7 @@ TEST_F(URLRequestFtpJobPriorityTest, SetSubsequentTransactionPriority) {
// Creates a second transaction.
job->Start();
- ASSERT_TRUE(network_layer_.last_transaction());
+ ASSERT_TRUE(network_layer_.last_transaction().get());
EXPECT_EQ(LOW, network_layer_.last_transaction()->priority());
}
diff --git a/net/url_request/url_request_http_job_unittest.cc b/net/url_request/url_request_http_job_unittest.cc
index 9469a67..1eba53e 100644
--- a/net/url_request/url_request_http_job_unittest.cc
+++ b/net/url_request/url_request_http_job_unittest.cc
@@ -75,11 +75,11 @@ TEST_F(URLRequestHttpJobTest, SetTransactionPriorityOnStart) {
scoped_refptr<TestURLRequestHttpJob> job(new TestURLRequestHttpJob(&req_));
job->SetPriority(LOW);
- EXPECT_FALSE(network_layer_.last_transaction());
+ EXPECT_FALSE(network_layer_.last_transaction().get());
job->Start();
- ASSERT_TRUE(network_layer_.last_transaction());
+ ASSERT_TRUE(network_layer_.last_transaction().get());
EXPECT_EQ(LOW, network_layer_.last_transaction()->priority());
}
@@ -89,7 +89,7 @@ TEST_F(URLRequestHttpJobTest, SetTransactionPriority) {
scoped_refptr<TestURLRequestHttpJob> job(new TestURLRequestHttpJob(&req_));
job->SetPriority(LOW);
job->Start();
- ASSERT_TRUE(network_layer_.last_transaction());
+ ASSERT_TRUE(network_layer_.last_transaction().get());
EXPECT_EQ(LOW, network_layer_.last_transaction()->priority());
job->SetPriority(HIGHEST);
@@ -103,7 +103,7 @@ TEST_F(URLRequestHttpJobTest, SetSubsequentTransactionPriority) {
job->Start();
job->SetPriority(LOW);
- ASSERT_TRUE(network_layer_.last_transaction());
+ ASSERT_TRUE(network_layer_.last_transaction().get());
EXPECT_EQ(LOW, network_layer_.last_transaction()->priority());
job->Kill();
@@ -111,7 +111,7 @@ TEST_F(URLRequestHttpJobTest, SetSubsequentTransactionPriority) {
// Creates a second transaction.
job->Start();
- ASSERT_TRUE(network_layer_.last_transaction());
+ ASSERT_TRUE(network_layer_.last_transaction().get());
EXPECT_EQ(LOW, network_layer_.last_transaction()->priority());
}
diff --git a/sync/internal_api/public/util/weak_handle.h b/sync/internal_api/public/util/weak_handle.h
index c299be7..24fccbc 100644
--- a/sync/internal_api/public/util/weak_handle.h
+++ b/sync/internal_api/public/util/weak_handle.h
@@ -208,7 +208,7 @@ class WeakHandleCore
template <typename U>
void DoCall0(void (U::*fn)(void)) const {
CHECK(IsOnOwnerThread());
- if (!Get()) {
+ if (!Get().get()) {
return;
}
(Get().get()->*fn)();
@@ -218,7 +218,7 @@ class WeakHandleCore
void DoCall1(void (U::*fn)(A1),
typename ParamTraits<A1>::ForwardType a1) const {
CHECK(IsOnOwnerThread());
- if (!Get()) {
+ if (!Get().get()) {
return;
}
(Get().get()->*fn)(a1);
@@ -229,7 +229,7 @@ class WeakHandleCore
typename ParamTraits<A1>::ForwardType a1,
typename ParamTraits<A2>::ForwardType a2) const {
CHECK(IsOnOwnerThread());
- if (!Get()) {
+ if (!Get().get()) {
return;
}
(Get().get()->*fn)(a1, a2);
@@ -241,7 +241,7 @@ class WeakHandleCore
typename ParamTraits<A2>::ForwardType a2,
typename ParamTraits<A3>::ForwardType a3) const {
CHECK(IsOnOwnerThread());
- if (!Get()) {
+ if (!Get().get()) {
return;
}
(Get().get()->*fn)(a1, a2, a3);
@@ -254,7 +254,7 @@ class WeakHandleCore
typename ParamTraits<A3>::ForwardType a3,
typename ParamTraits<A4>::ForwardType a4) const {
CHECK(IsOnOwnerThread());
- if (!Get()) {
+ if (!Get().get()) {
return;
}
(Get().get()->*fn)(a1, a2, a3, a4);
diff --git a/sync/internal_api/public/util/weak_handle_unittest.cc b/sync/internal_api/public/util/weak_handle_unittest.cc
index 56dfe7f..c8ba1ef 100644
--- a/sync/internal_api/public/util/weak_handle_unittest.cc
+++ b/sync/internal_api/public/util/weak_handle_unittest.cc
@@ -97,7 +97,7 @@ TEST_F(WeakHandleTest, InitializedAfterDestroy) {
h = b.AsWeakHandle();
}
EXPECT_TRUE(h.IsInitialized());
- EXPECT_FALSE(h.Get());
+ EXPECT_FALSE(h.Get().get());
}
TEST_F(WeakHandleTest, InitializedAfterInvalidate) {
@@ -105,7 +105,7 @@ TEST_F(WeakHandleTest, InitializedAfterInvalidate) {
WeakHandle<Base> h = b.AsWeakHandle();
b.Kill();
EXPECT_TRUE(h.IsInitialized());
- EXPECT_FALSE(h.Get());
+ EXPECT_FALSE(h.Get().get());
}
TEST_F(WeakHandleTest, Call) {
diff --git a/webkit/browser/quota/quota_manager.cc b/webkit/browser/quota/quota_manager.cc
index 54d8c13..b2c78b0 100644
--- a/webkit/browser/quota/quota_manager.cc
+++ b/webkit/browser/quota/quota_manager.cc
@@ -709,7 +709,7 @@ class QuotaManager::GetModifiedSinceHelper {
const GetOriginsCallback& callback,
StorageType type,
bool success) {
- if (!manager) {
+ if (!manager.get()) {
// The operation was aborted.
callback.Run(std::set<GURL>(), type);
return;
@@ -734,7 +734,7 @@ class QuotaManager::DumpQuotaTableHelper {
void DidDumpQuotaTable(const base::WeakPtr<QuotaManager>& manager,
const DumpQuotaTableCallback& callback,
bool success) {
- if (!manager) {
+ if (!manager.get()) {
// The operation was aborted.
callback.Run(QuotaTableEntries());
return;
@@ -766,7 +766,7 @@ class QuotaManager::DumpOriginInfoTableHelper {
void DidDumpOriginInfoTable(const base::WeakPtr<QuotaManager>& manager,
const DumpOriginInfoTableCallback& callback,
bool success) {
- if (!manager) {
+ if (!manager.get()) {
// The operation was aborted.
callback.Run(OriginInfoTableEntries());
return;