Commit 76e64e4c authored by Kevin McNee's avatar Kevin McNee Committed by Commit Bot

Use static_cast instead of reinterpret_cast for downcasting

static_cast is better suited for downcasting since it can check that the
types are related.

/content/browser/appcache
This CL was uploaded by git cl split.

R=mek@chromium.org

Change-Id: Ic95365fb8db7002cb97aa7b2a3a22ac6173e37d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2435700
Auto-Submit: Kevin McNee <mcnee@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811330}
parent cdd3b3b8
...@@ -691,7 +691,7 @@ class AppCacheRequestHandlerTest : public ::testing::Test { ...@@ -691,7 +691,7 @@ class AppCacheRequestHandlerTest : public ::testing::Test {
void OnBadMessage(const std::string& reason) { NOTREACHED(); } void OnBadMessage(const std::string& reason) { NOTREACHED(); }
MockAppCacheStorage* mock_storage() { MockAppCacheStorage* mock_storage() {
return reinterpret_cast<MockAppCacheStorage*>(mock_service_->storage()); return static_cast<MockAppCacheStorage*>(mock_service_->storage());
} }
void CreateRequestAndHandler(const GURL& url, void CreateRequestAndHandler(const GURL& url,
......
...@@ -2463,7 +2463,7 @@ class AppCacheUpdateJobTest : public testing::Test, ...@@ -2463,7 +2463,7 @@ class AppCacheUpdateJobTest : public testing::Test,
void FailStoreNewestCacheTest() { void FailStoreNewestCacheTest() {
MakeService(); MakeService();
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service_->storage()); static_cast<MockAppCacheStorage*>(service_->storage());
storage->SimulateStoreGroupAndNewestCacheFailure(); storage->SimulateStoreGroupAndNewestCacheFailure();
group_ = base::MakeRefCounted<AppCacheGroup>( group_ = base::MakeRefCounted<AppCacheGroup>(
...@@ -2490,7 +2490,7 @@ class AppCacheUpdateJobTest : public testing::Test, ...@@ -2490,7 +2490,7 @@ class AppCacheUpdateJobTest : public testing::Test,
void UpgradeFailStoreNewestCacheTest() { void UpgradeFailStoreNewestCacheTest() {
MakeService(); MakeService();
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service_->storage()); static_cast<MockAppCacheStorage*>(service_->storage());
storage->SimulateStoreGroupAndNewestCacheFailure(); storage->SimulateStoreGroupAndNewestCacheFailure();
group_ = base::MakeRefCounted<AppCacheGroup>( group_ = base::MakeRefCounted<AppCacheGroup>(
...@@ -2543,7 +2543,7 @@ class AppCacheUpdateJobTest : public testing::Test, ...@@ -2543,7 +2543,7 @@ class AppCacheUpdateJobTest : public testing::Test,
void MasterEntryFailStoreNewestCacheTest() { void MasterEntryFailStoreNewestCacheTest() {
MakeService(); MakeService();
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service_->storage()); static_cast<MockAppCacheStorage*>(service_->storage());
storage->SimulateStoreGroupAndNewestCacheFailure(); storage->SimulateStoreGroupAndNewestCacheFailure();
const GURL kManifestUrl = MockHttpServer::GetMockUrl("files/notmodified"); const GURL kManifestUrl = MockHttpServer::GetMockUrl("files/notmodified");
...@@ -2589,7 +2589,7 @@ class AppCacheUpdateJobTest : public testing::Test, ...@@ -2589,7 +2589,7 @@ class AppCacheUpdateJobTest : public testing::Test,
void UpgradeFailMakeGroupObsoleteTest() { void UpgradeFailMakeGroupObsoleteTest() {
MakeService(); MakeService();
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service_->storage()); static_cast<MockAppCacheStorage*>(service_->storage());
storage->SimulateMakeGroupObsoleteFailure(); storage->SimulateMakeGroupObsoleteFailure();
group_ = base::MakeRefCounted<AppCacheGroup>( group_ = base::MakeRefCounted<AppCacheGroup>(
...@@ -4528,7 +4528,7 @@ class AppCacheUpdateJobTest : public testing::Test, ...@@ -4528,7 +4528,7 @@ class AppCacheUpdateJobTest : public testing::Test,
!group_->first_evictable_error_time().is_null()); !group_->first_evictable_error_time().is_null());
if (expect_evictable_error_) { if (expect_evictable_error_) {
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service_->storage()); static_cast<MockAppCacheStorage*>(service_->storage());
EXPECT_EQ(group_->first_evictable_error_time(), EXPECT_EQ(group_->first_evictable_error_time(),
storage->stored_eviction_times_[group_->group_id()].second); storage->stored_eviction_times_[group_->group_id()].second);
} }
...@@ -4563,7 +4563,7 @@ class AppCacheUpdateJobTest : public testing::Test, ...@@ -4563,7 +4563,7 @@ class AppCacheUpdateJobTest : public testing::Test,
// is unknown to the test). Check group and newest cache were stored // is unknown to the test). Check group and newest cache were stored
// when update succeeds. // when update succeeds.
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service_->storage()); static_cast<MockAppCacheStorage*>(service_->storage());
EXPECT_TRUE(storage->IsGroupStored(group_.get())); EXPECT_TRUE(storage->IsGroupStored(group_.get()));
EXPECT_TRUE(storage->IsCacheStored(group_->newest_complete_cache())); EXPECT_TRUE(storage->IsCacheStored(group_->newest_complete_cache()));
......
...@@ -123,7 +123,7 @@ TEST_F(MockAppCacheStorageTest, CreateGroup) { ...@@ -123,7 +123,7 @@ TEST_F(MockAppCacheStorageTest, CreateGroup) {
// Should complete asyncly. // Should complete asyncly.
MockAppCacheService service; MockAppCacheService service;
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service.storage()); static_cast<MockAppCacheStorage*>(service.storage());
MockStorageDelegate delegate; MockStorageDelegate delegate;
GURL manifest_url("http://blah/"); GURL manifest_url("http://blah/");
service.storage()->LoadOrCreateGroup(manifest_url, &delegate); service.storage()->LoadOrCreateGroup(manifest_url, &delegate);
...@@ -169,7 +169,7 @@ TEST_F(MockAppCacheStorageTest, LoadGroupAndCache_FarHit) { ...@@ -169,7 +169,7 @@ TEST_F(MockAppCacheStorageTest, LoadGroupAndCache_FarHit) {
// load should complete asyncly. // load should complete asyncly.
MockAppCacheService service; MockAppCacheService service;
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service.storage()); static_cast<MockAppCacheStorage*>(service.storage());
// Setup some preconditions. Create a group and newest cache that // Setup some preconditions. Create a group and newest cache that
// appears to be "stored" and "not currently in use". // appears to be "stored" and "not currently in use".
...@@ -220,7 +220,7 @@ TEST_F(MockAppCacheStorageTest, StoreNewGroup) { ...@@ -220,7 +220,7 @@ TEST_F(MockAppCacheStorageTest, StoreNewGroup) {
// Store a group and its newest cache. Should complete asyncly. // Store a group and its newest cache. Should complete asyncly.
MockAppCacheService service; MockAppCacheService service;
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service.storage()); static_cast<MockAppCacheStorage*>(service.storage());
// Setup some preconditions. Create a group and newest cache that // Setup some preconditions. Create a group and newest cache that
// appears to be "unstored". // appears to be "unstored".
...@@ -252,7 +252,7 @@ TEST_F(MockAppCacheStorageTest, StoreExistingGroup) { ...@@ -252,7 +252,7 @@ TEST_F(MockAppCacheStorageTest, StoreExistingGroup) {
// Store a group and its newest cache. Should complete asyncly. // Store a group and its newest cache. Should complete asyncly.
MockAppCacheService service; MockAppCacheService service;
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service.storage()); static_cast<MockAppCacheStorage*>(service.storage());
// Setup some preconditions. Create a group and old complete cache // Setup some preconditions. Create a group and old complete cache
// that appear to be "stored", and a newest unstored complete cache. // that appear to be "stored", and a newest unstored complete cache.
...@@ -297,7 +297,7 @@ TEST_F(MockAppCacheStorageTest, StoreExistingGroupExistingCache) { ...@@ -297,7 +297,7 @@ TEST_F(MockAppCacheStorageTest, StoreExistingGroupExistingCache) {
// Store a group with updates to its existing newest complete cache. // Store a group with updates to its existing newest complete cache.
MockAppCacheService service; MockAppCacheService service;
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service.storage()); static_cast<MockAppCacheStorage*>(service.storage());
// Setup some preconditions. Create a group and a complete cache that // Setup some preconditions. Create a group and a complete cache that
// appear to be "stored". // appear to be "stored".
...@@ -339,7 +339,7 @@ TEST_F(MockAppCacheStorageTest, MakeGroupObsolete) { ...@@ -339,7 +339,7 @@ TEST_F(MockAppCacheStorageTest, MakeGroupObsolete) {
// Make a group obsolete, should complete asyncly. // Make a group obsolete, should complete asyncly.
MockAppCacheService service; MockAppCacheService service;
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service.storage()); static_cast<MockAppCacheStorage*>(service.storage());
// Setup some preconditions. Create a group and newest cache that // Setup some preconditions. Create a group and newest cache that
// appears to be "stored" and "currently in use". // appears to be "stored" and "currently in use".
...@@ -384,7 +384,7 @@ TEST_F(MockAppCacheStorageTest, MarkEntryAsForeign) { ...@@ -384,7 +384,7 @@ TEST_F(MockAppCacheStorageTest, MarkEntryAsForeign) {
// Should complete syncly. // Should complete syncly.
MockAppCacheService service; MockAppCacheService service;
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service.storage()); static_cast<MockAppCacheStorage*>(service.storage());
// Setup some preconditions. Create a cache with an entry. // Setup some preconditions. Create a cache with an entry.
GURL entry_url("http://blah/entry"); GURL entry_url("http://blah/entry");
...@@ -404,7 +404,7 @@ TEST_F(MockAppCacheStorageTest, FindNoMainResponse) { ...@@ -404,7 +404,7 @@ TEST_F(MockAppCacheStorageTest, FindNoMainResponse) {
// Should complete asyncly. // Should complete asyncly.
MockAppCacheService service; MockAppCacheService service;
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service.storage()); static_cast<MockAppCacheStorage*>(service.storage());
// Conduct the test. // Conduct the test.
MockStorageDelegate delegate; MockStorageDelegate delegate;
...@@ -429,7 +429,7 @@ TEST_F(MockAppCacheStorageTest, BasicFindMainResponse) { ...@@ -429,7 +429,7 @@ TEST_F(MockAppCacheStorageTest, BasicFindMainResponse) {
// Should complete asyncly. // Should complete asyncly.
MockAppCacheService service; MockAppCacheService service;
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service.storage()); static_cast<MockAppCacheStorage*>(service.storage());
// Setup some preconditions. Create a complete cache with an entry. // Setup some preconditions. Create a complete cache with an entry.
const int64_t kCacheId = storage->NewCacheId(); const int64_t kCacheId = storage->NewCacheId();
...@@ -464,7 +464,7 @@ TEST_F(MockAppCacheStorageTest, BasicFindMainFallbackResponse) { ...@@ -464,7 +464,7 @@ TEST_F(MockAppCacheStorageTest, BasicFindMainFallbackResponse) {
// Should complete asyncly. // Should complete asyncly.
MockAppCacheService service; MockAppCacheService service;
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service.storage()); static_cast<MockAppCacheStorage*>(service.storage());
// Setup some preconditions. Create a complete cache with a // Setup some preconditions. Create a complete cache with a
// fallback namespace and entry. // fallback namespace and entry.
...@@ -520,7 +520,7 @@ TEST_F(MockAppCacheStorageTest, FindMainResponseWithMultipleCandidates) { ...@@ -520,7 +520,7 @@ TEST_F(MockAppCacheStorageTest, FindMainResponseWithMultipleCandidates) {
// Should complete asyncly. // Should complete asyncly.
MockAppCacheService service; MockAppCacheService service;
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service.storage()); static_cast<MockAppCacheStorage*>(service.storage());
// Setup some preconditions. Create 2 complete caches with an entry // Setup some preconditions. Create 2 complete caches with an entry
// for the same url. // for the same url.
...@@ -577,7 +577,7 @@ TEST_F(MockAppCacheStorageTest, FindMainResponseExclusions) { ...@@ -577,7 +577,7 @@ TEST_F(MockAppCacheStorageTest, FindMainResponseExclusions) {
// Should complete asyncly. // Should complete asyncly.
MockAppCacheService service; MockAppCacheService service;
MockAppCacheStorage* storage = MockAppCacheStorage* storage =
reinterpret_cast<MockAppCacheStorage*>(service.storage()); static_cast<MockAppCacheStorage*>(service.storage());
// Setup some preconditions. Create a complete cache with a // Setup some preconditions. Create a complete cache with a
// foreign entry and an online namespace. // foreign entry and an online namespace.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment