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

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

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 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 "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 "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using browser_sync::UIModelWorker; 17 using browser_sync::UIModelWorker;
18 using csync::SyncerError; 18 using syncer::SyncerError;
19 using content::BrowserThread; 19 using content::BrowserThread;
20 20
21 // Various boilerplate, primarily for the StopWithPendingWork test. 21 // Various boilerplate, primarily for the StopWithPendingWork test.
22 22
23 class UIModelWorkerVisitor { 23 class UIModelWorkerVisitor {
24 public: 24 public:
25 UIModelWorkerVisitor(base::WaitableEvent* was_run, 25 UIModelWorkerVisitor(base::WaitableEvent* was_run,
26 bool quit_loop) 26 bool quit_loop)
27 : quit_loop_when_run_(quit_loop), 27 : quit_loop_when_run_(quit_loop),
28 was_run_(was_run) { } 28 was_run_(was_run) { }
29 virtual ~UIModelWorkerVisitor() { } 29 virtual ~UIModelWorkerVisitor() { }
30 30
31 virtual csync::SyncerError DoWork() { 31 virtual syncer::SyncerError DoWork() {
32 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 32 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
33 was_run_->Signal(); 33 was_run_->Signal();
34 if (quit_loop_when_run_) 34 if (quit_loop_when_run_)
35 MessageLoop::current()->Quit(); 35 MessageLoop::current()->Quit();
36 return csync::SYNCER_OK; 36 return syncer::SYNCER_OK;
37 } 37 }
38 38
39 private: 39 private:
40 bool quit_loop_when_run_; 40 bool quit_loop_when_run_;
41 base::WaitableEvent* was_run_; 41 base::WaitableEvent* was_run_;
42 DISALLOW_COPY_AND_ASSIGN(UIModelWorkerVisitor); 42 DISALLOW_COPY_AND_ASSIGN(UIModelWorkerVisitor);
43 }; 43 };
44 44
45 // A faux-syncer that only interacts with its model safe worker. 45 // A faux-syncer that only interacts with its model safe worker.
46 class Syncer { 46 class Syncer {
47 public: 47 public:
48 explicit Syncer(UIModelWorker* worker) : worker_(worker) {} 48 explicit Syncer(UIModelWorker* worker) : worker_(worker) {}
49 ~Syncer() {} 49 ~Syncer() {}
50 50
51 void SyncShare(UIModelWorkerVisitor* visitor) { 51 void SyncShare(UIModelWorkerVisitor* visitor) {
52 // We wait until the callback is executed. So it is safe to use Unretained. 52 // We wait until the callback is executed. So it is safe to use Unretained.
53 csync::WorkCallback c = base::Bind(&UIModelWorkerVisitor::DoWork, 53 syncer::WorkCallback c = base::Bind(&UIModelWorkerVisitor::DoWork,
54 base::Unretained(visitor)); 54 base::Unretained(visitor));
55 worker_->DoWorkAndWaitUntilDone(c); 55 worker_->DoWorkAndWaitUntilDone(c);
56 } 56 }
57 private: 57 private:
58 scoped_refptr<UIModelWorker> worker_; 58 scoped_refptr<UIModelWorker> worker_;
59 DISALLOW_COPY_AND_ASSIGN(Syncer); 59 DISALLOW_COPY_AND_ASSIGN(Syncer);
60 }; 60 };
61 61
62 // A callback run from the CoreThread to simulate terminating syncapi. 62 // A callback run from the CoreThread to simulate terminating syncapi.
63 void FakeSyncapiShutdownCallback(base::Thread* syncer_thread, 63 void FakeSyncapiShutdownCallback(base::Thread* syncer_thread,
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 // This is what gets the UI thread blocked until NotifyExitRequested, 204 // This is what gets the UI thread blocked until NotifyExitRequested,
205 // which is called when FakeSyncapiShutdownCallback runs and deletes the 205 // which is called when FakeSyncapiShutdownCallback runs and deletes the
206 // syncer. 206 // syncer.
207 bmw()->Stop(); 207 bmw()->Stop();
208 208
209 // Was the thread killed? 209 // Was the thread killed?
210 EXPECT_FALSE(syncer_thread()->IsRunning()); 210 EXPECT_FALSE(syncer_thread()->IsRunning());
211 core_thread()->Stop(); 211 core_thread()->Stop();
212 } 212 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/ui_model_worker.cc ('k') | chrome/browser/sync/invalidations/invalidator_storage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698