Skip to content

Commit

Permalink
Update chrome/ to use scoped_refptr<T>::get() rather than implicit "o…
Browse files Browse the repository at this point in the history
…perator T*"

Linux fixes, Part 1 of N

BUG=110610
TBR=darin

Review URL: https://chromiumcodereview.appspot.com/15836003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203632 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
rsleevi@chromium.org committed Jun 2, 2013
1 parent e2716a5 commit 5c6ac84
Show file tree
Hide file tree
Showing 75 changed files with 648 additions and 623 deletions.
2 changes: 1 addition & 1 deletion chrome/common/automation_messages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ struct ParamTraits<net::UploadElement> {
void ParamTraits<scoped_refptr<net::UploadData> >::Write(Message* m,
const param_type& p) {
WriteParam(m, p.get() != NULL);
if (p) {
if (p.get()) {
WriteParam(m, p->elements());
WriteParam(m, p->identifier());
WriteParam(m, p->is_chunked());
Expand Down
49 changes: 19 additions & 30 deletions chrome/common/cancelable_task_tracker_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,14 @@ TEST_F(CancelableTaskTrackerTest, CancelAll) {
scoped_refptr<base::TestSimpleTaskRunner> test_task_runner(
new base::TestSimpleTaskRunner());

ignore_result(
task_tracker_.PostTask(
test_task_runner,
FROM_HERE,
MakeExpectedNotRunClosure(FROM_HERE)));
ignore_result(task_tracker_.PostTask(
test_task_runner.get(), FROM_HERE, MakeExpectedNotRunClosure(FROM_HERE)));

ignore_result(
task_tracker_.PostTaskAndReply(
test_task_runner,
FROM_HERE,
MakeExpectedNotRunClosure(FROM_HERE),
MakeExpectedNotRunClosure(FROM_HERE)));
task_tracker_.PostTaskAndReply(test_task_runner.get(),
FROM_HERE,
MakeExpectedNotRunClosure(FROM_HERE),
MakeExpectedNotRunClosure(FROM_HERE)));

CancelableTaskTracker::IsCanceledCallback is_canceled;
ignore_result(task_tracker_.NewTrackedTaskId(&is_canceled));
Expand Down Expand Up @@ -269,18 +265,15 @@ TEST_F(CancelableTaskTrackerTest, DestructionCancelsAll) {
// Create another task tracker with a smaller scope.
CancelableTaskTracker task_tracker;

ignore_result(
task_tracker.PostTask(
test_task_runner,
FROM_HERE,
MakeExpectedNotRunClosure(FROM_HERE)));
ignore_result(task_tracker.PostTask(test_task_runner.get(),
FROM_HERE,
MakeExpectedNotRunClosure(FROM_HERE)));

ignore_result(
task_tracker.PostTaskAndReply(
test_task_runner,
FROM_HERE,
MakeExpectedNotRunClosure(FROM_HERE),
MakeExpectedNotRunClosure(FROM_HERE)));
task_tracker.PostTaskAndReply(test_task_runner.get(),
FROM_HERE,
MakeExpectedNotRunClosure(FROM_HERE),
MakeExpectedNotRunClosure(FROM_HERE)));

ignore_result(task_tracker_.NewTrackedTaskId(&is_canceled));
}
Expand All @@ -301,11 +294,8 @@ TEST_F(CancelableTaskTrackerTest, HasTrackedTasksPost) {

EXPECT_FALSE(task_tracker_.HasTrackedTasks());

ignore_result(
task_tracker_.PostTask(
test_task_runner,
FROM_HERE,
MakeExpectedNotRunClosure(FROM_HERE)));
ignore_result(task_tracker_.PostTask(
test_task_runner.get(), FROM_HERE, MakeExpectedNotRunClosure(FROM_HERE)));

task_tracker_.TryCancelAll();

Expand All @@ -327,11 +317,10 @@ TEST_F(CancelableTaskTrackerTest, HasTrackedTasksPostWithReply) {
EXPECT_FALSE(task_tracker_.HasTrackedTasks());

ignore_result(
task_tracker_.PostTaskAndReply(
test_task_runner,
FROM_HERE,
MakeExpectedNotRunClosure(FROM_HERE),
MakeExpectedNotRunClosure(FROM_HERE)));
task_tracker_.PostTaskAndReply(test_task_runner.get(),
FROM_HERE,
MakeExpectedNotRunClosure(FROM_HERE),
MakeExpectedNotRunClosure(FROM_HERE)));

task_tracker_.TryCancelAll();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ TEST_F(CommandsManifestTest, CommandManifestSimple) {

scoped_refptr<Extension> extension =
LoadAndExpectSuccess("command_simple.json");
ASSERT_TRUE(extension);
ASSERT_TRUE(extension.get());

const CommandMap* commands = CommandsInfo::GetNamedCommands(extension);
const CommandMap* commands = CommandsInfo::GetNamedCommands(extension.get());
ASSERT_TRUE(commands);
ASSERT_EQ(1u, commands->size());
CommandMap::const_iterator iter = commands->begin();
Expand All @@ -45,14 +45,15 @@ TEST_F(CommandsManifestTest, CommandManifestSimple) {
ASSERT_EQ(ctrl_shift_f, named_command->accelerator());

const Command* browser_action =
CommandsInfo::GetBrowserActionCommand(extension);
CommandsInfo::GetBrowserActionCommand(extension.get());
ASSERT_TRUE(NULL != browser_action);
ASSERT_STREQ("_execute_browser_action",
browser_action->command_name().c_str());
ASSERT_STREQ("", UTF16ToASCII(browser_action->description()).c_str());
ASSERT_EQ(alt_shift_f, browser_action->accelerator());

const Command* page_action = CommandsInfo::GetPageActionCommand(extension);
const Command* page_action =
CommandsInfo::GetPageActionCommand(extension.get());
ASSERT_TRUE(NULL != page_action);
ASSERT_STREQ("_execute_page_action",
page_action->command_name().c_str());
Expand Down Expand Up @@ -86,7 +87,7 @@ TEST_F(CommandsManifestTest, BrowserActionSynthesizesCommand) {
// An extension with a browser action but no extension command specified
// should get a command assigned to it.
const extensions::Command* command =
CommandsInfo::GetBrowserActionCommand(extension);
CommandsInfo::GetBrowserActionCommand(extension.get());
ASSERT_TRUE(command != NULL);
ASSERT_EQ(ui::VKEY_UNKNOWN, command->accelerator().key_code());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TEST_F(BrowserActionManifestTest,

ASSERT_TRUE(extension.get());
const ActionInfo* browser_action_info =
ActionInfo::GetBrowserActionInfo(extension);
ActionInfo::GetBrowserActionInfo(extension.get());
ASSERT_TRUE(browser_action_info);
EXPECT_TRUE(browser_action_info->default_icon.empty());
}
Expand All @@ -52,7 +52,7 @@ TEST_F(BrowserActionManifestTest,

ASSERT_TRUE(extension.get());
const ActionInfo* browser_action_info =
ActionInfo::GetBrowserActionInfo(extension);
ActionInfo::GetBrowserActionInfo(extension.get());
ASSERT_TRUE(browser_action_info);
ASSERT_FALSE(browser_action_info->default_icon.empty());

Expand All @@ -79,7 +79,7 @@ TEST_F(BrowserActionManifestTest,

ASSERT_TRUE(extension.get());
const ActionInfo* browser_action_info =
ActionInfo::GetBrowserActionInfo(extension);
ActionInfo::GetBrowserActionInfo(extension.get());
ASSERT_TRUE(browser_action_info);
ASSERT_FALSE(browser_action_info->default_icon.empty());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ scoped_ptr<ActionInfo> PageActionManifestTest::LoadAction(
const std::string& manifest_filename) {
scoped_refptr<Extension> extension = LoadAndExpectSuccess(
manifest_filename.c_str());
const ActionInfo* page_action_info = ActionInfo::GetPageActionInfo(extension);
const ActionInfo* page_action_info =
ActionInfo::GetPageActionInfo(extension.get());
EXPECT_TRUE(page_action_info);
if (page_action_info) {
return make_scoped_ptr(new ActionInfo(*page_action_info));
Expand All @@ -40,8 +41,9 @@ scoped_ptr<ActionInfo> PageActionManifestTest::LoadAction(
TEST_F(PageActionManifestTest, ManifestVersion2) {
scoped_refptr<Extension> extension(
LoadAndExpectSuccess("page_action_manifest_version_2.json"));
ASSERT_TRUE(extension);
const ActionInfo* page_action_info = ActionInfo::GetPageActionInfo(extension);
ASSERT_TRUE(extension.get());
const ActionInfo* page_action_info =
ActionInfo::GetPageActionInfo(extension.get());
ASSERT_TRUE(page_action_info);

EXPECT_EQ("", page_action_info->id);
Expand Down Expand Up @@ -121,7 +123,8 @@ TEST_F(PageActionManifestTest, LoadPageActionHelper) {
// Only use "popup", expect success.
scoped_refptr<Extension> extension =
LoadAndExpectSuccess("page_action_popup.json");
const ActionInfo* extension_action = ActionInfo::GetPageActionInfo(extension);
const ActionInfo* extension_action =
ActionInfo::GetPageActionInfo(extension.get());
ASSERT_TRUE(extension_action);
ASSERT_STREQ(
extension->url().Resolve(kPopupHtmlFile).spec().c_str(),
Expand All @@ -136,7 +139,7 @@ TEST_F(PageActionManifestTest, LoadPageActionHelper) {

// Use only "default_popup", expect success.
extension = LoadAndExpectSuccess("page_action_popup.json");
extension_action = ActionInfo::GetPageActionInfo(extension);
extension_action = ActionInfo::GetPageActionInfo(extension.get());
ASSERT_TRUE(extension_action);
ASSERT_STREQ(
extension->url().Resolve(kPopupHtmlFile).spec().c_str(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ TEST_F(ScriptBadgeManifestTest, ScriptBadgeBasic) {
.Build());
ASSERT_TRUE(extension.get());
const ActionInfo* script_badge_info =
ActionInfo::GetScriptBadgeInfo(extension);
ActionInfo::GetScriptBadgeInfo(extension.get());
ASSERT_TRUE(script_badge_info);
EXPECT_THAT(StripMissingFlagWarning(extension->install_warnings()),
testing::ElementsAre(/*empty*/));
Expand Down Expand Up @@ -93,7 +93,7 @@ TEST_F(ScriptBadgeManifestTest, ScriptBadgeExplicitTitleAndIconsIgnored) {
.Build());
ASSERT_TRUE(extension.get());
const ActionInfo* script_badge_info =
ActionInfo::GetScriptBadgeInfo(extension);
ActionInfo::GetScriptBadgeInfo(extension.get());
ASSERT_TRUE(script_badge_info);

EXPECT_THAT(StripMissingFlagWarning(extension->install_warnings()),
Expand Down Expand Up @@ -129,7 +129,7 @@ TEST_F(ScriptBadgeManifestTest, ScriptBadgeIconFallsBackToPuzzlePiece) {
.Build());
ASSERT_TRUE(extension.get());
const ActionInfo* script_badge_info =
ActionInfo::GetScriptBadgeInfo(extension);
ActionInfo::GetScriptBadgeInfo(extension.get());
ASSERT_TRUE(script_badge_info);
EXPECT_THAT(extension->install_warnings(),
testing::ElementsAre(/*empty*/));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TEST_F(DefaultLocaleManifestTest, DefaultLocale) {

scoped_refptr<Extension> extension(
LoadAndExpectSuccess("default_locale_valid.json"));
EXPECT_EQ("de-AT", LocaleInfo::GetDefaultLocale(extension));
EXPECT_EQ("de-AT", LocaleInfo::GetDefaultLocale(extension.get()));
}

} // namespace extensions
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ TEST_F(OAuth2ManifestTest, OAuth2SectionParsing) {
scoped_refptr<extensions::Extension> extension =
LoadAndExpectSuccess(manifest);
EXPECT_TRUE(extension->install_warnings().empty());
EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension).client_id);
EXPECT_EQ(2U, OAuth2Info::GetOAuth2Info(extension).scopes.size());
EXPECT_EQ("scope1", OAuth2Info::GetOAuth2Info(extension).scopes[0]);
EXPECT_EQ("scope2", OAuth2Info::GetOAuth2Info(extension).scopes[1]);
EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension.get()).client_id);
EXPECT_EQ(2U, OAuth2Info::GetOAuth2Info(extension.get()).scopes.size());
EXPECT_EQ("scope1", OAuth2Info::GetOAuth2Info(extension.get()).scopes[0]);
EXPECT_EQ("scope2", OAuth2Info::GetOAuth2Info(extension.get()).scopes[1]);
}

// OAuth2 section should be parsed for a packaged app.
Expand All @@ -54,10 +54,10 @@ TEST_F(OAuth2ManifestTest, OAuth2SectionParsing) {
scoped_refptr<extensions::Extension> extension =
LoadAndExpectSuccess(manifest);
EXPECT_TRUE(extension->install_warnings().empty());
EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension).client_id);
EXPECT_EQ(2U, OAuth2Info::GetOAuth2Info(extension).scopes.size());
EXPECT_EQ("scope1", OAuth2Info::GetOAuth2Info(extension).scopes[0]);
EXPECT_EQ("scope2", OAuth2Info::GetOAuth2Info(extension).scopes[1]);
EXPECT_EQ("client1", OAuth2Info::GetOAuth2Info(extension.get()).client_id);
EXPECT_EQ(2U, OAuth2Info::GetOAuth2Info(extension.get()).scopes.size());
EXPECT_EQ("scope1", OAuth2Info::GetOAuth2Info(extension.get()).scopes[0]);
EXPECT_EQ("scope2", OAuth2Info::GetOAuth2Info(extension.get()).scopes[1]);
}

// OAuth2 section should NOT be parsed for a hosted app.
Expand All @@ -75,8 +75,8 @@ TEST_F(OAuth2ManifestTest, OAuth2SectionParsing) {
EXPECT_EQ("'oauth2' is only allowed for extensions, legacy packaged apps "
"and packaged apps, and this is a hosted app.",
warning.message);
EXPECT_EQ("", OAuth2Info::GetOAuth2Info(extension).client_id);
EXPECT_TRUE(OAuth2Info::GetOAuth2Info(extension).scopes.empty());
EXPECT_EQ("", OAuth2Info::GetOAuth2Info(extension.get()).client_id);
EXPECT_TRUE(OAuth2Info::GetOAuth2Info(extension.get()).scopes.empty());
}
}

Expand Down
39 changes: 19 additions & 20 deletions chrome/common/extensions/extension_file_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ TEST_F(ExtensionFileUtilTest, LoadExtensionWithValidLocales) {
std::string error;
scoped_refptr<Extension> extension(extension_file_util::LoadExtension(
install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
ASSERT_TRUE(extension != NULL);
ASSERT_TRUE(extension.get() != NULL);
EXPECT_EQ("The first extension that I made.", extension->description());
}

Expand All @@ -130,7 +130,7 @@ TEST_F(ExtensionFileUtilTest, LoadExtensionWithoutLocalesFolder) {
std::string error;
scoped_refptr<Extension> extension(extension_file_util::LoadExtension(
install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
ASSERT_FALSE(extension == NULL);
ASSERT_FALSE(extension.get() == NULL);
EXPECT_TRUE(error.empty());
}

Expand Down Expand Up @@ -194,7 +194,7 @@ TEST_F(ExtensionFileUtilTest,
std::string error;
scoped_refptr<Extension> extension(extension_file_util::LoadExtension(
install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
ASSERT_TRUE(extension == NULL);
ASSERT_TRUE(extension.get() == NULL);
ASSERT_FALSE(error.empty());
ASSERT_STREQ("Manifest file is missing or unreadable.", error.c_str());
}
Expand All @@ -211,7 +211,7 @@ TEST_F(ExtensionFileUtilTest, LoadExtensionGivesHelpfullErrorOnBadManifest) {
std::string error;
scoped_refptr<Extension> extension(extension_file_util::LoadExtension(
install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
ASSERT_TRUE(extension == NULL);
ASSERT_TRUE(extension.get() == NULL);
ASSERT_FALSE(error.empty());
ASSERT_STREQ("Manifest is not valid JSON. "
"Line: 2, column: 16, Syntax error.", error.c_str());
Expand All @@ -227,9 +227,10 @@ TEST_F(ExtensionFileUtilTest, FailLoadingNonUTF8Scripts) {
std::string error;
scoped_refptr<Extension> extension(extension_file_util::LoadExtension(
install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
ASSERT_TRUE(extension == NULL);
ASSERT_TRUE(extension.get() == NULL);
ASSERT_STREQ("Could not load file 'bad_encoding.js' for content script. "
"It isn't UTF-8 encoded.", error.c_str());
"It isn't UTF-8 encoded.",
error.c_str());
}

TEST_F(ExtensionFileUtilTest, ExtensionURLToRelativeFilePath) {
Expand Down Expand Up @@ -392,9 +393,8 @@ TEST_F(ExtensionFileUtilTest, ValidateThemeUTF8) {
ASSERT_TRUE(extension.get()) << error;

std::vector<extensions::InstallWarning> warnings;
EXPECT_TRUE(extension_file_util::ValidateExtension(extension,
&error, &warnings)) <<
error;
EXPECT_TRUE(extension_file_util::ValidateExtension(
extension.get(), &error, &warnings)) << error;
EXPECT_EQ(0U, warnings.size());
}

Expand All @@ -417,8 +417,8 @@ TEST_F(ExtensionFileUtilTest, BackgroundScriptsMustExist) {
value.get(), temp.path(), Manifest::UNPACKED, 0, &error);
ASSERT_TRUE(extension.get()) << error;

EXPECT_FALSE(extension_file_util::ValidateExtension(extension,
&error, &warnings));
EXPECT_FALSE(extension_file_util::ValidateExtension(
extension.get(), &error, &warnings));
EXPECT_EQ(l10n_util::GetStringFUTF8(
IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, ASCIIToUTF16("foo.js")),
error);
Expand All @@ -432,8 +432,8 @@ TEST_F(ExtensionFileUtilTest, BackgroundScriptsMustExist) {
ASSERT_TRUE(extension.get()) << error;

warnings.clear();
EXPECT_FALSE(extension_file_util::ValidateExtension(extension,
&error, &warnings));
EXPECT_FALSE(extension_file_util::ValidateExtension(
extension.get(), &error, &warnings));
EXPECT_EQ(l10n_util::GetStringFUTF8(
IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED,
ASCIIToUTF16("http://google.com/foo.js")),
Expand Down Expand Up @@ -543,9 +543,8 @@ TEST_F(ExtensionFileUtilTest, CheckZeroLengthImageFile) {
std::string error;
scoped_refptr<Extension> extension(extension_file_util::LoadExtension(
ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
EXPECT_TRUE(extension == NULL);
EXPECT_STREQ("Could not load extension icon 'icon.png'.",
error.c_str());
EXPECT_TRUE(extension.get() == NULL);
EXPECT_STREQ("Could not load extension icon 'icon.png'.", error.c_str());

// Try to install an extension with a zero-length browser action icon file.
ext_dir = install_dir.AppendASCII("extensions")
Expand All @@ -555,9 +554,9 @@ TEST_F(ExtensionFileUtilTest, CheckZeroLengthImageFile) {

scoped_refptr<Extension> extension2(extension_file_util::LoadExtension(
ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
EXPECT_TRUE(extension2 == NULL);
EXPECT_TRUE(extension2.get() == NULL);
EXPECT_STREQ("Could not load icon 'icon.png' for browser action.",
error.c_str());
error.c_str());

// Try to install an extension with a zero-length page action icon file.
ext_dir = install_dir.AppendASCII("extensions")
Expand All @@ -567,9 +566,9 @@ TEST_F(ExtensionFileUtilTest, CheckZeroLengthImageFile) {

scoped_refptr<Extension> extension3(extension_file_util::LoadExtension(
ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
EXPECT_TRUE(extension3 == NULL);
EXPECT_TRUE(extension3.get() == NULL);
EXPECT_STREQ("Could not load icon 'icon.png' for page action.",
error.c_str());
error.c_str());
}

// TODO(aa): More tests as motivation allows. Maybe steal some from
Expand Down
Loading

0 comments on commit 5c6ac84

Please sign in to comment.