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

Side by Side Diff: chrome/browser/sync_file_system/sync_file_system_test_util.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix InstantNTP test. Created 7 years, 5 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 | Annotate | Revision Log
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/browser/sync_file_system/sync_file_system_test_util.h" 5 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
12 #include "content/public/test/test_browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/test/test_browser_thread_bundle.h" 13 #include "content/public/test/test_utils.h"
14 #include "webkit/browser/fileapi/syncable/sync_status_code.h" 14 #include "webkit/browser/fileapi/syncable/sync_status_code.h"
15 15
16 using content::BrowserThread; 16 using content::BrowserThread;
17 using content::TestBrowserThread;
18 17
19 namespace sync_file_system { 18 namespace sync_file_system {
20 19
21 template <typename R> 20 template <typename R>
22 void AssignAndQuit(base::RunLoop* run_loop, R* result_out, R result) { 21 void AssignAndQuit(base::RunLoop* run_loop, R* result_out, R result) {
23 DCHECK(result_out); 22 DCHECK(result_out);
24 DCHECK(run_loop); 23 DCHECK(run_loop);
25 *result_out = result; 24 *result_out = result;
26 run_loop->Quit(); 25 run_loop->Quit();
27 } 26 }
28 27
29 template <typename R> base::Callback<void(R)> 28 template <typename R> base::Callback<void(R)>
30 AssignAndQuitCallback(base::RunLoop* run_loop, R* result) { 29 AssignAndQuitCallback(base::RunLoop* run_loop, R* result) {
31 return base::Bind(&AssignAndQuit<R>, run_loop, base::Unretained(result)); 30 return base::Bind(&AssignAndQuit<R>, run_loop, base::Unretained(result));
32 } 31 }
33 32
34 // Instantiate versions we know callers will need. 33 // Instantiate versions we know callers will need.
35 template base::Callback<void(SyncStatusCode)> 34 template base::Callback<void(SyncStatusCode)>
36 AssignAndQuitCallback(base::RunLoop*, SyncStatusCode*); 35 AssignAndQuitCallback(base::RunLoop*, SyncStatusCode*);
37 36
38 MultiThreadTestHelper::MultiThreadTestHelper()
39 : thread_bundle_(new content::TestBrowserThreadBundle(
40 content::TestBrowserThreadBundle::REAL_FILE_THREAD |
41 content::TestBrowserThreadBundle::REAL_IO_THREAD)) {
42 }
43
44 MultiThreadTestHelper::~MultiThreadTestHelper() {}
45
46 void MultiThreadTestHelper::SetUp() {
47 ui_task_runner_ =
48 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
49 file_task_runner_ =
50 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE);
51 io_task_runner_ =
52 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
53 }
54
55 void MultiThreadTestHelper::TearDown() {
56 // Make sure we give some more time to finish tasks on the FILE thread
57 // before stopping IO/FILE threads.
58 base::RunLoop run_loop;
59 file_task_runner_->PostTaskAndReply(
60 FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure());
61 run_loop.Run();
62 }
63
64 } // namespace sync_file_system 37 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698