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

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

Issue 7891054: Add GROUP_FILE ModelSafeGroup (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Remove FileModelWorkers Created 9 years, 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/glue/browser_thread_model_worker.h"
6
7 #include "base/synchronization/waitable_event.h"
8 #include "content/browser/browser_thread.h"
9
10 using base::WaitableEvent;
11
12 namespace browser_sync {
13
14 BrowserThreadModelWorker::BrowserThreadModelWorker(
15 BrowserThread::ID thread, ModelSafeGroup group)
16 : thread_(thread), group_(group) {}
17
18 BrowserThreadModelWorker::~BrowserThreadModelWorker() {}
19
20 void BrowserThreadModelWorker::DoWorkAndWaitUntilDone(Callback0::Type* work) {
21 if (BrowserThread::CurrentlyOn(thread_)) {
22 DLOG(WARNING) << "Already on the appropriate thread.";
akalin 2011/09/14 19:16:32 log the thread ID, i.e. DLOG(WARNING) << "Already
not at google - send to devlin 2011/09/14 20:39:03 It would be nice if I could print out "FILE" inste
23 work->Run();
24 return;
25 }
26 WaitableEvent done(false, false);
27 if (!BrowserThread::PostTask(
28 thread_,
29 FROM_HERE,
30 NewRunnableMethod(
31 this,
32 &BrowserThreadModelWorker::CallDoWorkAndSignalTask,
33 work,
34 &done))) {
35 NOTREACHED() << "Failed to post task to the appropriate thread.";
akalin 2011/09/14 19:16:32 same here
not at google - send to devlin 2011/09/14 20:39:03 Done.
36 return;
37 }
38 done.Wait();
39 }
40
41 void BrowserThreadModelWorker::CallDoWorkAndSignalTask(
42 Callback0::Type* work, WaitableEvent* done) {
43 DCHECK(BrowserThread::CurrentlyOn(thread_));
44 work->Run();
45 done->Signal();
46 }
47
48 ModelSafeGroup BrowserThreadModelWorker::GetModelSafeGroup() {
49 return group_;
50 }
51
52 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698