diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-02 21:15:09 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-02 21:15:09 +0000 |
commit | dc24976fc87171d50b49f37bbaaa23ae53e51f4b (patch) | |
tree | 8d7c684afa0d65e22efc3384197ef5b50d867160 /chrome/browser/extensions/api | |
parent | fc72bb18b111ff63e57135d97de6d59291f3b7b8 (diff) | |
download | chromium_src-dc24976fc87171d50b49f37bbaaa23ae53e51f4b.zip chromium_src-dc24976fc87171d50b49f37bbaaa23ae53e51f4b.tar.gz chromium_src-dc24976fc87171d50b49f37bbaaa23ae53e51f4b.tar.bz2 |
Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*"
Linux fixes, Part 2 of N
BUG=110610
TBR=darin
Review URL: https://chromiumcodereview.appspot.com/16295003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api')
50 files changed, 366 insertions, 334 deletions
diff --git a/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc b/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc index fd8b7c6..6cf0f74 100644 --- a/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc +++ b/chrome/browser/extensions/api/alarms/alarms_api_unittest.cc @@ -60,7 +60,7 @@ class ExtensionAlarmsTest : public BrowserWithTestWindowTest { extensions::Manifest::UNPACKED); // Make sure there's a RenderViewHost for alarms to warn into. - AddTab(browser(), BackgroundInfo::GetBackgroundURL(extension_)); + AddTab(browser(), BackgroundInfo::GetBackgroundURL(extension_.get())); contents_ = browser()->tab_strip_model()->GetActiveWebContents(); test_clock_->SetNow(base::Time::FromDoubleT(10)); diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc index 6d4170a..11c91f5 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc @@ -247,7 +247,7 @@ bool BluetoothGetProfilesFunction::DoWork( bool BluetoothGetAdapterStateFunction::DoWork( scoped_refptr<BluetoothAdapter> adapter) { bluetooth::AdapterState state; - PopulateAdapterState(*adapter, &state); + PopulateAdapterState(*adapter.get(), &state); SetResult(state.ToValue().release()); SendResponse(true); return true; @@ -447,7 +447,7 @@ void BluetoothReadFunction::Work() { return; scoped_refptr<net::GrowableIOBuffer> buffer(new net::GrowableIOBuffer); - success_ = socket_->Receive(buffer); + success_ = socket_->Receive(buffer.get()); if (success_) SetResult(base::BinaryValue::CreateWithCopiedBuffer(buffer->StartOfBuffer(), buffer->offset())); @@ -501,8 +501,9 @@ void BluetoothWriteFunction::Work() { scoped_refptr<net::WrappedIOBuffer> wrapped_io_buffer( new net::WrappedIOBuffer(data_to_write_->GetBuffer())); scoped_refptr<net::DrainableIOBuffer> drainable_io_buffer( - new net::DrainableIOBuffer(wrapped_io_buffer, data_to_write_->GetSize())); - success_ = socket_->Send(drainable_io_buffer); + new net::DrainableIOBuffer(wrapped_io_buffer.get(), + data_to_write_->GetSize())); + success_ = socket_->Send(drainable_io_buffer.get()); if (success_) { if (drainable_io_buffer->BytesConsumed() > 0) SetResult( diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc index a840e14..f000d5e 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc @@ -168,54 +168,41 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Profiles) { scoped_refptr<TestBluetoothAddProfileFunction> add_profile_function; add_profile_function = setupFunction( new TestBluetoothAddProfileFunction(profile1_.get())); - std::string error( - utils::RunFunctionAndReturnError( - add_profile_function, - "[{\"uuid\": \"1234\"}]", - browser())); + std::string error(utils::RunFunctionAndReturnError( + add_profile_function.get(), "[{\"uuid\": \"1234\"}]", browser())); ASSERT_TRUE(error.empty()); // Registering the profile for the same uuid again will throw an error. add_profile_function = setupFunction( new TestBluetoothAddProfileFunction(profile2_.get())); error = utils::RunFunctionAndReturnError( - add_profile_function, - "[{\"uuid\": \"1234\"}]", - browser()); + add_profile_function.get(), "[{\"uuid\": \"1234\"}]", browser()); ASSERT_FALSE(error.empty()); add_profile_function = setupFunction( new TestBluetoothAddProfileFunction(profile2_.get())); error = utils::RunFunctionAndReturnError( - add_profile_function, - "[{\"uuid\": \"5678\"}]", - browser()); + add_profile_function.get(), "[{\"uuid\": \"5678\"}]", browser()); ASSERT_TRUE(error.empty()); scoped_refptr<api::BluetoothRemoveProfileFunction> remove_profile_function; remove_profile_function = setupFunction( new api::BluetoothRemoveProfileFunction()); error = utils::RunFunctionAndReturnError( - remove_profile_function, - "[{\"uuid\": \"1234\"}]", - browser()); + remove_profile_function.get(), "[{\"uuid\": \"1234\"}]", browser()); ASSERT_TRUE(error.empty()); remove_profile_function = setupFunction( new api::BluetoothRemoveProfileFunction()); error = utils::RunFunctionAndReturnError( - remove_profile_function, - "[{\"uuid\": \"5678\"}]", - browser()); + remove_profile_function.get(), "[{\"uuid\": \"5678\"}]", browser()); ASSERT_TRUE(error.empty()); // Removing the same profile again will throw an error. remove_profile_function = setupFunction( new api::BluetoothRemoveProfileFunction()); error = utils::RunFunctionAndReturnError( - remove_profile_function, - "[{\"uuid\": \"5678\"}]", - browser()); + remove_profile_function.get(), "[{\"uuid\": \"5678\"}]", browser()); ASSERT_FALSE(error.empty()); } @@ -235,7 +222,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetAdapterState) { get_adapter_state = setupFunction(new api::BluetoothGetAdapterStateFunction); scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - get_adapter_state, "[]", browser())); + get_adapter_state.get(), "[]", browser())); ASSERT_TRUE(result.get() != NULL); api::bluetooth::AdapterState state; ASSERT_TRUE(api::bluetooth::AdapterState::Populate(*result, &state)); @@ -257,7 +244,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetLocalOutOfBandPairingData) { new api::BluetoothGetLocalOutOfBandPairingDataFunction)); scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - get_oob_function, "[]", browser())); + get_oob_function.get(), "[]", browser())); base::DictionaryValue* dict; EXPECT_TRUE(result->GetAsDictionary(&dict)); @@ -280,8 +267,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetLocalOutOfBandPairingData) { get_oob_function = setupFunction(new api::BluetoothGetLocalOutOfBandPairingDataFunction); - std::string error( - utils::RunFunctionAndReturnError(get_oob_function, "[]", browser())); + std::string error(utils::RunFunctionAndReturnError( + get_oob_function.get(), "[]", browser())); EXPECT_FALSE(error.empty()); } @@ -299,8 +286,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, SetOutOfBandPairingData) { set_oob_function = setupFunction( new api::BluetoothSetOutOfBandPairingDataFunction); // There isn't actually a result. - (void)utils::RunFunctionAndReturnSingleResult( - set_oob_function, params, browser()); + (void) utils::RunFunctionAndReturnSingleResult( + set_oob_function.get(), params, browser()); // Try again with an error testing::Mock::VerifyAndClearExpectations(mock_adapter_); @@ -313,8 +300,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, SetOutOfBandPairingData) { set_oob_function = setupFunction( new api::BluetoothSetOutOfBandPairingDataFunction); - std::string error( - utils::RunFunctionAndReturnError(set_oob_function, params, browser())); + std::string error(utils::RunFunctionAndReturnError( + set_oob_function.get(), params, browser())); EXPECT_FALSE(error.empty()); // TODO(bryeung): Also test setting the data when there is support for @@ -331,7 +318,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) { scoped_refptr<api::BluetoothStartDiscoveryFunction> start_function; start_function = setupFunction(new api::BluetoothStartDiscoveryFunction); std::string error( - utils::RunFunctionAndReturnError(start_function, "[]", browser())); + utils::RunFunctionAndReturnError(start_function.get(), "[]", browser())); ASSERT_FALSE(error.empty()); // Reset for a successful start @@ -340,7 +327,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) { .WillOnce(testing::Invoke(CallDiscoveryCallback)); start_function = setupFunction(new api::BluetoothStartDiscoveryFunction); - (void)utils::RunFunctionAndReturnError(start_function, "[]", browser()); + (void) + utils::RunFunctionAndReturnError(start_function.get(), "[]", browser()); // Reset to try stopping testing::Mock::VerifyAndClearExpectations(mock_adapter_); @@ -350,7 +338,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) { EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)); scoped_refptr<api::BluetoothStopDiscoveryFunction> stop_function; stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction); - (void)utils::RunFunctionAndReturnSingleResult(stop_function, "[]", browser()); + (void) utils::RunFunctionAndReturnSingleResult( + stop_function.get(), "[]", browser()); // Reset to try stopping with an error SetUpMockAdapter(); @@ -358,7 +347,8 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) { .WillOnce(testing::Invoke(CallDiscoveryErrorCallback)); EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)); stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction); - error = utils::RunFunctionAndReturnError(stop_function, "[]", browser()); + error = + utils::RunFunctionAndReturnError(stop_function.get(), "[]", browser()); ASSERT_FALSE(error.empty()); SetUpMockAdapter(); } diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc index 17f31d7..3a4c2e6 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc @@ -37,7 +37,7 @@ ExtensionBluetoothEventRouter::ExtensionBluetoothEventRouter(Profile* profile) } ExtensionBluetoothEventRouter::~ExtensionBluetoothEventRouter() { - if (adapter_) { + if (adapter_.get()) { adapter_->RemoveObserver(this); adapter_ = NULL; } @@ -53,13 +53,13 @@ ExtensionBluetoothEventRouter::~ExtensionBluetoothEventRouter() { } bool ExtensionBluetoothEventRouter::IsBluetoothSupported() const { - return adapter_ || + return adapter_.get() || device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable(); } void ExtensionBluetoothEventRouter::GetAdapter( const device::BluetoothAdapterFactory::AdapterCallback& callback) { - if (adapter_) { + if (adapter_.get()) { callback.Run(scoped_refptr<device::BluetoothAdapter>(adapter_)); return; } @@ -191,7 +191,7 @@ void ExtensionBluetoothEventRouter::DispatchConnectionEvent( void ExtensionBluetoothEventRouter::AdapterPresentChanged( device::BluetoothAdapter* adapter, bool present) { - if (adapter != adapter_) { + if (adapter != adapter_.get()) { DVLOG(1) << "Ignoring event for adapter " << adapter->GetAddress(); return; } @@ -200,7 +200,7 @@ void ExtensionBluetoothEventRouter::AdapterPresentChanged( void ExtensionBluetoothEventRouter::AdapterPoweredChanged( device::BluetoothAdapter* adapter, bool has_power) { - if (adapter != adapter_) { + if (adapter != adapter_.get()) { DVLOG(1) << "Ignoring event for adapter " << adapter->GetAddress(); return; } @@ -209,7 +209,7 @@ void ExtensionBluetoothEventRouter::AdapterPoweredChanged( void ExtensionBluetoothEventRouter::AdapterDiscoveringChanged( device::BluetoothAdapter* adapter, bool discovering) { - if (adapter != adapter_) { + if (adapter != adapter_.get()) { DVLOG(1) << "Ignoring event for adapter " << adapter->GetAddress(); return; } @@ -226,7 +226,7 @@ void ExtensionBluetoothEventRouter::AdapterDiscoveringChanged( void ExtensionBluetoothEventRouter::DeviceAdded( device::BluetoothAdapter* adapter, device::BluetoothDevice* device) { - if (adapter != adapter_) { + if (adapter != adapter_.get()) { DVLOG(1) << "Ignoring event for adapter " << adapter->GetAddress(); return; } @@ -245,7 +245,7 @@ void ExtensionBluetoothEventRouter::DeviceAdded( } void ExtensionBluetoothEventRouter::InitializeAdapterIfNeeded() { - if (!adapter_) { + if (!adapter_.get()) { GetAdapter(base::Bind(&ExtensionBluetoothEventRouter::InitializeAdapter, weak_ptr_factory_.GetWeakPtr())); } @@ -253,14 +253,14 @@ void ExtensionBluetoothEventRouter::InitializeAdapterIfNeeded() { void ExtensionBluetoothEventRouter::InitializeAdapter( scoped_refptr<device::BluetoothAdapter> adapter) { - if (!adapter_) { + if (!adapter_.get()) { adapter_ = adapter; adapter_->AddObserver(this); } } void ExtensionBluetoothEventRouter::MaybeReleaseAdapter() { - if (adapter_ && num_event_listeners_ == 0) { + if (adapter_.get() && num_event_listeners_ == 0) { adapter_->RemoveObserver(this); adapter_ = NULL; } @@ -268,7 +268,7 @@ void ExtensionBluetoothEventRouter::MaybeReleaseAdapter() { void ExtensionBluetoothEventRouter::DispatchAdapterStateEvent() { api::bluetooth::AdapterState state; - PopulateAdapterState(*adapter_, &state); + PopulateAdapterState(*adapter_.get(), &state); scoped_ptr<ListValue> args(new ListValue()); args->Append(state.ToValue().release()); diff --git a/chrome/browser/extensions/api/browsing_data/browsing_data_api.cc b/chrome/browser/extensions/api/browsing_data/browsing_data_api.cc index 7638e6e..ae7cce1 100644 --- a/chrome/browser/extensions/api/browsing_data/browsing_data_api.cc +++ b/chrome/browser/extensions/api/browsing_data/browsing_data_api.cc @@ -277,7 +277,7 @@ bool BrowsingDataRemoveFunction::RunImpl() { void BrowsingDataRemoveFunction::CheckRemovingPluginDataSupported( scoped_refptr<PluginPrefs> plugin_prefs) { - if (!PluginDataRemoverHelper::IsSupported(plugin_prefs)) + if (!PluginDataRemoverHelper::IsSupported(plugin_prefs.get())) removal_mask_ &= ~BrowsingDataRemover::REMOVE_PLUGIN_DATA; BrowserThread::PostTask( diff --git a/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc b/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc index abb650e..9d8b0c5 100644 --- a/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc +++ b/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc @@ -245,10 +245,10 @@ class ExtensionBrowsingDataTest : public InProcessBrowserTest, EXPECT_EQ(NULL, RunFunctionAndReturnSingleResult( function.get(), args, browser())) << " for " << args; } else { - EXPECT_TRUE( - MatchPattern(RunFunctionAndReturnError(function, args, browser()), - extension_browsing_data_api_constants::kDeleteProhibitedError)) << - " for " << args; + EXPECT_TRUE(MatchPattern( + RunFunctionAndReturnError(function.get(), args, browser()), + extension_browsing_data_api_constants::kDeleteProhibitedError)) + << " for " << args; } } @@ -263,11 +263,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, OneAtATime) { BrowsingDataRemover::set_removing(true); scoped_refptr<RemoveBrowsingDataFunction> function = new RemoveBrowsingDataFunction(); - EXPECT_TRUE(MatchPattern( - RunFunctionAndReturnError(function, - kRemoveEverythingArguments, - browser()), - extension_browsing_data_api_constants::kOneAtATimeError)); + EXPECT_TRUE( + MatchPattern(RunFunctionAndReturnError( + function.get(), kRemoveEverythingArguments, browser()), + extension_browsing_data_api_constants::kOneAtATimeError)); BrowsingDataRemover::set_removing(false); EXPECT_EQ(base::Time(), GetBeginTime()); diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc index 3a52784..a4b98cb 100644 --- a/chrome/browser/extensions/api/debugger/debugger_api.cc +++ b/chrome/browser/extensions/api/debugger/debugger_api.cc @@ -407,8 +407,8 @@ ExtensionDevToolsClientHost::ExtensionDevToolsClientHost( content::NotificationService::AllSources()); // Attach to debugger and tell it we are ready. - DevToolsManager::GetInstance()-> - RegisterDevToolsClientHostFor(agent_host_, this); + DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( + agent_host_.get(), this); if (infobar_delegate_) { infobar_delegate_->AttachClientHost(this); @@ -537,7 +537,7 @@ void ExtensionDevToolsClientHost::DispatchOnInspectorFrontend( extensions::ExtensionSystem::Get(profile_)->event_router()-> DispatchEventToExtension(extension_id_, event.Pass()); } else { - DebuggerSendCommandFunction* function = pending_requests_[id]; + DebuggerSendCommandFunction* function = pending_requests_[id].get(); if (!function) return; @@ -599,7 +599,7 @@ bool DebuggerFunction::InitAgentHost() { return false; } - if (!agent_host_) { + if (!agent_host_.get()) { FormatErrorMessage(keys::kNoTargetError); return false; } @@ -610,8 +610,8 @@ bool DebuggerFunction::InitClientHost() { if (!InitAgentHost()) return false; - client_host_ = AttachedClientHosts::GetInstance()-> - Lookup(agent_host_, GetExtension()->id()); + client_host_ = AttachedClientHosts::GetInstance()->Lookup( + agent_host_.get(), GetExtension()->id()); if (!client_host_) { FormatErrorMessage(keys::kNotAttachedError); @@ -665,7 +665,7 @@ bool DebuggerAttachFunction::RunImpl() { } new ExtensionDevToolsClientHost(profile(), - agent_host_, + agent_host_.get(), GetExtension()->id(), GetExtension()->name(), debuggee_, diff --git a/chrome/browser/extensions/api/declarative/declarative_api.cc b/chrome/browser/extensions/api/declarative/declarative_api.cc index 2429658..f0ec23e 100644 --- a/chrome/browser/extensions/api/declarative/declarative_api.cc +++ b/chrome/browser/extensions/api/declarative/declarative_api.cc @@ -42,7 +42,7 @@ bool RulesFunction::RunImpl() { rules_registry_ = rules_registry_service->GetRulesRegistry(event_name); // Raw access to this function is not available to extensions, therefore // there should never be a request for a nonexisting rules registry. - EXTENSION_FUNCTION_VALIDATE(rules_registry_); + EXTENSION_FUNCTION_VALIDATE(rules_registry_.get()); if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) { bool success = RunImplOnCorrectThread(); @@ -52,7 +52,7 @@ bool RulesFunction::RunImpl() { content::BrowserThread::GetMessageLoopProxyForThread( rules_registry_->owner_thread()); base::PostTaskAndReplyWithResult( - message_loop_proxy, + message_loop_proxy.get(), FROM_HERE, base::Bind(&RulesFunction::RunImplOnCorrectThread, this), base::Bind(&RulesFunction::SendResponse, this)); diff --git a/chrome/browser/extensions/api/declarative/declarative_rule_unittest.cc b/chrome/browser/extensions/api/declarative/declarative_rule_unittest.cc index cb0f693..2e78b8a 100644 --- a/chrome/browser/extensions/api/declarative/declarative_rule_unittest.cc +++ b/chrome/browser/extensions/api/declarative/declarative_rule_unittest.cc @@ -108,7 +108,7 @@ struct FulfillableCondition { void GetURLMatcherConditionSets( URLMatcherConditionSet::Vector* condition_sets) const { - if (condition_set) + if (condition_set.get()) condition_sets->push_back(condition_set); } diff --git a/chrome/browser/extensions/api/declarative/deduping_factory.h b/chrome/browser/extensions/api/declarative/deduping_factory.h index 4627533..b34d9a0 100644 --- a/chrome/browser/extensions/api/declarative/deduping_factory.h +++ b/chrome/browser/extensions/api/declarative/deduping_factory.h @@ -134,7 +134,7 @@ scoped_refptr<const BaseClassT> DedupingFactory<BaseClassT>::Instantiate( if (prototypes.empty()) { scoped_refptr<const BaseClassT> new_object = (*factory_method)(instance_type, value, error, bad_message); - if (!new_object || !error->empty() || *bad_message) + if (!new_object.get() || !error->empty() || *bad_message) return scoped_refptr<const BaseClassT>(); prototypes.push_back(new_object); } @@ -144,7 +144,7 @@ scoped_refptr<const BaseClassT> DedupingFactory<BaseClassT>::Instantiate( // Handle parameterized objects. scoped_refptr<const BaseClassT> new_object = (*factory_method)(instance_type, value, error, bad_message); - if (!new_object || !error->empty() || *bad_message) + if (!new_object.get() || !error->empty() || *bad_message) return scoped_refptr<const BaseClassT>(); size_t length = 0; diff --git a/chrome/browser/extensions/api/declarative/deduping_factory_unittest.cc b/chrome/browser/extensions/api/declarative/deduping_factory_unittest.cc index 0d9cc37..0d424f8 100644 --- a/chrome/browser/extensions/api/declarative/deduping_factory_unittest.cc +++ b/chrome/browser/extensions/api/declarative/deduping_factory_unittest.cc @@ -98,15 +98,15 @@ TEST(DedupingFactoryTest, InstantiationParameterized) { factory.Instantiate(kTypeName, d1.get(), &error, &bad_message)); scoped_refptr<const BaseClass> c2( factory.Instantiate(kTypeName, d2.get(), &error, &bad_message)); - ASSERT_TRUE(c1); - ASSERT_TRUE(c2); + ASSERT_TRUE(c1.get()); + ASSERT_TRUE(c2.get()); EXPECT_EQ(1, static_cast<const Foo*>(c1.get())->parameter()); EXPECT_EQ(2, static_cast<const Foo*>(c2.get())->parameter()); // This one produces an overflow, now the cache contains [2, 3] scoped_refptr<const BaseClass> c3( factory.Instantiate(kTypeName, d3.get(), &error, &bad_message)); - ASSERT_TRUE(c3); + ASSERT_TRUE(c3.get()); EXPECT_EQ(3, static_cast<const Foo*>(c3.get())->parameter()); // Reuse 2, this should give the same instance as c2. @@ -144,8 +144,8 @@ TEST(DedupingFactoryTest, InstantiationNonParameterized) { factory.Instantiate(kTypeName, d1.get(), &error, &bad_message)); scoped_refptr<const BaseClass> c2( factory.Instantiate(kTypeName, d2.get(), &error, &bad_message)); - ASSERT_TRUE(c1); - ASSERT_TRUE(c2); + ASSERT_TRUE(c1.get()); + ASSERT_TRUE(c2.get()); EXPECT_EQ(1, static_cast<const Foo*>(c1.get())->parameter()); EXPECT_EQ(1, static_cast<const Foo*>(c2.get())->parameter()); EXPECT_EQ(c1, c2); @@ -168,8 +168,8 @@ TEST(DedupingFactoryTest, TypeNames) { scoped_refptr<const BaseClass> c1_b( factory.Instantiate(kTypeName2, d1.get(), &error, &bad_message)); - ASSERT_TRUE(c1_a); - ASSERT_TRUE(c1_b); + ASSERT_TRUE(c1_a.get()); + ASSERT_TRUE(c1_b.get()); EXPECT_NE(c1_a, c1_b); } @@ -191,8 +191,8 @@ TEST(DedupingFactoryTest, Clear) { scoped_refptr<const BaseClass> c1_b( factory.Instantiate(kTypeName, d1.get(), &error, &bad_message)); - ASSERT_TRUE(c1_a); - ASSERT_TRUE(c1_b); + ASSERT_TRUE(c1_a.get()); + ASSERT_TRUE(c1_b.get()); EXPECT_NE(c1_a, c1_b); } diff --git a/chrome/browser/extensions/api/declarative_content/content_action_unittest.cc b/chrome/browser/extensions/api/declarative_content/content_action_unittest.cc index bce9c80c..049cc6c 100644 --- a/chrome/browser/extensions/api/declarative_content/content_action_unittest.cc +++ b/chrome/browser/extensions/api/declarative_content/content_action_unittest.cc @@ -31,14 +31,14 @@ TEST(DeclarativeContentActionTest, InvalidCreation) { result = ContentAction::Create(*ParseJson("[]"), &error, &bad_message); EXPECT_TRUE(bad_message); EXPECT_EQ("", error); - EXPECT_FALSE(result); + EXPECT_FALSE(result.get()); // Test missing instanceType element. error.clear(); result = ContentAction::Create(*ParseJson("{}"), &error, &bad_message); EXPECT_TRUE(bad_message); EXPECT_EQ("", error); - EXPECT_FALSE(result); + EXPECT_FALSE(result.get()); // Test wrong instanceType element. error.clear(); @@ -48,7 +48,7 @@ TEST(DeclarativeContentActionTest, InvalidCreation) { "}"), &error, &bad_message); EXPECT_THAT(error, HasSubstr("invalid instanceType")); - EXPECT_FALSE(result); + EXPECT_FALSE(result.get()); } TEST(DeclarativeContentActionTest, ShowPageAction) { @@ -63,7 +63,7 @@ TEST(DeclarativeContentActionTest, ShowPageAction) { &error, &bad_message); EXPECT_EQ("", error); EXPECT_FALSE(bad_message); - ASSERT_TRUE(result); + ASSERT_TRUE(result.get()); EXPECT_EQ(ContentAction::ACTION_SHOW_PAGE_ACTION, result->GetType()); const Extension* extension = env.MakeExtension( diff --git a/chrome/browser/extensions/api/declarative_content/content_condition.cc b/chrome/browser/extensions/api/declarative_content/content_condition.cc index 9a0a40f..5730a504 100644 --- a/chrome/browser/extensions/api/declarative_content/content_condition.cc +++ b/chrome/browser/extensions/api/declarative_content/content_condition.cc @@ -126,7 +126,7 @@ scoped_ptr<ContentCondition> ContentCondition::Create( return scoped_ptr<ContentCondition>(NULL); } - if (!url_matcher_condition_set) { + if (!url_matcher_condition_set.get()) { URLMatcherConditionSet::Conditions url_matcher_conditions; url_matcher_conditions.insert( url_matcher_condition_factory->CreateHostPrefixCondition( diff --git a/chrome/browser/extensions/api/declarative_content/content_condition.h b/chrome/browser/extensions/api/declarative_content/content_condition.h index 162631d..0adea94 100644 --- a/chrome/browser/extensions/api/declarative_content/content_condition.h +++ b/chrome/browser/extensions/api/declarative_content/content_condition.h @@ -81,14 +81,14 @@ class ContentCondition { // If this Condition has a url filter, appends it to |condition_sets|. void GetURLMatcherConditionSets( URLMatcherConditionSet::Vector* condition_sets) const { - if (url_matcher_conditions_) + if (url_matcher_conditions_.get()) condition_sets->push_back(url_matcher_conditions_); } // True if GetURLMatcherConditionSets would append anything to its // argument. bool has_url_matcher_condition_set() const { - return url_matcher_conditions_ != NULL; + return url_matcher_conditions_.get() != NULL; } // Returns the CSS selectors required to match by this condition. diff --git a/chrome/browser/extensions/api/declarative_content/content_rules_registry_unittest.cc b/chrome/browser/extensions/api/declarative_content/content_rules_registry_unittest.cc index f37f1ec..6c7a7e2 100644 --- a/chrome/browser/extensions/api/declarative_content/content_rules_registry_unittest.cc +++ b/chrome/browser/extensions/api/declarative_content/content_rules_registry_unittest.cc @@ -40,13 +40,13 @@ TEST_F(DeclarativeContentRulesRegistryTest, ActiveRulesDoesntGrow) { scoped_refptr<ContentRulesRegistry> registry( new ContentRulesRegistry(env.profile(), NULL /*ui_part*/)); - EXPECT_EQ(0u, active_rules(*registry).size()); + EXPECT_EQ(0u, active_rules(*registry.get()).size()); content::LoadCommittedDetails load_details; content::FrameNavigateParams navigate_params; scoped_ptr<WebContents> tab = env.MakeTab(); registry->DidNavigateMainFrame(tab.get(), load_details, navigate_params); - EXPECT_EQ(0u, active_rules(*registry).size()); + EXPECT_EQ(0u, active_rules(*registry.get()).size()); // Add a rule. linked_ptr<RulesRegistry::Rule> rule(new RulesRegistry::Rule); @@ -73,24 +73,24 @@ TEST_F(DeclarativeContentRulesRegistryTest, ActiveRulesDoesntGrow) { registry->AddRulesImpl(extension->id(), rules); registry->DidNavigateMainFrame(tab.get(), load_details, navigate_params); - EXPECT_EQ(0u, active_rules(*registry).size()); + EXPECT_EQ(0u, active_rules(*registry.get()).size()); std::vector<std::string> css_selectors; css_selectors.push_back("input"); registry->Apply(tab.get(), css_selectors); - EXPECT_EQ(1u, active_rules(*registry).size()); + EXPECT_EQ(1u, active_rules(*registry.get()).size()); // Closing the tab should erase its entry from active_rules_. tab.reset(); - EXPECT_EQ(0u, active_rules(*registry).size()); + EXPECT_EQ(0u, active_rules(*registry.get()).size()); tab = env.MakeTab(); registry->Apply(tab.get(), css_selectors); - EXPECT_EQ(1u, active_rules(*registry).size()); + EXPECT_EQ(1u, active_rules(*registry.get()).size()); // Navigating the tab should erase its entry from active_rules_ if // it no longer matches. registry->DidNavigateMainFrame(tab.get(), load_details, navigate_params); - EXPECT_EQ(0u, active_rules(*registry).size()); + EXPECT_EQ(0u, active_rules(*registry.get()).size()); } } // namespace diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc index b3e23fd..8752da2 100644 --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc @@ -113,7 +113,7 @@ void WebRequestActionWithThreadsTest::SetUp() { Extension::NO_FLAGS, "ext_id_1", &error); - ASSERT_TRUE(extension_) << error; + ASSERT_TRUE(extension_.get()) << error; extension_all_urls_ = LoadManifestUnchecked("permissions", "web_request_all_host_permissions.json", @@ -121,9 +121,9 @@ void WebRequestActionWithThreadsTest::SetUp() { Extension::NO_FLAGS, "ext_id_2", &error); - ASSERT_TRUE(extension_all_urls_) << error; + ASSERT_TRUE(extension_all_urls_.get()) << error; extension_info_map_ = new ExtensionInfoMap; - ASSERT_TRUE(extension_info_map_); + ASSERT_TRUE(extension_info_map_.get()); extension_info_map_->AddExtension( extension_.get(), base::Time::Now(), false /*incognito_enabled*/); extension_info_map_->AddExtension(extension_all_urls_.get(), @@ -140,12 +140,12 @@ bool WebRequestActionWithThreadsTest::ActionWorksOnRequest( std::list<LinkedPtrEventResponseDelta> deltas; scoped_refptr<net::HttpResponseHeaders> headers( new net::HttpResponseHeaders("")); - WebRequestData request_data(®ular_request, stage, headers); + WebRequestData request_data(®ular_request, stage, headers.get()); std::set<std::string> ignored_tags; - WebRequestAction::ApplyInfo apply_info = { - extension_info_map_, request_data, false /*crosses_incognito*/, &deltas, - &ignored_tags - }; + WebRequestAction::ApplyInfo apply_info = { extension_info_map_.get(), + request_data, + false /*crosses_incognito*/, + &deltas, &ignored_tags }; action_set->Apply(extension_id, base::Time(), &apply_info); return (1u == deltas.size() || 0u < ignored_tags.size()); } diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.cc index 6432eb3..0909d16 100644 --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.cc +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.cc @@ -114,9 +114,9 @@ bool WebRequestCondition::IsFulfilled( void WebRequestCondition::GetURLMatcherConditionSets( URLMatcherConditionSet::Vector* condition_sets) const { - if (url_matcher_conditions_) + if (url_matcher_conditions_.get()) condition_sets->push_back(url_matcher_conditions_); - if (first_party_url_matcher_conditions_) + if (first_party_url_matcher_conditions_.get()) condition_sets->push_back(first_party_url_matcher_conditions_); } diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc index fb11630..ebcf75c 100644 --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc @@ -287,7 +287,7 @@ TEST(WebRequestConditionAttributeTest, Stages) { &single_stage_list, &error)); EXPECT_EQ("", error); - ASSERT_TRUE(one_stage_attributes.back() != NULL); + ASSERT_TRUE(one_stage_attributes.back().get() != NULL); } const GURL url_empty; diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc index 9a83958..d80baf7 100644 --- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc @@ -240,17 +240,16 @@ void WebRequestRulesRegistryTest::SetUp() { Extension::NO_FLAGS, kExtensionId, &error); - ASSERT_TRUE(extension_) << error; - extension2_ = - LoadManifestUnchecked("permissions", - "web_request_all_host_permissions.json", - Manifest::INVALID_LOCATION, - Extension::NO_FLAGS, - kExtensionId2, - &error); - ASSERT_TRUE(extension2_) << error; + ASSERT_TRUE(extension_.get()) << error; + extension2_ = LoadManifestUnchecked("permissions", + "web_request_all_host_permissions.json", + Manifest::INVALID_LOCATION, + Extension::NO_FLAGS, + kExtensionId2, + &error); + ASSERT_TRUE(extension2_.get()) << error; extension_info_map_ = new ExtensionInfoMap; - ASSERT_TRUE(extension_info_map_); + ASSERT_TRUE(extension_info_map_.get()); extension_info_map_->AddExtension(extension_.get(), base::Time() + base::TimeDelta::FromDays(1), false /*incognito_enabled*/); diff --git a/chrome/browser/extensions/api/dial/dial_service.cc b/chrome/browser/extensions/api/dial/dial_service.cc index d525a05..f59eed7 100644 --- a/chrome/browser/extensions/api/dial/dial_service.cc +++ b/chrome/browser/extensions/api/dial/dial_service.cc @@ -350,7 +350,7 @@ bool DialServiceImpl::ParseResponse(const std::string& response, new HttpResponseHeaders(raw_headers); std::string device_url_str; - if (!GetHeader(headers, kSsdpLocationHeader, &device_url_str) || + if (!GetHeader(headers.get(), kSsdpLocationHeader, &device_url_str) || device_url_str.empty()) { DVLOG(1) << "No LOCATION header found."; return false; @@ -363,7 +363,8 @@ bool DialServiceImpl::ParseResponse(const std::string& response, } std::string device_id; - if (!GetHeader(headers, kSsdpUsnHeader, &device_id) || device_id.empty()) { + if (!GetHeader(headers.get(), kSsdpUsnHeader, &device_id) || + device_id.empty()) { DVLOG(1) << "No USN header found."; return false; } @@ -375,11 +376,11 @@ bool DialServiceImpl::ParseResponse(const std::string& response, // TODO(mfoltz): Parse the max-age value from the cache control header. // http://crbug.com/165289 std::string cache_control; - GetHeader(headers, kSsdpCacheControlHeader, &cache_control); + GetHeader(headers.get(), kSsdpCacheControlHeader, &cache_control); std::string config_id; int config_id_int; - if (GetHeader(headers, kSsdpConfigIdHeader, &config_id) && + if (GetHeader(headers.get(), kSsdpConfigIdHeader, &config_id) && base::StringToInt(config_id, &config_id_int)) { device->set_config_id(config_id_int); } else { diff --git a/chrome/browser/extensions/api/dns/dns_apitest.cc b/chrome/browser/extensions/api/dns/dns_apitest.cc index 3671879..14c005f 100644 --- a/chrome/browser/extensions/api/dns/dns_apitest.cc +++ b/chrome/browser/extensions/api/dns/dns_apitest.cc @@ -61,7 +61,7 @@ IN_PROC_BROWSER_TEST_F(DnsApiTest, DnsResolveIPLiteral) { resolve_function->set_has_callback(true); scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult( - resolve_function, "[\"127.0.0.1\"]", browser())); + resolve_function.get(), "[\"127.0.0.1\"]", browser())); ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); diff --git a/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc b/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc index 5034052..1cd540e 100644 --- a/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc +++ b/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc @@ -809,8 +809,8 @@ class HTML5FileWriter { CHECK_EQ(base::PLATFORM_FILE_OK, result); blob_data_->AppendData(payload_); url_request_context_.reset(new TestURLRequestContext(fs_)); - url_request_context_->blob_storage_controller()->AddFinishedBlob( - blob_url(), blob_data_); + url_request_context_->blob_storage_controller() + ->AddFinishedBlob(blob_url(), blob_data_.get()); operation()->Write( url_request_context_.get(), fs_->CrackURL(GURL(root_ + filename_)), diff --git a/chrome/browser/extensions/api/extension_action/extension_action_api.cc b/chrome/browser/extensions/api/extension_action/extension_action_api.cc index b26b8c1..e8b2f09 100644 --- a/chrome/browser/extensions/api/extension_action/extension_action_api.cc +++ b/chrome/browser/extensions/api/extension_action/extension_action_api.cc @@ -464,11 +464,11 @@ void ExtensionActionFunction::NotifyChange() { switch (extension_action_->action_type()) { case ActionInfo::TYPE_BROWSER: case ActionInfo::TYPE_PAGE: - if (ExtensionActionManager::Get(profile_)-> - GetBrowserAction(*extension_)) { + if (ExtensionActionManager::Get(profile_) + ->GetBrowserAction(*extension_.get())) { NotifyBrowserActionChange(); - } else if (ExtensionActionManager::Get(profile_)-> - GetPageAction(*extension_)) { + } else if (ExtensionActionManager::Get(profile_) + ->GetPageAction(*extension_.get())) { NotifyLocationBarChange(); } return; diff --git a/chrome/browser/extensions/api/identity/experimental_identity_apitest.cc b/chrome/browser/extensions/api/identity/experimental_identity_apitest.cc index ee3ab02..9eb99bc 100644 --- a/chrome/browser/extensions/api/identity/experimental_identity_apitest.cc +++ b/chrome/browser/extensions/api/identity/experimental_identity_apitest.cc @@ -319,7 +319,7 @@ IN_PROC_BROWSER_TEST_F(ExperimentalGetAuthTokenFunctionTest, scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); scoped_refptr<ExperimentalMockGetAuthTokenFunction> func( new ExperimentalMockGetAuthTokenFunction()); - func->set_extension(extension); + func->set_extension(extension.get()); EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true)); TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow( TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get()); @@ -330,7 +330,7 @@ IN_PROC_BROWSER_TEST_F(ExperimentalGetAuthTokenFunctionTest, EXPECT_FALSE(func->login_ui_shown()); EXPECT_FALSE(func->install_ui_shown()); - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension); + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); EXPECT_EQ( IdentityTokenCacheValue::CACHE_STATUS_NOTFOUND, id_api()->GetCachedToken(extension->id(), oauth2_info.scopes).status()); @@ -357,8 +357,8 @@ IN_PROC_BROWSER_TEST_F(ExperimentalGetAuthTokenFunctionTest, scoped_refptr<ExperimentalMockGetAuthTokenFunction> func( new ExperimentalMockGetAuthTokenFunction()); scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); - func->set_extension(extension); - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension); + func->set_extension(extension.get()); + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true)); TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow( TestOAuth2MintTokenFlow::MINT_TOKEN_SUCCESS, func.get()); @@ -501,8 +501,8 @@ IN_PROC_BROWSER_TEST_F(ExperimentalGetAuthTokenFunctionTest, scoped_refptr<ExperimentalMockGetAuthTokenFunction> func( new ExperimentalMockGetAuthTokenFunction()); scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); - func->set_extension(extension); - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension); + func->set_extension(extension.get()); + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(false)); func->set_login_ui_result(true); TestOAuth2MintTokenFlow* flow1 = new TestOAuth2MintTokenFlow( @@ -606,7 +606,7 @@ class ExperimentalLaunchWebAuthFlowFunctionTest : extra_params.length() ? "," : "", extra_params.c_str()); - RunFunctionAsync(function, args); + RunFunctionAsync(function.get(), args); observer.Wait(); @@ -644,14 +644,15 @@ IN_PROC_BROWSER_TEST_F(ExperimentalLaunchWebAuthFlowFunctionTest, new ExperimentalIdentityLaunchWebAuthFlowFunction()); RunFunctionAsync( - function, "[{\"interactive\": true, \"url\": \"data:text/html,auth\"}]"); + function.get(), + "[{\"interactive\": true, \"url\": \"data:text/html,auth\"}]"); observer.Wait(); Browser* web_auth_flow_browser = content::Source<Browser>(observer.source()).ptr(); web_auth_flow_browser->window()->Close(); - EXPECT_EQ(std::string(errors::kUserRejected), WaitForError(function)); + EXPECT_EQ(std::string(errors::kUserRejected), WaitForError(function.get())); } IN_PROC_BROWSER_TEST_F(ExperimentalLaunchWebAuthFlowFunctionTest, @@ -662,7 +663,7 @@ IN_PROC_BROWSER_TEST_F(ExperimentalLaunchWebAuthFlowFunctionTest, function->set_extension(empty_extension.get()); std::string error = utils::RunFunctionAndReturnError( - function, + function.get(), "[{\"interactive\": false, \"url\": \"data:text/html,auth\"}]", browser()); @@ -678,7 +679,7 @@ IN_PROC_BROWSER_TEST_F(ExperimentalLaunchWebAuthFlowFunctionTest, function->InitFinalRedirectURLPrefixesForTest("abcdefghij"); scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( - function, + function.get(), "[{\"interactive\": false," "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]", browser())); @@ -698,7 +699,7 @@ IN_PROC_BROWSER_TEST_F(ExperimentalLaunchWebAuthFlowFunctionTest, function->InitFinalRedirectURLPrefixesForTest("abcdefghij"); scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( - function, + function.get(), "[{\"interactive\": true," "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]", browser())); @@ -718,7 +719,7 @@ IN_PROC_BROWSER_TEST_F(ExperimentalLaunchWebAuthFlowFunctionTest, function->InitFinalRedirectURLPrefixesForTest("abcdefghij"); scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( - function, + function.get(), "[{\"interactive\": true," "\"url\": \"data:text/html,<script>window.location.replace('" "https://abcdefghij.chromiumapp.org/callback#test')</script>\"}]", diff --git a/chrome/browser/extensions/api/identity/identity_apitest.cc b/chrome/browser/extensions/api/identity/identity_apitest.cc index f2707bc..736b806 100644 --- a/chrome/browser/extensions/api/identity/identity_apitest.cc +++ b/chrome/browser/extensions/api/identity/identity_apitest.cc @@ -384,9 +384,8 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NonInteractiveMintAdviceSuccess) { scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); - func->set_extension(extension); - EXPECT_CALL(*func.get(), HasLoginToken()) - .WillOnce(Return(true)); + func->set_extension(extension.get()); + EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true)); TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow( TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get()); EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow)); @@ -396,10 +395,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, EXPECT_FALSE(func->login_ui_shown()); EXPECT_FALSE(func->scope_ui_shown()); - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension); - EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_ADVICE, - id_api()->GetCachedToken(extension->id(), - oauth2_info.scopes).status()); + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); + EXPECT_EQ( + IdentityTokenCacheValue::CACHE_STATUS_ADVICE, + id_api()->GetCachedToken(extension->id(), oauth2_info.scopes).status()); } IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, @@ -422,10 +421,9 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NonInteractiveSuccess) { scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); - func->set_extension(extension); - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension); - EXPECT_CALL(*func.get(), HasLoginToken()) - .WillOnce(Return(true)); + func->set_extension(extension.get()); + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); + EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true)); TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow( TestOAuth2MintTokenFlow::MINT_TOKEN_SUCCESS, func.get()); EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow)); @@ -542,9 +540,8 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, InteractiveLoginSuccessApprovalSuccess) { scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); - func->set_extension(extension); - EXPECT_CALL(*func.get(), HasLoginToken()) - .WillOnce(Return(false)); + func->set_extension(extension.get()); + EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(false)); func->set_login_ui_result(true); TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow( TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get()); @@ -644,7 +641,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, ++it) { scoped_refptr<MockGetAuthTokenFunction> func( new MockGetAuthTokenFunction()); - func->set_extension(extension); + func->set_extension(extension.get()); EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true)); TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow( TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get()); @@ -661,11 +658,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, InteractiveApprovalSuccess) { scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension); + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); - func->set_extension(extension); - EXPECT_CALL(*func.get(), HasLoginToken()) - .WillOnce(Return(true)); + func->set_extension(extension.get()); + EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true)); TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow( TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get()); EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)) @@ -687,10 +683,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NoninteractiveQueue) { scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); - func->set_extension(extension); + func->set_extension(extension.get()); // Create a fake request to block the queue. - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension); + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); std::set<std::string> scopes(oauth2_info.scopes.begin(), oauth2_info.scopes.end()); IdentityAPI* id_api = @@ -707,9 +703,9 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NoninteractiveQueue) { // The real request will start processing, but wait in the queue behind // the blocker. EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true)); - RunFunctionAsync(func, "[{}]"); + RunFunctionAsync(func.get(), "[{}]"); // Verify that we have fetched the login token at this point. - testing::Mock::VerifyAndClearExpectations(func); + testing::Mock::VerifyAndClearExpectations(func.get()); // The flow will be created after the first queued request clears. TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow( @@ -718,7 +714,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NoninteractiveQueue) { queue->RequestComplete(type, extension->id(), scopes, &queued_request); - scoped_ptr<base::Value> value(WaitForSingleResult(func)); + scoped_ptr<base::Value> value(WaitForSingleResult(func.get())); std::string access_token; EXPECT_TRUE(value->GetAsString(&access_token)); EXPECT_EQ(std::string(kAccessToken), access_token); @@ -729,10 +725,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NoninteractiveQueue) { IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, InteractiveQueue) { scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); - func->set_extension(extension); + func->set_extension(extension.get()); // Create a fake request to block the queue. - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension); + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); std::set<std::string> scopes(oauth2_info.scopes.begin(), oauth2_info.scopes.end()); IdentityAPI* id_api = @@ -752,16 +748,16 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, InteractiveQueue) { TestOAuth2MintTokenFlow* flow1 = new TestOAuth2MintTokenFlow( TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get()); EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow1)); - RunFunctionAsync(func, "[{\"interactive\": true}]"); + RunFunctionAsync(func.get(), "[{\"interactive\": true}]"); // Verify that we have fetched the login token and run the first flow. - testing::Mock::VerifyAndClearExpectations(func); + testing::Mock::VerifyAndClearExpectations(func.get()); EXPECT_FALSE(func->scope_ui_shown()); // The UI will be displayed and a token retrieved after the first // queued request clears. queue->RequestComplete(type, extension->id(), scopes, &queued_request); - scoped_ptr<base::Value> value(WaitForSingleResult(func)); + scoped_ptr<base::Value> value(WaitForSingleResult(func.get())); std::string access_token; EXPECT_TRUE(value->GetAsString(&access_token)); EXPECT_EQ(std::string(kAccessToken), access_token); @@ -773,10 +769,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, InteractiveQueuedNoninteractiveFails) { scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); - func->set_extension(extension); + func->set_extension(extension.get()); // Create a fake request to block the interactive queue. - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension); + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); std::set<std::string> scopes(oauth2_info.scopes.begin(), oauth2_info.scopes.end()); IdentityAPI* id_api = @@ -806,10 +802,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NonInteractiveCacheHit) { scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); - func->set_extension(extension); + func->set_extension(extension.get()); // pre-populate the cache with a token - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension); + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); IdentityTokenCacheValue token(kAccessToken, base::TimeDelta::FromSeconds(3600)); id_api()->SetCachedToken(extension->id(), oauth2_info.scopes, token); @@ -830,10 +826,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, NonInteractiveIssueAdviceCacheHit) { scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); - func->set_extension(extension); + func->set_extension(extension.get()); // pre-populate the cache with advice - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension); + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); IssueAdviceInfo info; IdentityTokenCacheValue token(info); id_api()->SetCachedToken(extension->id(), oauth2_info.scopes, token); @@ -852,10 +848,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, InteractiveCacheHit) { scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); - func->set_extension(extension); + func->set_extension(extension.get()); // Create a fake request to block the queue. - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension); + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); std::set<std::string> scopes(oauth2_info.scopes.begin(), oauth2_info.scopes.end()); IdentityMintRequestQueue* queue = id_api()->mint_queue(); @@ -872,7 +868,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow( TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS, func.get()); EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow)); - RunFunctionAsync(func, "[{\"interactive\": true}]"); + RunFunctionAsync(func.get(), "[{\"interactive\": true}]"); // Populate the cache with a token while the request is blocked. IdentityTokenCacheValue token(kAccessToken, @@ -884,7 +880,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, queue->RequestComplete(type, extension->id(), scopes, &queued_request); - scoped_ptr<base::Value> value(WaitForSingleResult(func)); + scoped_ptr<base::Value> value(WaitForSingleResult(func.get())); std::string access_token; EXPECT_TRUE(value->GetAsString(&access_token)); EXPECT_EQ(std::string(kAccessToken), access_token); @@ -896,10 +892,10 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, LoginInvalidatesTokenCache) { scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); - func->set_extension(extension); + func->set_extension(extension.get()); // pre-populate the cache with a token - const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension); + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); IdentityTokenCacheValue token(kAccessToken, base::TimeDelta::FromSeconds(3600)); id_api()->SetCachedToken(extension->id(), oauth2_info.scopes, token); @@ -933,7 +929,9 @@ class RemoveCachedAuthTokenFunctionTest : public ExtensionBrowserTest { new IdentityRemoveCachedAuthTokenFunction); func->set_extension(utils::CreateEmptyExtension(kExtensionId)); return utils::RunFunction( - func, std::string("[{\"token\": \"") + kAccessToken + "\"}]", browser(), + func.get(), + std::string("[{\"token\": \"") + kAccessToken + "\"}]", + browser(), extension_function_test_utils::NONE); } @@ -1016,11 +1014,11 @@ IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, std::string args = "[{\"interactive\": true, \"url\": \"" + auth_url.spec() + "\"}]"; - RunFunctionAsync(function, args); + RunFunctionAsync(function.get(), args); popup_observer.Wait(); - EXPECT_EQ(std::string(errors::kUserRejected), WaitForError(function)); + EXPECT_EQ(std::string(errors::kUserRejected), WaitForError(function.get())); } IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, InteractionRequired) { @@ -1040,8 +1038,8 @@ IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, InteractionRequired) { std::string args = "[{\"interactive\": false, \"url\": \"" + auth_url.spec() + "\"}]"; - std::string error = utils::RunFunctionAndReturnError(function, args, - browser()); + std::string error = + utils::RunFunctionAndReturnError(function.get(), args, browser()); EXPECT_EQ(std::string(errors::kInteractionRequired), error); } @@ -1078,7 +1076,7 @@ IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, NonInteractiveSuccess) { function->InitFinalRedirectURLPrefixForTest("abcdefghij"); scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( - function, + function.get(), "[{\"interactive\": false," "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]", browser())); @@ -1099,7 +1097,7 @@ IN_PROC_BROWSER_TEST_F( function->InitFinalRedirectURLPrefixForTest("abcdefghij"); scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( - function, + function.get(), "[{\"interactive\": true," "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]", browser())); @@ -1129,8 +1127,8 @@ IN_PROC_BROWSER_TEST_F( function->InitFinalRedirectURLPrefixForTest("abcdefghij"); std::string args = "[{\"interactive\": true, \"url\": \"" + auth_url.spec() + "\"}]"; - scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( - function, args, browser())); + scoped_ptr<base::Value> value( + utils::RunFunctionAndReturnSingleResult(function.get(), args, browser())); std::string url; EXPECT_TRUE(value->GetAsString(&url)); diff --git a/chrome/browser/extensions/api/idle/idle_api_unittest.cc b/chrome/browser/extensions/api/idle/idle_api_unittest.cc index e55ef07..61f385b 100644 --- a/chrome/browser/extensions/api/idle/idle_api_unittest.cc +++ b/chrome/browser/extensions/api/idle/idle_api_unittest.cc @@ -522,7 +522,7 @@ TEST_F(IdleTest, UnloadCleanup) { } // Threshold will reset after unload (and listen count == 0) - UnloadedExtensionInfo details(extension_, + UnloadedExtensionInfo details(extension_.get(), extension_misc::UNLOAD_REASON_UNINSTALL); idle_manager_->Observe( chrome::NOTIFICATION_EXTENSION_UNLOADED, @@ -543,7 +543,7 @@ TEST_F(IdleTest, UnloadCleanup) { // Verifies that unloading an extension with no listeners or threshold works. TEST_F(IdleTest, UnloadOnly) { - UnloadedExtensionInfo details(extension_, + UnloadedExtensionInfo details(extension_.get(), extension_misc::UNLOAD_REASON_UNINSTALL); idle_manager_->Observe( chrome::NOTIFICATION_EXTENSION_UNLOADED, @@ -555,7 +555,7 @@ TEST_F(IdleTest, UnloadOnly) { // listener removals. TEST_F(IdleTest, UnloadWhileListening) { ScopedListen listen(idle_manager_, extension_->id()); - UnloadedExtensionInfo details(extension_, + UnloadedExtensionInfo details(extension_.get(), extension_misc::UNLOAD_REASON_UNINSTALL); idle_manager_->Observe( chrome::NOTIFICATION_EXTENSION_UNLOADED, diff --git a/chrome/browser/extensions/api/management/management_api.cc b/chrome/browser/extensions/api/management/management_api.cc index a1bd36e..6c15861 100644 --- a/chrome/browser/extensions/api/management/management_api.cc +++ b/chrome/browser/extensions/api/management/management_api.cc @@ -394,9 +394,9 @@ void ManagementGetPermissionWarningsByManifestFunction::OnParseSuccess( return; } - std::vector<std::string> warnings = CreateWarningsList(extension); - results_ = management::GetPermissionWarningsByManifest::Results::Create( - warnings); + std::vector<std::string> warnings = CreateWarningsList(extension.get()); + results_ = + management::GetPermissionWarningsByManifest::Results::Create(warnings); SendResponse(true); // Matched with AddRef() in RunImpl(). diff --git a/chrome/browser/extensions/api/management/management_api_browsertest.cc b/chrome/browser/extensions/api/management/management_api_browsertest.cc index 5b6b04d..8361c89 100644 --- a/chrome/browser/extensions/api/management/management_api_browsertest.cc +++ b/chrome/browser/extensions/api/management/management_api_browsertest.cc @@ -112,9 +112,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiBrowserTest, EXPECT_TRUE(MatchPattern( util::RunFunctionAndReturnError( - uninstall_function, + uninstall_function.get(), base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]", - id.c_str()), + id.c_str()), browser()), keys::kUninstallCanceledError)); @@ -126,7 +126,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiBrowserTest, ManagementUninstallFunction::SetAutoConfirmForTest(true); util::RunFunctionAndReturnSingleResult( - uninstall_function, + uninstall_function.get(), base::StringPrintf("[\"%s\", {\"showConfirmDialog\": true}]", id.c_str()), browser()); diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host.cc b/chrome/browser/extensions/api/messaging/native_message_process_host.cc index 1f713d3..9f8c50b 100644 --- a/chrome/browser/extensions/api/messaging/native_message_process_host.cc +++ b/chrome/browser/extensions/api/messaging/native_message_process_host.cc @@ -215,9 +215,9 @@ void NativeMessageProcessHost::DoRead() { while (!closed_ && !read_eof_ && !read_pending_) { read_buffer_ = new net::IOBuffer(kReadBufferSize); int result = read_stream_->Read( - read_buffer_, kReadBufferSize, - base::Bind(&NativeMessageProcessHost::OnRead, - base::Unretained(this))); + read_buffer_.get(), + kReadBufferSize, + base::Bind(&NativeMessageProcessHost::OnRead, base::Unretained(this))); HandleReadResult(result); } } @@ -310,18 +310,20 @@ void NativeMessageProcessHost::DoWrite() { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); while (!write_pending_ && !closed_) { - if (!current_write_buffer_ || !current_write_buffer_->BytesRemaining()) { + if (!current_write_buffer_.get() || + !current_write_buffer_->BytesRemaining()) { if (write_queue_.empty()) return; current_write_buffer_ = new net::DrainableIOBuffer( - write_queue_.front(), write_queue_.front()->size()); + write_queue_.front().get(), write_queue_.front()->size()); write_queue_.pop(); } - int result = write_stream_->Write( - current_write_buffer_, current_write_buffer_->BytesRemaining(), - base::Bind(&NativeMessageProcessHost::OnWritten, - base::Unretained(this))); + int result = + write_stream_->Write(current_write_buffer_.get(), + current_write_buffer_->BytesRemaining(), + base::Bind(&NativeMessageProcessHost::OnWritten, + base::Unretained(this))); HandleWriteResult(result); } } diff --git a/chrome/browser/extensions/api/notifications/notifications_api.cc b/chrome/browser/extensions/api/notifications/notifications_api.cc index 597cc8a..3bacbad 100644 --- a/chrome/browser/extensions/api/notifications/notifications_api.cc +++ b/chrome/browser/extensions/api/notifications/notifications_api.cc @@ -58,7 +58,7 @@ class NotificationsApiDelegate : public NotificationDelegate { id_(id), scoped_id_(CreateScopedIdentifier(extension_id, id)), process_id_(-1) { - DCHECK(api_function_); + DCHECK(api_function_.get()); if (api_function_->render_view_host()) process_id_ = api_function->render_view_host()->GetProcess()->GetID(); } @@ -105,7 +105,7 @@ class NotificationsApiDelegate : public NotificationDelegate { // until ReleaseRVH is called, and api_function_ (as a // UIThreadExtensionFunction) will zero out its copy of render_view_host // when the RVH goes away. - if (!api_function_) + if (!api_function_.get()) return NULL; return api_function_->render_view_host(); } diff --git a/chrome/browser/extensions/api/notifications/notifications_apitest.cc b/chrome/browser/extensions/api/notifications/notifications_apitest.cc index bf145fc..01d7c9d 100644 --- a/chrome/browser/extensions/api/notifications/notifications_apitest.cc +++ b/chrome/browser/extensions/api/notifications/notifications_apitest.cc @@ -70,7 +70,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestIdUsage) { notification_function->set_has_callback(true); scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - notification_function, + notification_function.get(), "[\"\", " // Empty string: ask API to generate ID "{" "\"type\": \"basic\"," @@ -78,7 +78,8 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestIdUsage) { "\"title\": \"Attention!\"," "\"message\": \"Check out Cirque du Soleil\"" "}]", - browser(), utils::NONE)); + browser(), + utils::NONE)); ASSERT_EQ(base::Value::TYPE_STRING, result->GetType()); ASSERT_TRUE(result->GetAsString(¬ification_id)); @@ -95,15 +96,17 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestIdUsage) { notification_function->set_has_callback(true); scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - notification_function, - "[\"" + notification_id + "\", " - "{" - "\"type\": \"basic\"," - "\"iconUrl\": \"an/image/that/does/not/exist.png\"," - "\"title\": \"Attention!\"," - "\"message\": \"Too late! The show ended yesterday\"" - "}]", - browser(), utils::NONE)); + notification_function.get(), + "[\"" + notification_id + + "\", " + "{" + "\"type\": \"basic\"," + "\"iconUrl\": \"an/image/that/does/not/exist.png\"," + "\"title\": \"Attention!\"," + "\"message\": \"Too late! The show ended yesterday\"" + "}]", + browser(), + utils::NONE)); ASSERT_EQ(base::Value::TYPE_BOOLEAN, result->GetType()); bool copy_bool_value = false; @@ -127,7 +130,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestIdUsage) { notification_function->set_has_callback(true); scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - notification_function, + notification_function.get(), "[\"xxxxxxxxxxxx\", " "{" "\"type\": \"basic\"," @@ -135,7 +138,8 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestIdUsage) { "\"title\": \"!\"," "\"message\": \"!\"" "}]", - browser(), utils::NONE)); + browser(), + utils::NONE)); ASSERT_EQ(base::Value::TYPE_BOOLEAN, result->GetType()); bool copy_bool_value = false; @@ -152,9 +156,11 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestIdUsage) { notification_function->set_extension(empty_extension.get()); notification_function->set_has_callback(true); - scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - notification_function, - "[\"xxxxxxxxxxx\"]", browser(), utils::NONE)); + scoped_ptr<base::Value> result( + utils::RunFunctionAndReturnSingleResult(notification_function.get(), + "[\"xxxxxxxxxxx\"]", + browser(), + utils::NONE)); ASSERT_EQ(base::Value::TYPE_BOOLEAN, result->GetType()); bool copy_bool_value = false; @@ -171,9 +177,11 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestIdUsage) { notification_function->set_extension(empty_extension.get()); notification_function->set_has_callback(true); - scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - notification_function, - "[\"" + notification_id + "\"]", browser(), utils::NONE)); + scoped_ptr<base::Value> result( + utils::RunFunctionAndReturnSingleResult(notification_function.get(), + "[\"" + notification_id + "\"]", + browser(), + utils::NONE)); ASSERT_EQ(base::Value::TYPE_BOOLEAN, result->GetType()); bool copy_bool_value = false; @@ -192,7 +200,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestBaseFormatNotification) { notification_create_function->set_has_callback(true); scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - notification_create_function, + notification_create_function.get(), "[\"\", " "{" "\"type\": \"basic\"," @@ -213,7 +221,8 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestBaseFormatNotification) { "\"expandedMessage\": \"This is a longer expanded message.\"," "\"imageUrl\": \"http://www.google.com/logos/2012/election12-hp.jpg\"" "}]", - browser(), utils::NONE)); + browser(), + utils::NONE)); std::string notification_id; ASSERT_EQ(base::Value::TYPE_STRING, result->GetType()); @@ -231,7 +240,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestMultipleItemNotification) { notification_create_function->set_has_callback(true); scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - notification_create_function, + notification_create_function.get(), "[\"\", " "{" "\"type\": \"list\"," @@ -253,7 +262,8 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestMultipleItemNotification) { "\"priority\": 1," "\"eventTime\": 1361488019.9999999" "}]", - browser(), utils::NONE)); + browser(), + utils::NONE)); // TODO(dharcourt): [...], items = [{title: foo, message: bar}, ...], [...] std::string notification_id; @@ -278,7 +288,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestGetAll) { notification_get_all_function->set_extension(empty_extension.get()); notification_get_all_function->set_has_callback(true); scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - notification_get_all_function, "[]", browser(), utils::NONE)); + notification_get_all_function.get(), "[]", browser(), utils::NONE)); base::DictionaryValue* return_value; ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); @@ -297,7 +307,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestGetAll) { notification_create_function->set_has_callback(true); scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - notification_create_function, + notification_create_function.get(), base::StringPrintf("[\"identifier-%u\", " "{" "\"type\": \"basic\"," @@ -319,7 +329,7 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestGetAll) { notification_get_all_function->set_extension(empty_extension.get()); notification_get_all_function->set_has_callback(true); scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - notification_get_all_function, "[]", browser(), utils::NONE)); + notification_get_all_function.get(), "[]", browser(), utils::NONE)); base::DictionaryValue* return_value; ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); diff --git a/chrome/browser/extensions/api/permissions/permissions_api.cc b/chrome/browser/extensions/api/permissions/permissions_api.cc index cbaf1d9..0b526a8 100644 --- a/chrome/browser/extensions/api/permissions/permissions_api.cc +++ b/chrome/browser/extensions/api/permissions/permissions_api.cc @@ -62,7 +62,7 @@ bool PermissionsContainsFunction::RunImpl() { return false; results_ = Contains::Results::Create( - GetExtension()->GetActivePermissions()->Contains(*permissions)); + GetExtension()->GetActivePermissions()->Contains(*permissions.get())); return true; } @@ -181,8 +181,8 @@ bool PermissionsRequestFunction::RunImpl() { requested_permissions_.get()); // The requested permissions must be defined as optional in the manifest. - if (!PermissionsData::GetOptionalPermissions(GetExtension())->Contains( - *manifest_required_requested_permissions)) { + if (!PermissionsData::GetOptionalPermissions(GetExtension()) + ->Contains(*manifest_required_requested_permissions.get())) { error_ = kNotInOptionalPermissionsError; return false; } @@ -192,7 +192,7 @@ bool PermissionsRequestFunction::RunImpl() { scoped_refptr<const PermissionSet> granted = ExtensionPrefs::Get(profile_)-> GetGrantedPermissions(GetExtension()->id()); - if (granted && granted->Contains(*requested_permissions_)) { + if (granted.get() && granted->Contains(*requested_permissions_.get())) { PermissionsUpdater perms_updater(profile()); perms_updater.AddPermissions(GetExtension(), requested_permissions_.get()); results_ = Request::Results::Create(true); diff --git a/chrome/browser/extensions/api/permissions/permissions_api_helpers_unittest.cc b/chrome/browser/extensions/api/permissions/permissions_api_helpers_unittest.cc index 28c94ac..429ee70 100644 --- a/chrome/browser/extensions/api/permissions/permissions_api_helpers_unittest.cc +++ b/chrome/browser/extensions/api/permissions/permissions_api_helpers_unittest.cc @@ -40,7 +40,7 @@ TEST(ExtensionPermissionsAPIHelpers, Pack) { new PermissionSet(apis, hosts, URLPatternSet()); // Pack the permission set to value and verify its contents. - scoped_ptr<Permissions> permissions(PackPermissionSet(permission_set)); + scoped_ptr<Permissions> permissions(PackPermissionSet(permission_set.get())); scoped_ptr<DictionaryValue> value(permissions->ToValue()); ListValue* api_list = NULL; ListValue* origin_list = NULL; @@ -71,7 +71,7 @@ TEST(ExtensionPermissionsAPIHelpers, Pack) { from_value = UnpackPermissionSet(permissions_object, true, &error); EXPECT_TRUE(error.empty()); - EXPECT_EQ(*permission_set, *from_value); + EXPECT_EQ(*permission_set.get(), *from_value.get()); } // Tests various error conditions and edge cases when unpacking values @@ -93,7 +93,7 @@ TEST(ExtensionPermissionsAPIHelpers, Unpack) { EXPECT_TRUE(Permissions::Populate(*value, &permissions_object)); permissions = UnpackPermissionSet(permissions_object, true, &error); EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kTab)); - EXPECT_TRUE(permissions); + EXPECT_TRUE(permissions.get()); EXPECT_TRUE(error.empty()); } @@ -104,7 +104,7 @@ TEST(ExtensionPermissionsAPIHelpers, Unpack) { value->Set("origins", origins->DeepCopy()); EXPECT_TRUE(Permissions::Populate(*value, &permissions_object)); permissions = UnpackPermissionSet(permissions_object, true, &error); - EXPECT_TRUE(permissions); + EXPECT_TRUE(permissions.get()); EXPECT_TRUE(error.empty()); EXPECT_TRUE(permissions->HasExplicitAccessToOrigin(GURL("http://a.com/"))); } @@ -152,7 +152,7 @@ TEST(ExtensionPermissionsAPIHelpers, Unpack) { value->Set("random", Value::CreateIntegerValue(3)); EXPECT_TRUE(Permissions::Populate(*value, &permissions_object)); permissions = UnpackPermissionSet(permissions_object, true, &error); - EXPECT_TRUE(permissions); + EXPECT_TRUE(permissions.get()); EXPECT_TRUE(error.empty()); EXPECT_TRUE(permissions->HasExplicitAccessToOrigin(GURL("http://a.com/"))); } @@ -166,7 +166,7 @@ TEST(ExtensionPermissionsAPIHelpers, Unpack) { value->Set("permissions", invalid_apis->DeepCopy()); EXPECT_TRUE(Permissions::Populate(*value, &permissions_object)); permissions = UnpackPermissionSet(permissions_object, true, &error); - EXPECT_FALSE(permissions); + EXPECT_FALSE(permissions.get()); EXPECT_FALSE(error.empty()); EXPECT_EQ(error, "'unknown_permission' is not a recognized permission."); } diff --git a/chrome/browser/extensions/api/permissions/permissions_apitest.cc b/chrome/browser/extensions/api/permissions/permissions_apitest.cc index 82bd17f..ef20085 100644 --- a/chrome/browser/extensions/api/permissions/permissions_apitest.cc +++ b/chrome/browser/extensions/api/permissions/permissions_apitest.cc @@ -80,7 +80,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OptionalPermissionsGranted) { ExtensionPrefs* prefs = browser()->profile()->GetExtensionService()->extension_prefs(); prefs->AddGrantedPermissions("kjmkgkdkpedkejedfhmfcenooemhbpbo", - granted_permissions); + granted_permissions.get()); PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); host_resolver()->AddRule("*.com", "127.0.0.1"); diff --git a/chrome/browser/extensions/api/power/power_api_unittest.cc b/chrome/browser/extensions/api/power/power_api_unittest.cc index 07870a6..9e7ca2e 100644 --- a/chrome/browser/extensions/api/power/power_api_unittest.cc +++ b/chrome/browser/extensions/api/power/power_api_unittest.cc @@ -157,7 +157,7 @@ class PowerApiTest : public BrowserWithTestWindowTest { static_cast<UIThreadExtensionFunction*>( new PowerReleaseKeepAwakeFunction)); function->set_extension(extension); - return utils::RunFunction(function, args, browser(), utils::NONE); + return utils::RunFunction(function.get(), args, browser(), utils::NONE); } // Send a notification to PowerApiManager saying that |extension| has diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_canary_test.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_canary_test.cc index 13d7233..f0bf6f11 100644 --- a/chrome/browser/extensions/api/push_messaging/push_messaging_canary_test.cc +++ b/chrome/browser/extensions/api/push_messaging/push_messaging_canary_test.cc @@ -111,7 +111,7 @@ class PushMessagingCanaryTest : public ExtensionApiTest { resolver->AllowDirectLookup("*.gstatic.com"); resolver->AllowDirectLookup("*.googleapis.com"); mock_host_resolver_override_.reset( - new net::ScopedDefaultHostResolverProc(resolver)); + new net::ScopedDefaultHostResolverProc(resolver.get())); } // We need to reset the DNS lookup when we finish, or the test will fail. diff --git a/chrome/browser/extensions/api/record/record_api_test.cc b/chrome/browser/extensions/api/record/record_api_test.cc index 6827a6e..458858f 100644 --- a/chrome/browser/extensions/api/record/record_api_test.cc +++ b/chrome/browser/extensions/api/record/record_api_test.cc @@ -319,10 +319,11 @@ IN_PROC_BROWSER_TEST_F(RecordApiTest, MAYBE_CheckPlayback) { scoped_refptr<RecordReplayURLsFunction> playback_function( new RecordReplayURLsFunction( new TestProcessStrategy(&temp_files_))); - scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( - utils::RunFunctionAndReturnSingleResult(playback_function, - base::StringPrintf(kPlaybackArgs1, escaped_user_data_dir.c_str()), - browser()))); + scoped_ptr<base::DictionaryValue> result( + utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( + playback_function.get(), + base::StringPrintf(kPlaybackArgs1, escaped_user_data_dir.c_str()), + browser()))); // Check that command line user-data-dir was overridden. (That // it was *consistently* overridden in both capture and replay diff --git a/chrome/browser/extensions/api/socket/socket_apitest.cc b/chrome/browser/extensions/api/socket/socket_apitest.cc index 2712236..bf3be55 100644 --- a/chrome/browser/extensions/api/socket/socket_apitest.cc +++ b/chrome/browser/extensions/api/socket/socket_apitest.cc @@ -123,9 +123,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPCreateGood) { socket_create_function->set_has_callback(true); scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - socket_create_function, - "[\"udp\"]", - browser(), utils::NONE)); + socket_create_function.get(), "[\"udp\"]", browser(), utils::NONE)); ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); int socketId = -1; @@ -142,9 +140,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPCreateGood) { socket_create_function->set_has_callback(true); scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - socket_create_function, - "[\"tcp\"]", - browser(), utils::NONE)); + socket_create_function.get(), "[\"tcp\"]", browser(), utils::NONE)); ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); DictionaryValue *value = static_cast<DictionaryValue*>(result.get()); int socketId = -1; @@ -161,7 +157,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, GetNetworkList) { socket_function->set_has_callback(true); scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult( - socket_function, "[]", browser(), utils::NONE)); + socket_function.get(), "[]", browser(), utils::NONE)); ASSERT_EQ(base::Value::TYPE_LIST, result->GetType()); // If we're invoking socket tests, all we can confirm is that we have at diff --git a/chrome/browser/extensions/api/storage/settings_frontend.cc b/chrome/browser/extensions/api/storage/settings_frontend.cc index ac2512b..dece669 100644 --- a/chrome/browser/extensions/api/storage/settings_frontend.cc +++ b/chrome/browser/extensions/api/storage/settings_frontend.cc @@ -176,7 +176,7 @@ void SettingsFrontend::RunWithStorage( scoped_refptr<const Extension> extension = extensions::ExtensionSystem::Get(profile_)->extension_service()-> GetExtensionById(extension_id, true); - CHECK(extension); + CHECK(extension.get()); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, diff --git a/chrome/browser/extensions/api/storage/storage_schema_manifest_handler_unittest.cc b/chrome/browser/extensions/api/storage/storage_schema_manifest_handler_unittest.cc index 2134486..1d0a7bb 100644 --- a/chrome/browser/extensions/api/storage/storage_schema_manifest_handler_unittest.cc +++ b/chrome/browser/extensions/api/storage/storage_schema_manifest_handler_unittest.cc @@ -44,7 +44,7 @@ class StorageSchemaManifestHandlerTest : public testing::Test { scoped_refptr<Extension> extension = Extension::Create( temp_dir_.path(), Manifest::UNPACKED, manifest_, Extension::NO_FLAGS, "", &error); - if (!extension) + if (!extension.get()) return NULL; base::FilePath schema_path = temp_dir_.path().AppendASCII("schema.json"); if (schema.empty()) { @@ -60,7 +60,7 @@ class StorageSchemaManifestHandlerTest : public testing::Test { testing::AssertionResult Validates(const std::string& schema) { scoped_refptr<Extension> extension = CreateExtension(schema); - if (!extension) + if (!extension.get()) return testing::AssertionFailure() << "Failed to create test extension"; std::string error; std::vector<InstallWarning> warnings; @@ -78,7 +78,7 @@ class StorageSchemaManifestHandlerTest : public testing::Test { TEST_F(StorageSchemaManifestHandlerTest, Parse) { scoped_refptr<Extension> extension = CreateExtension(""); - ASSERT_TRUE(extension); + ASSERT_TRUE(extension.get()); // No storage.managed_schema entry. string16 error; @@ -87,12 +87,12 @@ TEST_F(StorageSchemaManifestHandlerTest, Parse) { // Not a string. manifest_.SetInteger("storage.managed_schema", 123); extension = CreateExtension(""); - EXPECT_FALSE(extension); + EXPECT_FALSE(extension.get()); // All good now. manifest_.SetString("storage.managed_schema", "schema.json"); extension = CreateExtension(""); - ASSERT_TRUE(extension); + ASSERT_TRUE(extension.get()); EXPECT_TRUE(handler_->Parse(extension.get(), &error)) << error; } diff --git a/chrome/browser/extensions/api/streams_private/streams_private_manifest_unittest.cc b/chrome/browser/extensions/api/streams_private/streams_private_manifest_unittest.cc index 6f8aae5..98518f3 100644 --- a/chrome/browser/extensions/api/streams_private/streams_private_manifest_unittest.cc +++ b/chrome/browser/extensions/api/streams_private/streams_private_manifest_unittest.cc @@ -37,7 +37,7 @@ TEST_F(StreamsPrivateManifestTest, ValidMimeTypesHandlerMIMETypes) { .Build(); ASSERT_TRUE(extension.get()); - MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); + MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension.get()); ASSERT_TRUE(handler != NULL); EXPECT_FALSE(handler->CanHandleMIMEType("plain/html")); @@ -58,7 +58,7 @@ TEST_F(StreamsPrivateManifestTest, ASSERT_TRUE(extension.get()); - MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); + MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension.get()); ASSERT_TRUE(handler == NULL); } diff --git a/chrome/browser/extensions/api/system_info/system_info_provider.h b/chrome/browser/extensions/api/system_info/system_info_provider.h index 849075d..574e629 100644 --- a/chrome/browser/extensions/api/system_info/system_info_provider.h +++ b/chrome/browser/extensions/api/system_info/system_info_provider.h @@ -51,7 +51,7 @@ class SystemInfoProvider // For testing static void InitializeForTesting( scoped_refptr<SystemInfoProvider<T> > provider) { - DCHECK(provider != NULL); + DCHECK(provider.get() != NULL); single_shared_provider_.Get() = provider; } diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc index fcb587b..288d2cf 100644 --- a/chrome/browser/extensions/api/tabs/tabs_api.cc +++ b/chrome/browser/extensions/api/tabs/tabs_api.cc @@ -1967,9 +1967,8 @@ ExecuteCodeInTabFunction::ExecuteCodeInTabFunction() ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() {} bool ExecuteCodeInTabFunction::HasPermission() { - if (Init() && - PermissionsData::HasAPIPermissionForTab( - extension_, execute_tab_id_, APIPermission::kTab)) { + if (Init() && PermissionsData::HasAPIPermissionForTab( + extension_.get(), execute_tab_id_, APIPermission::kTab)) { return true; } return ExtensionFunction::HasPermission(); diff --git a/chrome/browser/extensions/api/usb/usb_api.cc b/chrome/browser/extensions/api/usb/usb_api.cc index a1da7ba..453f8940 100644 --- a/chrome/browser/extensions/api/usb/usb_api.cc +++ b/chrome/browser/extensions/api/usb/usb_api.cc @@ -450,9 +450,9 @@ void UsbFindDevicesFunction::AsyncWorkStart() { void UsbFindDevicesFunction::OnCompleted() { for (size_t i = 0; i < devices_.size(); ++i) { - UsbDevice* const device = devices_[i]; - UsbDeviceResource* const resource = new UsbDeviceResource( - extension_->id(), device); + UsbDevice* const device = devices_[i].get(); + UsbDeviceResource* const resource = + new UsbDeviceResource(extension_->id(), device); Device js_device; result_->Append(PopulateDevice(manager_->Add(resource), @@ -483,8 +483,8 @@ void UsbListInterfacesFunction::AsyncWorkStart() { } config_ = new UsbConfigDescriptor(); - resource->device()->ListInterfaces(config_, base::Bind( - &UsbListInterfacesFunction::OnCompleted, this)); + resource->device()->ListInterfaces( + config_.get(), base::Bind(&UsbListInterfacesFunction::OnCompleted, this)); } void UsbListInterfacesFunction::OnCompleted(bool success) { @@ -743,13 +743,21 @@ void UsbControlTransferFunction::AsyncWorkStart() { scoped_refptr<net::IOBuffer> buffer = CreateBufferForTransfer( transfer, direction, size); - if (!buffer) { + if (!buffer.get()) { CompleteWithError(kErrorMalformedParameters); return; } - resource->device()->ControlTransfer(direction, request_type, recipient, - transfer.request, transfer.value, transfer.index, buffer, size, 0, + resource->device()->ControlTransfer( + direction, + request_type, + recipient, + transfer.request, + transfer.value, + transfer.index, + buffer.get(), + size, + 0, base::Bind(&UsbControlTransferFunction::OnCompleted, this)); } @@ -788,13 +796,18 @@ void UsbBulkTransferFunction::AsyncWorkStart() { scoped_refptr<net::IOBuffer> buffer = CreateBufferForTransfer( transfer, direction, size); - if (!buffer) { + if (!buffer.get()) { CompleteWithError(kErrorMalformedParameters); return; } - resource->device()->BulkTransfer(direction, transfer.endpoint, - buffer, size, 0, base::Bind(&UsbBulkTransferFunction::OnCompleted, this)); + resource->device() + ->BulkTransfer(direction, + transfer.endpoint, + buffer.get(), + size, + 0, + base::Bind(&UsbBulkTransferFunction::OnCompleted, this)); } UsbInterruptTransferFunction::UsbInterruptTransferFunction() {} @@ -832,13 +845,18 @@ void UsbInterruptTransferFunction::AsyncWorkStart() { scoped_refptr<net::IOBuffer> buffer = CreateBufferForTransfer( transfer, direction, size); - if (!buffer) { + if (!buffer.get()) { CompleteWithError(kErrorMalformedParameters); return; } - resource->device()->InterruptTransfer(direction, transfer.endpoint, buffer, - size, 0, base::Bind(&UsbInterruptTransferFunction::OnCompleted, this)); + resource->device()->InterruptTransfer( + direction, + transfer.endpoint, + buffer.get(), + size, + 0, + base::Bind(&UsbInterruptTransferFunction::OnCompleted, this)); } UsbIsochronousTransferFunction::UsbIsochronousTransferFunction() {} @@ -892,14 +910,20 @@ void UsbIsochronousTransferFunction::AsyncWorkStart() { scoped_refptr<net::IOBuffer> buffer = CreateBufferForTransfer( generic_transfer, direction, size); - if (!buffer) { + if (!buffer.get()) { CompleteWithError(kErrorMalformedParameters); return; } - resource->device()->IsochronousTransfer(direction, generic_transfer.endpoint, - buffer, size, packets, packet_length, 0, base::Bind( - &UsbIsochronousTransferFunction::OnCompleted, this)); + resource->device()->IsochronousTransfer( + direction, + generic_transfer.endpoint, + buffer.get(), + size, + packets, + packet_length, + 0, + base::Bind(&UsbIsochronousTransferFunction::OnCompleted, this)); } UsbResetDeviceFunction::UsbResetDeviceFunction() {} diff --git a/chrome/browser/extensions/api/usb/usb_apitest.cc b/chrome/browser/extensions/api/usb/usb_apitest.cc index 55ed901..20f37d9 100644 --- a/chrome/browser/extensions/api/usb/usb_apitest.cc +++ b/chrome/browser/extensions/api/usb/usb_apitest.cc @@ -95,60 +95,68 @@ class UsbApiTest : public ExtensionApiTest { } // namespace IN_PROC_BROWSER_TEST_F(UsbApiTest, DeviceHandling) { - EXPECT_CALL(*mock_device_, Close(_)) + EXPECT_CALL(*mock_device_.get(), Close(_)) .WillRepeatedly(InvokeUsbCallback()); - EXPECT_CALL(*mock_device_, ResetDevice(_)) - .WillOnce(InvokeUsbResultCallback<0>(true)) - .WillOnce(InvokeUsbResultCallback<0>(false)); - EXPECT_CALL(*mock_device_, + EXPECT_CALL(*mock_device_.get(), ResetDevice(_)) + .WillOnce(InvokeUsbResultCallback<0>(true)) + .WillOnce(InvokeUsbResultCallback<0>(false)); + EXPECT_CALL(*mock_device_.get(), InterruptTransfer(USB_DIRECTION_OUTBOUND, 2, _, 1, _, _)) - .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_COMPLETED)); + .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_COMPLETED)); ASSERT_TRUE(RunExtensionTest("usb/device_handling")); } IN_PROC_BROWSER_TEST_F(UsbApiTest, ListInterfaces) { - EXPECT_CALL(*mock_device_, ListInterfaces(_, _)) - .WillOnce(InvokeUsbResultCallback<1>(false)); - EXPECT_CALL(*mock_device_, Close(_)).Times(AnyNumber()); + EXPECT_CALL(*mock_device_.get(), ListInterfaces(_, _)) + .WillOnce(InvokeUsbResultCallback<1>(false)); + EXPECT_CALL(*mock_device_.get(), Close(_)).Times(AnyNumber()); ASSERT_TRUE(RunExtensionTest("usb/list_interfaces")); } IN_PROC_BROWSER_TEST_F(UsbApiTest, TransferEvent) { - EXPECT_CALL(*mock_device_, - ControlTransfer(USB_DIRECTION_OUTBOUND, UsbDevice::STANDARD, - UsbDevice::DEVICE, 1, 2, 3, _, 1, _, _)) + EXPECT_CALL(*mock_device_.get(), + ControlTransfer(USB_DIRECTION_OUTBOUND, + UsbDevice::STANDARD, + UsbDevice::DEVICE, + 1, + 2, + 3, + _, + 1, + _, + _)) .WillOnce(InvokeUsbTransferCallback<9>(USB_TRANSFER_COMPLETED)); - EXPECT_CALL(*mock_device_, - BulkTransfer(USB_DIRECTION_OUTBOUND, 1, _, 1, _, _)) + EXPECT_CALL(*mock_device_.get(), + BulkTransfer(USB_DIRECTION_OUTBOUND, 1, _, 1, _, _)) .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_COMPLETED)); - EXPECT_CALL(*mock_device_, - InterruptTransfer(USB_DIRECTION_OUTBOUND, 2, _, 1, _, _)) + EXPECT_CALL(*mock_device_.get(), + InterruptTransfer(USB_DIRECTION_OUTBOUND, 2, _, 1, _, _)) .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_COMPLETED)); - EXPECT_CALL(*mock_device_, - IsochronousTransfer(USB_DIRECTION_OUTBOUND, 3, _, 1, 1, 1, _, _)) + EXPECT_CALL(*mock_device_.get(), + IsochronousTransfer(USB_DIRECTION_OUTBOUND, 3, _, 1, 1, 1, _, _)) .WillOnce(InvokeUsbTransferCallback<7>(USB_TRANSFER_COMPLETED)); - EXPECT_CALL(*mock_device_, Close(_)).Times(AnyNumber()); + EXPECT_CALL(*mock_device_.get(), Close(_)).Times(AnyNumber()); ASSERT_TRUE(RunExtensionTest("usb/transfer_event")); } IN_PROC_BROWSER_TEST_F(UsbApiTest, ZeroLengthTransfer) { - EXPECT_CALL(*mock_device_, BulkTransfer(_, _, _, 0, _, _)) + EXPECT_CALL(*mock_device_.get(), BulkTransfer(_, _, _, 0, _, _)) .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_COMPLETED)); - EXPECT_CALL(*mock_device_, Close(_)).Times(AnyNumber()); + EXPECT_CALL(*mock_device_.get(), Close(_)).Times(AnyNumber()); ASSERT_TRUE(RunExtensionTest("usb/zero_length_transfer")); } IN_PROC_BROWSER_TEST_F(UsbApiTest, TransferFailure) { - EXPECT_CALL(*mock_device_, BulkTransfer(_, _, _, _, _, _)) + EXPECT_CALL(*mock_device_.get(), BulkTransfer(_, _, _, _, _, _)) .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_COMPLETED)) .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_ERROR)) .WillOnce(InvokeUsbTransferCallback<5>(USB_TRANSFER_TIMEOUT)); - EXPECT_CALL(*mock_device_, Close(_)).Times(AnyNumber()); + EXPECT_CALL(*mock_device_.get(), Close(_)).Times(AnyNumber()); ASSERT_TRUE(RunExtensionTest("usb/transfer_failure")); } IN_PROC_BROWSER_TEST_F(UsbApiTest, InvalidLengthTransfer) { - EXPECT_CALL(*mock_device_, Close(_)).Times(AnyNumber()); + EXPECT_CALL(*mock_device_.get(), Close(_)).Times(AnyNumber()); ASSERT_TRUE(RunExtensionTest("usb/invalid_length_transfer")); } diff --git a/chrome/browser/extensions/api/web_request/web_request_api.cc b/chrome/browser/extensions/api/web_request/web_request_api.cc index 724ac26..ef1b2fb 100644 --- a/chrome/browser/extensions/api/web_request/web_request_api.cc +++ b/chrome/browser/extensions/api/web_request/web_request_api.cc @@ -1925,9 +1925,12 @@ void ExtensionWebRequestEventRouter::OnRulesRegistryReady( base::Time::Now() - blocked_request.blocking_time; UMA_HISTOGRAM_TIMES("Extensions.NetworkDelayRegistryLoad", block_time); - ProcessDeclarativeRules(profile, blocked_request.extension_info_map, - event_name, blocked_request.request, request_stage, - blocked_request.original_response_headers); + ProcessDeclarativeRules(profile, + blocked_request.extension_info_map, + event_name, + blocked_request.request, + request_stage, + blocked_request.original_response_headers.get()); // Reset to NULL so that nobody relies on this being set. blocked_request.extension_info_map = NULL; DecrementBlockCount(profile, std::string(), event_name, request_id, NULL); diff --git a/chrome/browser/extensions/api/web_request/web_request_api_helpers.cc b/chrome/browser/extensions/api/web_request/web_request_api_helpers.cc index 3c7b446..902112e 100644 --- a/chrome/browser/extensions/api/web_request/web_request_api_helpers.cc +++ b/chrome/browser/extensions/api/web_request/web_request_api_helpers.cc @@ -1263,9 +1263,9 @@ void NotifyWebRequestAPIUsed( if (!g_browser_process->profile_manager()->IsValidProfile(profile)) return; - if (profile->GetExtensionService()->HasUsedWebRequest(extension)) + if (profile->GetExtensionService()->HasUsedWebRequest(extension.get())) return; - profile->GetExtensionService()->SetHasUsedWebRequest(extension, true); + profile->GetExtensionService()->SetHasUsedWebRequest(extension.get(), true); content::BrowserContext* browser_context = profile; for (content::RenderProcessHost::iterator it = diff --git a/chrome/browser/extensions/api/web_request/web_request_api_unittest.cc b/chrome/browser/extensions/api/web_request/web_request_api_unittest.cc index 4746018..f712938 100644 --- a/chrome/browser/extensions/api/web_request/web_request_api_unittest.cc +++ b/chrome/browser/extensions/api/web_request/web_request_api_unittest.cc @@ -1273,9 +1273,8 @@ TEST(ExtensionWebRequestHelpersTest, TestCalculateOnHeadersReceivedDelta) { // Key3 is deleted new_headers.push_back(ResponseHeader("Key4", "Value4")); // Added - scoped_ptr<EventResponseDelta> delta( - CalculateOnHeadersReceivedDelta("extid", base::Time::Now(), cancel, - base_headers, &new_headers)); + scoped_ptr<EventResponseDelta> delta(CalculateOnHeadersReceivedDelta( + "extid", base::Time::Now(), cancel, base_headers.get(), &new_headers)); ASSERT_TRUE(delta.get()); EXPECT_TRUE(delta->cancel); EXPECT_EQ(2u, delta->added_response_headers.size()); diff --git a/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc b/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc index 01777f9..5820af4 100644 --- a/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc +++ b/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc @@ -52,7 +52,7 @@ void ExtensionWebRequestHelpersTestWithThreadsTest::SetUp() { Extension::NO_FLAGS, "ext_id_1", &error); - ASSERT_TRUE(permissionless_extension_) << error; + ASSERT_TRUE(permissionless_extension_.get()) << error; com_extension_ = LoadManifestUnchecked("permissions", "web_request_com_host_permissions.json", @@ -60,7 +60,7 @@ void ExtensionWebRequestHelpersTestWithThreadsTest::SetUp() { Extension::NO_FLAGS, "ext_id_2", &error); - ASSERT_TRUE(com_extension_) << error; + ASSERT_TRUE(com_extension_.get()) << error; extension_info_map_ = new ExtensionInfoMap; extension_info_map_->AddExtension(permissionless_extension_.get(), base::Time::Now(), @@ -149,25 +149,25 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest, GURL("http://example.com"), NULL, &context, NULL); EXPECT_TRUE(WebRequestPermissions::CanExtensionAccessURL( - extension_info_map_, + extension_info_map_.get(), permissionless_extension_->id(), request.url(), false /*crosses_incognito*/, WebRequestPermissions::DO_NOT_CHECK_HOST)); EXPECT_FALSE(WebRequestPermissions::CanExtensionAccessURL( - extension_info_map_, + extension_info_map_.get(), permissionless_extension_->id(), request.url(), false /*crosses_incognito*/, WebRequestPermissions::REQUIRE_HOST_PERMISSION)); EXPECT_TRUE(WebRequestPermissions::CanExtensionAccessURL( - extension_info_map_, + extension_info_map_.get(), com_extension_->id(), request.url(), false /*crosses_incognito*/, WebRequestPermissions::REQUIRE_HOST_PERMISSION)); EXPECT_FALSE(WebRequestPermissions::CanExtensionAccessURL( - extension_info_map_, + extension_info_map_.get(), com_extension_->id(), request.url(), false /*crosses_incognito*/, diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc index c00e796..dc299f2 100644 --- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc +++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc @@ -416,8 +416,9 @@ void BeginInstallWithManifestFunction::OnWebstoreParseSuccess( std::string(), &error); - if (!dummy_extension_) { - OnWebstoreParseFailure(id_, WebstoreInstallHelper::Delegate::MANIFEST_ERROR, + if (!dummy_extension_.get()) { + OnWebstoreParseFailure(id_, + WebstoreInstallHelper::Delegate::MANIFEST_ERROR, kInvalidManifestError); return; } @@ -490,7 +491,7 @@ void BeginInstallWithManifestFunction::SigninCompletedOrNotNeeded() { install_prompt_.reset(new ExtensionInstallPrompt(web_contents)); install_prompt_->ConfirmWebstoreInstall( this, - dummy_extension_, + dummy_extension_.get(), &icon_, ExtensionInstallPrompt::GetDefaultShowDialogCallback()); // Control flow finishes up in InstallUIProceed or InstallUIAbort. @@ -515,7 +516,7 @@ void BeginInstallWithManifestFunction::InstallUIProceed() { // for all extension installs, so we only need to record the web store // specific histogram here. ExtensionService::RecordPermissionMessagesHistogram( - dummy_extension_, "Extensions.Permissions_WebStoreInstall"); + dummy_extension_.get(), "Extensions.Permissions_WebStoreInstall"); // Matches the AddRef in RunImpl(). Release(); @@ -533,14 +534,14 @@ void BeginInstallWithManifestFunction::InstallUIAbort(bool user_initiated) { std::string histogram_name = user_initiated ? "Extensions.Permissions_WebStoreInstallCancel" : "Extensions.Permissions_WebStoreInstallAbort"; - ExtensionService::RecordPermissionMessagesHistogram( - dummy_extension_, histogram_name.c_str()); + ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), + histogram_name.c_str()); histogram_name = user_initiated ? "Extensions.Permissions_InstallCancel" : "Extensions.Permissions_InstallAbort"; - ExtensionService::RecordPermissionMessagesHistogram( - dummy_extension_, histogram_name.c_str()); + ExtensionService::RecordPermissionMessagesHistogram(dummy_extension_.get(), + histogram_name.c_str()); // Matches the AddRef in RunImpl(). Release(); |