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

Side by Side Diff: chrome/browser/sync/glue/ui_model_worker_unittest.cc

Issue 9036003: Avoid useless SYNC_CYCLE_CONTINUATION sync cycle (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "chrome/browser/sync/glue/ui_model_worker.h" 13 #include "chrome/browser/sync/glue/ui_model_worker.h"
14 #include "chrome/browser/sync/util/unrecoverable_error_info.h"
15 #include "content/test/test_browser_thread.h" 14 #include "content/test/test_browser_thread.h"
16 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
17 16
18 using browser_sync::UIModelWorker; 17 using browser_sync::UIModelWorker;
19 using browser_sync::UnrecoverableErrorInfo; 18 using browser_sync::SyncerError;
20 using content::BrowserThread; 19 using content::BrowserThread;
21 20
22 // Various boilerplate, primarily for the StopWithPendingWork test. 21 // Various boilerplate, primarily for the StopWithPendingWork test.
23 22
24 class UIModelWorkerVisitor { 23 class UIModelWorkerVisitor {
25 public: 24 public:
26 UIModelWorkerVisitor(base::WaitableEvent* was_run, 25 UIModelWorkerVisitor(base::WaitableEvent* was_run,
27 bool quit_loop) 26 bool quit_loop)
28 : quit_loop_when_run_(quit_loop), 27 : quit_loop_when_run_(quit_loop),
29 was_run_(was_run) { } 28 was_run_(was_run) { }
30 virtual ~UIModelWorkerVisitor() { } 29 virtual ~UIModelWorkerVisitor() { }
31 30
32 virtual UnrecoverableErrorInfo DoWork() { 31 virtual SyncerError DoWork() {
33 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 32 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
34 was_run_->Signal(); 33 was_run_->Signal();
35 if (quit_loop_when_run_) 34 if (quit_loop_when_run_)
36 MessageLoop::current()->Quit(); 35 MessageLoop::current()->Quit();
37 return UnrecoverableErrorInfo(); 36 return browser_sync::NO_ERROR;
38 } 37 }
39 38
40 private: 39 private:
41 bool quit_loop_when_run_; 40 bool quit_loop_when_run_;
42 base::WaitableEvent* was_run_; 41 base::WaitableEvent* was_run_;
43 DISALLOW_COPY_AND_ASSIGN(UIModelWorkerVisitor); 42 DISALLOW_COPY_AND_ASSIGN(UIModelWorkerVisitor);
44 }; 43 };
45 44
46 // A faux-syncer that only interacts with its model safe worker. 45 // A faux-syncer that only interacts with its model safe worker.
47 class Syncer { 46 class Syncer {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 202
204 // This is what gets the UI thread blocked until NotifyExitRequested, 203 // This is what gets the UI thread blocked until NotifyExitRequested,
205 // which is called when FakeSyncapiShutdownCallback runs and deletes the 204 // which is called when FakeSyncapiShutdownCallback runs and deletes the
206 // syncer. 205 // syncer.
207 bmw()->Stop(); 206 bmw()->Stop();
208 207
209 // Was the thread killed? 208 // Was the thread killed?
210 EXPECT_FALSE(syncer_thread()->IsRunning()); 209 EXPECT_FALSE(syncer_thread()->IsRunning());
211 core_thread()->Stop(); 210 core_thread()->Stop();
212 } 211 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/ui_model_worker.cc ('k') | chrome/browser/sync/sessions/session_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698