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

Side by Side Diff: chrome/browser/sync/glue/browser_thread_model_worker_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) 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 TestTimeouts::action_timeout(), 53 TestTimeouts::action_timeout(),
54 this, 54 this,
55 &SyncBrowserThreadModelWorkerTest::Timeout); 55 &SyncBrowserThreadModelWorkerTest::Timeout);
56 worker()->DoWorkAndWaitUntilDone(c); 56 worker()->DoWorkAndWaitUntilDone(c);
57 } 57 }
58 58
59 // This is the work that will be scheduled to be done on the DB thread. 59 // This is the work that will be scheduled to be done on the DB thread.
60 syncer::SyncerError DoWork() { 60 syncer::SyncerError DoWork() {
61 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); 61 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
62 timer_.Stop(); // Stop the failure timer so the test succeeds. 62 timer_.Stop(); // Stop the failure timer so the test succeeds.
63 BrowserThread::PostTask( 63 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
64 BrowserThread::IO, FROM_HERE, base::MessageLoop::QuitClosure()); 64 base::MessageLoop::QuitWhenIdleClosure());
65 did_do_work_ = true; 65 did_do_work_ = true;
66 return syncer::SYNCER_OK; 66 return syncer::SYNCER_OK;
67 } 67 }
68 68
69 // This will be called by the OneShotTimer and make the test fail unless 69 // This will be called by the OneShotTimer and make the test fail unless
70 // DoWork is called first. 70 // DoWork is called first.
71 void Timeout() { 71 void Timeout() {
72 ADD_FAILURE() << "Timed out waiting for work to be done on the DB thread."; 72 ADD_FAILURE() << "Timed out waiting for work to be done on the DB thread.";
73 BrowserThread::PostTask( 73 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
74 BrowserThread::IO, FROM_HERE, base::MessageLoop::QuitClosure()); 74 base::MessageLoop::QuitWhenIdleClosure());
75 } 75 }
76 76
77 protected: 77 protected:
78 void SetUp() override { 78 void SetUp() override {
79 worker_ = new BrowserThreadModelWorker( 79 worker_ = new BrowserThreadModelWorker(
80 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), 80 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
81 syncer::GROUP_DB, NULL); 81 syncer::GROUP_DB, NULL);
82 } 82 }
83 83
84 virtual void Teardown() { 84 virtual void Teardown() {
(...skipping 14 matching lines...) Expand all
99 base::ThreadTaskRunnerHandle::Get()->PostTask( 99 base::ThreadTaskRunnerHandle::Get()->PostTask(
100 FROM_HERE, base::Bind(&SyncBrowserThreadModelWorkerTest::ScheduleWork, 100 FROM_HERE, base::Bind(&SyncBrowserThreadModelWorkerTest::ScheduleWork,
101 factory()->GetWeakPtr())); 101 factory()->GetWeakPtr()));
102 base::MessageLoop::current()->Run(); 102 base::MessageLoop::current()->Run();
103 EXPECT_TRUE(did_do_work()); 103 EXPECT_TRUE(did_do_work());
104 } 104 }
105 105
106 } // namespace 106 } // namespace
107 107
108 } // namespace browser_sync 108 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698