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

Side by Side Diff: ios/chrome/browser/browser_state/test_chrome_browser_state.mm

Issue 2314243002: Remove calls to deprecated MessageLoop methods in ios. (Closed)
Patch Set: CR Created 4 years, 3 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
« no previous file with comments | « no previous file | ios/web/webui/url_data_manager_ios_backend.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "ios/chrome/browser/browser_state/test_chrome_browser_state.h" 5 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 return true; 353 return true;
354 } 354 }
355 355
356 void TestChromeBrowserState::DestroyHistoryService() { 356 void TestChromeBrowserState::DestroyHistoryService() {
357 history::HistoryService* history_service = 357 history::HistoryService* history_service =
358 ios::HistoryServiceFactory::GetInstance()->GetForBrowserStateIfExists( 358 ios::HistoryServiceFactory::GetInstance()->GetForBrowserStateIfExists(
359 this, ServiceAccessType::EXPLICIT_ACCESS); 359 this, ServiceAccessType::EXPLICIT_ACCESS);
360 if (!history_service) 360 if (!history_service)
361 return; 361 return;
362 362
363 base::RunLoop run_loop;
364
363 history_service->ClearCachedDataForContextID(0); 365 history_service->ClearCachedDataForContextID(0);
364 history_service->SetOnBackendDestroyTask( 366 history_service->SetOnBackendDestroyTask(run_loop.QuitWhenIdleClosure());
365 base::MessageLoop::QuitWhenIdleClosure());
366 history_service->Shutdown(); 367 history_service->Shutdown();
367 history_service = nullptr; 368 history_service = nullptr;
368 369
369 // Resetting the testing factory force the destruction of the current 370 // Resetting the testing factory force the destruction of the current
370 // HistoryService instance associated with the TestChromeBrowserState. 371 // HistoryService instance associated with the TestChromeBrowserState.
371 ios::HistoryServiceFactory::GetInstance()->SetTestingFactory(this, nullptr); 372 ios::HistoryServiceFactory::GetInstance()->SetTestingFactory(this, nullptr);
372 373
373 // Wait for the backend class to terminate before deleting the files and 374 // Wait for the backend class to terminate before deleting the files and
374 // moving to the next test. Note: if this never terminates, somebody is 375 // moving to the next test. Note: if this never terminates, somebody is
375 // probably leaking a reference to the history backend, so it never calls 376 // probably leaking a reference to the history backend, so it never calls
376 // our destroy task. 377 // our destroy task.
377 base::MessageLoop::current()->Run(); 378 run_loop.Run();
378
379 // Make sure we don't have any event pending that could disrupt the next
380 // test.
381 base::ThreadTaskRunnerHandle::Get()->PostTask(
382 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
383 base::MessageLoop::current()->Run();
384 } 379 }
385 380
386 syncable_prefs::TestingPrefServiceSyncable* 381 syncable_prefs::TestingPrefServiceSyncable*
387 TestChromeBrowserState::GetTestingPrefService() { 382 TestChromeBrowserState::GetTestingPrefService() {
388 DCHECK(prefs_); 383 DCHECK(prefs_);
389 DCHECK(testing_prefs_); 384 DCHECK(testing_prefs_);
390 return testing_prefs_; 385 return testing_prefs_;
391 } 386 }
392 387
393 TestChromeBrowserState::Builder::Builder() : build_called_(false) {} 388 TestChromeBrowserState::Builder::Builder() : build_called_(false) {}
(...skipping 25 matching lines...) Expand all
419 pref_service_ = std::move(prefs); 414 pref_service_ = std::move(prefs);
420 } 415 }
421 416
422 std::unique_ptr<TestChromeBrowserState> 417 std::unique_ptr<TestChromeBrowserState>
423 TestChromeBrowserState::Builder::Build() { 418 TestChromeBrowserState::Builder::Build() {
424 DCHECK(!build_called_); 419 DCHECK(!build_called_);
425 return base::WrapUnique(new TestChromeBrowserState( 420 return base::WrapUnique(new TestChromeBrowserState(
426 state_path_, std::move(pref_service_), testing_factories_, 421 state_path_, std::move(pref_service_), testing_factories_,
427 refcounted_testing_factories_)); 422 refcounted_testing_factories_));
428 } 423 }
OLDNEW
« no previous file with comments | « no previous file | ios/web/webui/url_data_manager_ios_backend.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698