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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/engine/model_safe_worker.h
===================================================================
--- chrome/browser/sync/engine/model_safe_worker.h (revision 0)
+++ chrome/browser/sync/engine/model_safe_worker.h (revision 0)
@@ -0,0 +1,45 @@
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_
+#define CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_
+
+#include "chrome/browser/sync/util/closure.h"
+#include "chrome/browser/sync/util/sync_types.h"
+
+namespace browser_sync {
+
+// The Syncer uses a ModelSafeWorker for all tasks that could potentially
+// modify syncable entries (e.g under a WriteTransaction). The ModelSafeWorker
+// only knows how to do one thing, and that is take some work (in a fully
+// pre-bound callback) and have it performed (as in Run()) from a thread which
+// is guaranteed to be "model-safe", where "safe" refers to not allowing us to
+// cause an embedding application model to fall out of sync with the
+// syncable::Directory due to a race.
+class ModelSafeWorker {
+ public:
+ ModelSafeWorker() { }
+ virtual ~ModelSafeWorker() { }
+
+ // Any time the Syncer performs model modifications (e.g employing a
+ // WriteTransaction), it should be done by this method to ensure it is done
+ // from a model-safe thread.
+ //
+ // TODO(timsteele): For now this is non-reentrant, meaning the work being
+ // done should be at a high enough level in the stack that
+ // DoWorkAndWaitUntilDone won't be called again by invoking Run() on |work|.
+ // This is not strictly necessary; it may be best to call
+ // DoWorkAndWaitUntilDone at lower levels, such as within ApplyUpdates, but
+ // this is sufficient to simplify and test out our dispatching approach.
+ virtual void DoWorkAndWaitUntilDone(Closure* work) {
+ work->Run(); // By default, do the work on the current thread.
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ModelSafeWorker);
+};
+
+} // namespace browser_sync
+
+#endif // CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_
Property changes on: chrome\browser\sync\engine\model_safe_worker.h
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698