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

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

Issue 1987009: Add routing info and unrecoverable error info to about:sync (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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) 2006-2009 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_
6 #define CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ 6 #define CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
12 #include "chrome/browser/sync/syncable/model_type.h" 13 #include "chrome/browser/sync/syncable/model_type.h"
13 #include "chrome/browser/sync/util/closure.h" 14 #include "chrome/browser/sync/util/closure.h"
14 #include "chrome/browser/sync/util/sync_types.h" 15 #include "chrome/browser/sync/util/sync_types.h"
15 16
16 namespace browser_sync { 17 namespace browser_sync {
17 18
18 enum ModelSafeGroup { 19 enum ModelSafeGroup {
19 GROUP_PASSIVE = 0, // Models that are just "passively" being synced; e.g. 20 GROUP_PASSIVE = 0, // Models that are just "passively" being synced; e.g.
20 // changes to these models don't need to be pushed to a 21 // changes to these models don't need to be pushed to a
21 // native model. 22 // native model.
22 GROUP_UI, // Models that live on UI thread and are being synced. 23 GROUP_UI, // Models that live on UI thread and are being synced.
23 GROUP_DB, // Models that live on DB thread and are being synced. 24 GROUP_DB, // Models that live on DB thread and are being synced.
24 GROUP_HISTORY, // Models that live on history thread and are being 25 GROUP_HISTORY, // Models that live on history thread and are being
25 // synced. 26 // synced.
26 GROUP_PASSWORD, // Models that live on the password thread and are 27 GROUP_PASSWORD, // Models that live on the password thread and are
27 // being synced. On windows and linux, this runs on the 28 // being synced. On windows and linux, this runs on the
28 // DB thread. 29 // DB thread.
29 MODEL_SAFE_GROUP_COUNT, 30 MODEL_SAFE_GROUP_COUNT,
30 }; 31 };
31 32
33 std::string ModelSafeGroupToString(ModelSafeGroup group);
34
32 // The Syncer uses a ModelSafeWorker for all tasks that could potentially 35 // The Syncer uses a ModelSafeWorker for all tasks that could potentially
33 // modify syncable entries (e.g under a WriteTransaction). The ModelSafeWorker 36 // modify syncable entries (e.g under a WriteTransaction). The ModelSafeWorker
34 // only knows how to do one thing, and that is take some work (in a fully 37 // only knows how to do one thing, and that is take some work (in a fully
35 // pre-bound callback) and have it performed (as in Run()) from a thread which 38 // pre-bound callback) and have it performed (as in Run()) from a thread which
36 // is guaranteed to be "model-safe", where "safe" refers to not allowing us to 39 // is guaranteed to be "model-safe", where "safe" refers to not allowing us to
37 // cause an embedding application model to fall out of sync with the 40 // cause an embedding application model to fall out of sync with the
38 // syncable::Directory due to a race. 41 // syncable::Directory due to a race.
39 class ModelSafeWorker : public base::RefCountedThreadSafe<ModelSafeWorker> { 42 class ModelSafeWorker : public base::RefCountedThreadSafe<ModelSafeWorker> {
40 public: 43 public:
41 ModelSafeWorker() { } 44 ModelSafeWorker() { }
(...skipping 14 matching lines...) Expand all
56 // this worker. If this returns true, then it should be safe to operate 59 // this worker. If this returns true, then it should be safe to operate
57 // on models that are in this worker's group. If this returns false, 60 // on models that are in this worker's group. If this returns false,
58 // such work should not be attempted. 61 // such work should not be attempted.
59 virtual bool CurrentThreadIsWorkThread() { 62 virtual bool CurrentThreadIsWorkThread() {
60 // The passive group is not the work thread for any browser model. 63 // The passive group is not the work thread for any browser model.
61 return false; 64 return false;
62 } 65 }
63 66
64 private: 67 private:
65 friend class base::RefCountedThreadSafe<ModelSafeWorker>; 68 friend class base::RefCountedThreadSafe<ModelSafeWorker>;
66 69
67 DISALLOW_COPY_AND_ASSIGN(ModelSafeWorker); 70 DISALLOW_COPY_AND_ASSIGN(ModelSafeWorker);
68 }; 71 };
69 72
70 // A map that details which ModelSafeGroup each syncable::ModelType 73 // A map that details which ModelSafeGroup each syncable::ModelType
71 // belongs to. Routing info can change in response to the user enabling / 74 // belongs to. Routing info can change in response to the user enabling /
72 // disabling sync for certain types, as well as model association completions. 75 // disabling sync for certain types, as well as model association completions.
73 typedef std::map<syncable::ModelType, ModelSafeGroup> 76 typedef std::map<syncable::ModelType, ModelSafeGroup>
74 ModelSafeRoutingInfo; 77 ModelSafeRoutingInfo;
75 78
76 ModelSafeGroup GetGroupForModelType(const syncable::ModelType type, 79 ModelSafeGroup GetGroupForModelType(const syncable::ModelType type,
(...skipping 20 matching lines...) Expand all
97 virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) = 0; 100 virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) = 0;
98 protected: 101 protected:
99 virtual ~ModelSafeWorkerRegistrar() {} 102 virtual ~ModelSafeWorkerRegistrar() {}
100 private: 103 private:
101 DISALLOW_COPY_AND_ASSIGN(ModelSafeWorkerRegistrar); 104 DISALLOW_COPY_AND_ASSIGN(ModelSafeWorkerRegistrar);
102 }; 105 };
103 106
104 } // namespace browser_sync 107 } // namespace browser_sync
105 108
106 #endif // CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ 109 #endif // CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser_about_handler.cc ('k') | chrome/browser/sync/engine/model_safe_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698