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

Side by Side Diff: chrome/test/base/testing_profile.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/test/base/testing_profile.h" 5 #include "chrome/test/base/testing_profile.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 class QuittingHistoryDBTask : public history::HistoryDBTask { 135 class QuittingHistoryDBTask : public history::HistoryDBTask {
136 public: 136 public:
137 QuittingHistoryDBTask() {} 137 QuittingHistoryDBTask() {}
138 138
139 bool RunOnDBThread(history::HistoryBackend* backend, 139 bool RunOnDBThread(history::HistoryBackend* backend,
140 history::HistoryDatabase* db) override { 140 history::HistoryDatabase* db) override {
141 return true; 141 return true;
142 } 142 }
143 143
144 void DoneRunOnMainThread() override { base::MessageLoop::current()->Quit(); } 144 void DoneRunOnMainThread() override {
145 base::MessageLoop::current()->QuitWhenIdle();
146 }
145 147
146 private: 148 private:
147 ~QuittingHistoryDBTask() override {} 149 ~QuittingHistoryDBTask() override {}
148 150
149 DISALLOW_COPY_AND_ASSIGN(QuittingHistoryDBTask); 151 DISALLOW_COPY_AND_ASSIGN(QuittingHistoryDBTask);
150 }; 152 };
151 153
152 class TestExtensionURLRequestContext : public net::URLRequestContext { 154 class TestExtensionURLRequestContext : public net::URLRequestContext {
153 public: 155 public:
154 TestExtensionURLRequestContext() { 156 TestExtensionURLRequestContext() {
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 return true; 555 return true;
554 } 556 }
555 557
556 void TestingProfile::DestroyHistoryService() { 558 void TestingProfile::DestroyHistoryService() {
557 history::HistoryService* history_service = 559 history::HistoryService* history_service =
558 HistoryServiceFactory::GetForProfileWithoutCreating(this); 560 HistoryServiceFactory::GetForProfileWithoutCreating(this);
559 if (!history_service) 561 if (!history_service)
560 return; 562 return;
561 563
562 history_service->ClearCachedDataForContextID(0); 564 history_service->ClearCachedDataForContextID(0);
563 history_service->SetOnBackendDestroyTask(base::MessageLoop::QuitClosure()); 565 history_service->SetOnBackendDestroyTask(
566 base::MessageLoop::QuitWhenIdleClosure());
564 history_service->Cleanup(); 567 history_service->Cleanup();
565 HistoryServiceFactory::ShutdownForProfile(this); 568 HistoryServiceFactory::ShutdownForProfile(this);
566 569
567 // Wait for the backend class to terminate before deleting the files and 570 // Wait for the backend class to terminate before deleting the files and
568 // moving to the next test. Note: if this never terminates, somebody is 571 // moving to the next test. Note: if this never terminates, somebody is
569 // probably leaking a reference to the history backend, so it never calls 572 // probably leaking a reference to the history backend, so it never calls
570 // our destroy task. 573 // our destroy task.
571 base::MessageLoop::current()->Run(); 574 base::MessageLoop::current()->Run();
572 575
573 // Make sure we don't have any event pending that could disrupt the next 576 // Make sure we don't have any event pending that could disrupt the next
574 // test. 577 // test.
575 base::ThreadTaskRunnerHandle::Get()->PostTask( 578 base::ThreadTaskRunnerHandle::Get()->PostTask(
576 FROM_HERE, base::MessageLoop::QuitClosure()); 579 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
577 base::MessageLoop::current()->Run(); 580 base::MessageLoop::current()->Run();
578 } 581 }
579 582
580 void TestingProfile::CreateBookmarkModel(bool delete_file) { 583 void TestingProfile::CreateBookmarkModel(bool delete_file) {
581 if (delete_file) { 584 if (delete_file) {
582 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); 585 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName);
583 base::DeleteFile(path, false); 586 base::DeleteFile(path, false);
584 } 587 }
585 ManagedBookmarkServiceFactory::GetInstance()->SetTestingFactory( 588 ManagedBookmarkServiceFactory::GetInstance()->SetTestingFactory(
586 this, ManagedBookmarkServiceFactory::GetDefaultFactory()); 589 this, ManagedBookmarkServiceFactory::GetDefaultFactory());
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 #if defined(ENABLE_EXTENSIONS) 1051 #if defined(ENABLE_EXTENSIONS)
1049 extension_policy_, 1052 extension_policy_,
1050 #endif 1053 #endif
1051 pref_service_.Pass(), 1054 pref_service_.Pass(),
1052 original_profile, 1055 original_profile,
1053 guest_session_, 1056 guest_session_,
1054 supervised_user_id_, 1057 supervised_user_id_,
1055 policy_service_.Pass(), 1058 policy_service_.Pass(),
1056 testing_factories_); 1059 testing_factories_);
1057 } 1060 }
OLDNEW
« no previous file with comments | « chrome/test/base/interactive_test_utils_views.cc ('k') | chrome/test/chromedriver/net/websocket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698