OLD | NEW |
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/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 UIModelWorkerVisitor(base::WaitableEvent* was_run, | 24 UIModelWorkerVisitor(base::WaitableEvent* was_run, |
25 bool quit_loop) | 25 bool quit_loop) |
26 : quit_loop_when_run_(quit_loop), | 26 : quit_loop_when_run_(quit_loop), |
27 was_run_(was_run) { } | 27 was_run_(was_run) { } |
28 virtual ~UIModelWorkerVisitor() { } | 28 virtual ~UIModelWorkerVisitor() { } |
29 | 29 |
30 virtual syncer::SyncerError DoWork() { | 30 virtual syncer::SyncerError DoWork() { |
31 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 31 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
32 was_run_->Signal(); | 32 was_run_->Signal(); |
33 if (quit_loop_when_run_) | 33 if (quit_loop_when_run_) |
34 base::MessageLoop::current()->Quit(); | 34 base::MessageLoop::current()->QuitWhenIdle(); |
35 return syncer::SYNCER_OK; | 35 return syncer::SYNCER_OK; |
36 } | 36 } |
37 | 37 |
38 private: | 38 private: |
39 bool quit_loop_when_run_; | 39 bool quit_loop_when_run_; |
40 base::WaitableEvent* was_run_; | 40 base::WaitableEvent* was_run_; |
41 DISALLOW_COPY_AND_ASSIGN(UIModelWorkerVisitor); | 41 DISALLOW_COPY_AND_ASSIGN(UIModelWorkerVisitor); |
42 }; | 42 }; |
43 | 43 |
44 // A faux-syncer that only interacts with its model safe worker. | 44 // A faux-syncer that only interacts with its model safe worker. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 syncer_thread()->task_runner()->PostTask( | 94 syncer_thread()->task_runner()->PostTask( |
95 FROM_HERE, | 95 FROM_HERE, |
96 base::Bind(&Syncer::SyncShare, base::Unretained(syncer()), v.get())); | 96 base::Bind(&Syncer::SyncShare, base::Unretained(syncer()), v.get())); |
97 | 97 |
98 // We are on the UI thread, so run our loop to process the | 98 // We are on the UI thread, so run our loop to process the |
99 // (hopefully) scheduled task from a SyncShare invocation. | 99 // (hopefully) scheduled task from a SyncShare invocation. |
100 base::MessageLoop::current()->Run(); | 100 base::MessageLoop::current()->Run(); |
101 syncer_thread()->Stop(); | 101 syncer_thread()->Stop(); |
102 } | 102 } |
OLD | NEW |