Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Unified Diff: chrome/browser/extensions/extension_info_map_unittest.cc

Issue 4200005: Part 4/4 of immutable Extension refactor: Kill Extension::StaticData and put (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_info_map_unittest.cc
diff --git a/chrome/browser/extensions/extension_info_map_unittest.cc b/chrome/browser/extensions/extension_info_map_unittest.cc
index e417d23a5265feae7c4408f608465684a9ecc2ba..d4892d1b47a655abf38a504c9f830056495561a5 100644
--- a/chrome/browser/extensions/extension_info_map_unittest.cc
+++ b/chrome/browser/extensions/extension_info_map_unittest.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/extensions/extension_info_map.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/extensions/extension.h"
#include "chrome/common/json_value_serializer.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -73,37 +74,36 @@ static scoped_refptr<Extension> LoadManifest(const std::string& dir,
TEST_F(ExtensionInfoMapTest, RefCounting) {
scoped_refptr<ExtensionInfoMap> info_map(new ExtensionInfoMap());
- // New extensions should have a single reference holding onto their static
- // data.
+ // New extensions should have a single reference holding onto them.
scoped_refptr<Extension> extension1(CreateExtension("extension1"));
scoped_refptr<Extension> extension2(CreateExtension("extension2"));
scoped_refptr<Extension> extension3(CreateExtension("extension3"));
- EXPECT_TRUE(extension1->static_data()->HasOneRef());
- EXPECT_TRUE(extension2->static_data()->HasOneRef());
- EXPECT_TRUE(extension3->static_data()->HasOneRef());
+ EXPECT_TRUE(extension1->HasOneRef());
+ EXPECT_TRUE(extension2->HasOneRef());
+ EXPECT_TRUE(extension3->HasOneRef());
// Add a ref to each extension and give it to the info map. The info map
// expects the caller to add a ref for it, but then assumes ownership of that
// reference.
- extension1->static_data()->AddRef();
- info_map->AddExtension(extension1->static_data());
- extension2->static_data()->AddRef();
- info_map->AddExtension(extension2->static_data());
- extension3->static_data()->AddRef();
- info_map->AddExtension(extension3->static_data());
-
- // Delete extension1, and the info map should have the only ref.
- const Extension::StaticData* data1 = extension1->static_data();
+ extension1->AddRef();
+ info_map->AddExtension(extension1);
+ extension2->AddRef();
+ info_map->AddExtension(extension2);
+ extension3->AddRef();
+ info_map->AddExtension(extension3);
+
+ // Release extension1, and the info map should have the only ref.
+ const Extension* weak_extension1 = extension1;
extension1 = NULL;
- EXPECT_TRUE(data1->HasOneRef());
+ EXPECT_TRUE(weak_extension1->HasOneRef());
// Remove extension2, and the extension2 object should have the only ref.
info_map->RemoveExtension(extension2->id());
- EXPECT_TRUE(extension2->static_data()->HasOneRef());
+ EXPECT_TRUE(extension2->HasOneRef());
// Delete the info map, and the extension3 object should have the only ref.
info_map = NULL;
- EXPECT_TRUE(extension3->static_data()->HasOneRef());
+ EXPECT_TRUE(extension3->HasOneRef());
}
// Tests that we can query a few extension properties from the ExtensionInfoMap.
@@ -113,10 +113,10 @@ TEST_F(ExtensionInfoMapTest, Properties) {
scoped_refptr<Extension> extension1(CreateExtension("extension1"));
scoped_refptr<Extension> extension2(CreateExtension("extension2"));
- extension1->static_data()->AddRef();
- info_map->AddExtension(extension1->static_data());
- extension2->static_data()->AddRef();
- info_map->AddExtension(extension2->static_data());
+ extension1->AddRef();
+ info_map->AddExtension(extension1);
+ extension2->AddRef();
+ info_map->AddExtension(extension2);
EXPECT_EQ(extension1->name(),
info_map->GetNameForExtension(extension1->id()));
@@ -142,10 +142,10 @@ TEST_F(ExtensionInfoMapTest, CheckPermissions) {
ASSERT_TRUE(app->is_app());
ASSERT_TRUE(app->web_extent().ContainsURL(app_url));
- app->static_data()->AddRef();
- info_map->AddExtension(app->static_data());
- extension->static_data()->AddRef();
- info_map->AddExtension(extension->static_data());
+ app->AddRef();
+ info_map->AddExtension(app);
+ extension->AddRef();
+ info_map->AddExtension(extension);
// The app should have the notifications permission, either from a
// chrome-extension URL or from its web extent.

Powered by Google App Engine
This is Rietveld 408576698