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

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 1395103003: Don't use base::MessageLoop::{Quit,QuitClosure} in chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 // If packing succeeded, we make sure that the package names match our 1233 // If packing succeeded, we make sure that the package names match our
1234 // expectations. 1234 // expectations.
1235 void PackExtensionTestClient::OnPackSuccess( 1235 void PackExtensionTestClient::OnPackSuccess(
1236 const base::FilePath& crx_path, 1236 const base::FilePath& crx_path,
1237 const base::FilePath& private_key_path) { 1237 const base::FilePath& private_key_path) {
1238 // We got the notification and processed it; we don't expect any further tasks 1238 // We got the notification and processed it; we don't expect any further tasks
1239 // to be posted to the current thread, so we should stop blocking and continue 1239 // to be posted to the current thread, so we should stop blocking and continue
1240 // on with the rest of the test. 1240 // on with the rest of the test.
1241 // This call to |Quit()| matches the call to |Run()| in the 1241 // This call to |Quit()| matches the call to |Run()| in the
1242 // |PackPunctuatedExtension| test. 1242 // |PackPunctuatedExtension| test.
1243 base::MessageLoop::current()->Quit(); 1243 base::MessageLoop::current()->QuitWhenIdle();
1244 EXPECT_EQ(expected_crx_path_.value(), crx_path.value()); 1244 EXPECT_EQ(expected_crx_path_.value(), crx_path.value());
1245 EXPECT_EQ(expected_private_key_path_.value(), private_key_path.value()); 1245 EXPECT_EQ(expected_private_key_path_.value(), private_key_path.value());
1246 ASSERT_TRUE(base::PathExists(private_key_path)); 1246 ASSERT_TRUE(base::PathExists(private_key_path));
1247 } 1247 }
1248 1248
1249 // The tests are designed so that we never expect to see a packing error. 1249 // The tests are designed so that we never expect to see a packing error.
1250 void PackExtensionTestClient::OnPackFailure(const std::string& error_message, 1250 void PackExtensionTestClient::OnPackFailure(const std::string& error_message,
1251 ExtensionCreator::ErrorType type) { 1251 ExtensionCreator::ErrorType type) {
1252 if (type == ExtensionCreator::kCRXExists) 1252 if (type == ExtensionCreator::kCRXExists)
1253 FAIL() << "Packing should not fail."; 1253 FAIL() << "Packing should not fail.";
(...skipping 3454 matching lines...) Expand 10 before | Expand all | Expand 10 after
4708 } 4708 }
4709 4709
4710 class ExtensionCookieCallback { 4710 class ExtensionCookieCallback {
4711 public: 4711 public:
4712 ExtensionCookieCallback() 4712 ExtensionCookieCallback()
4713 : result_(false), 4713 : result_(false),
4714 weak_factory_(base::MessageLoop::current()) {} 4714 weak_factory_(base::MessageLoop::current()) {}
4715 4715
4716 void SetCookieCallback(bool result) { 4716 void SetCookieCallback(bool result) {
4717 base::ThreadTaskRunnerHandle::Get()->PostTask( 4717 base::ThreadTaskRunnerHandle::Get()->PostTask(
4718 FROM_HERE, 4718 FROM_HERE, base::Bind(&base::MessageLoop::QuitWhenIdle,
4719 base::Bind(&base::MessageLoop::Quit, weak_factory_.GetWeakPtr())); 4719 weak_factory_.GetWeakPtr()));
4720 result_ = result; 4720 result_ = result;
4721 } 4721 }
4722 4722
4723 void GetAllCookiesCallback(const net::CookieList& list) { 4723 void GetAllCookiesCallback(const net::CookieList& list) {
4724 base::ThreadTaskRunnerHandle::Get()->PostTask( 4724 base::ThreadTaskRunnerHandle::Get()->PostTask(
4725 FROM_HERE, 4725 FROM_HERE, base::Bind(&base::MessageLoop::QuitWhenIdle,
4726 base::Bind(&base::MessageLoop::Quit, weak_factory_.GetWeakPtr())); 4726 weak_factory_.GetWeakPtr()));
4727 list_ = list; 4727 list_ = list;
4728 } 4728 }
4729 net::CookieList list_; 4729 net::CookieList list_;
4730 bool result_; 4730 bool result_;
4731 base::WeakPtrFactory<base::MessageLoop> weak_factory_; 4731 base::WeakPtrFactory<base::MessageLoop> weak_factory_;
4732 }; 4732 };
4733 4733
4734 // Verifies extension state is removed upon uninstall. 4734 // Verifies extension state is removed upon uninstall.
4735 TEST_F(ExtensionServiceTest, ClearExtensionData) { 4735 TEST_F(ExtensionServiceTest, ClearExtensionData) {
4736 InitializeEmptyExtensionService(); 4736 InitializeEmptyExtensionService();
(...skipping 3438 matching lines...) Expand 10 before | Expand all | Expand 10 after
8175 8175
8176 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 8176 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
8177 content::Source<Profile>(profile()), 8177 content::Source<Profile>(profile()),
8178 content::NotificationService::NoDetails()); 8178 content::NotificationService::NoDetails());
8179 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); 8179 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
8180 EXPECT_EQ(0u, registry()->enabled_extensions().size()); 8180 EXPECT_EQ(0u, registry()->enabled_extensions().size());
8181 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 8181 EXPECT_EQ(0u, registry()->disabled_extensions().size());
8182 EXPECT_EQ(0u, registry()->terminated_extensions().size()); 8182 EXPECT_EQ(0u, registry()->terminated_extensions().size());
8183 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); 8183 EXPECT_EQ(0u, registry()->blacklisted_extensions().size());
8184 } 8184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698