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

Side by Side Diff: chrome/browser/sync/engine/model_safe_worker.h

Issue 194065: Initial commit of sync engine code to browser/sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fixes to gtest include path, reverted syncapi. Created 11 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2006-2009 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 #ifndef CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_
6 #define CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_
7
8 #include "chrome/browser/sync/util/closure.h"
9 #include "chrome/browser/sync/util/sync_types.h"
10
11 namespace browser_sync {
12
13 // The Syncer uses a ModelSafeWorker for all tasks that could potentially
14 // modify syncable entries (e.g under a WriteTransaction). The ModelSafeWorker
15 // only knows how to do one thing, and that is take some work (in a fully
16 // pre-bound callback) and have it performed (as in Run()) from a thread which
17 // is guaranteed to be "model-safe", where "safe" refers to not allowing us to
18 // cause an embedding application model to fall out of sync with the
19 // syncable::Directory due to a race.
20 class ModelSafeWorker {
21 public:
22 ModelSafeWorker() { }
23 virtual ~ModelSafeWorker() { }
24
25 // Any time the Syncer performs model modifications (e.g employing a
26 // WriteTransaction), it should be done by this method to ensure it is done
27 // from a model-safe thread.
28 //
29 // TODO(timsteele): For now this is non-reentrant, meaning the work being
30 // done should be at a high enough level in the stack that
31 // DoWorkAndWaitUntilDone won't be called again by invoking Run() on |work|.
32 // This is not strictly necessary; it may be best to call
33 // DoWorkAndWaitUntilDone at lower levels, such as within ApplyUpdates, but
34 // this is sufficient to simplify and test out our dispatching approach.
35 virtual void DoWorkAndWaitUntilDone(Closure* work) {
36 work->Run(); // By default, do the work on the current thread.
37 }
38
39 private:
40 DISALLOW_COPY_AND_ASSIGN(ModelSafeWorker);
41 };
42
43 } // namespace browser_sync
44
45 #endif // CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698