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

Side by Side Diff: chrome/browser/sync/glue/data_type_controller.h

Issue 10662035: [Sync] Put everything in sync/api into csync namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix 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 #ifndef CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_CONTROLLER_H__ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_CONTROLLER_H__
6 #define CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_CONTROLLER_H__ 6 #define CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_CONTROLLER_H__
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/sequenced_task_runner_helpers.h" 14 #include "base/sequenced_task_runner_helpers.h"
15 #include "chrome/browser/sync/glue/data_type_error_handler.h" 15 #include "chrome/browser/sync/glue/data_type_error_handler.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "sync/internal_api/public/engine/model_safe_worker.h" 17 #include "sync/internal_api/public/engine/model_safe_worker.h"
18 #include "sync/internal_api/public/syncable/model_type.h" 18 #include "sync/internal_api/public/syncable/model_type.h"
19 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" 19 #include "sync/internal_api/public/util/unrecoverable_error_handler.h"
20 20
21 namespace csync {
21 class SyncError; 22 class SyncError;
23 }
22 24
23 namespace browser_sync { 25 namespace browser_sync {
24 26
25 // Data type controllers need to be refcounted threadsafe, as they may 27 // Data type controllers need to be refcounted threadsafe, as they may
26 // need to run model associator or change processor on other threads. 28 // need to run model associator or change processor on other threads.
27 class DataTypeController 29 class DataTypeController
28 : public base::RefCountedThreadSafe< 30 : public base::RefCountedThreadSafe<
29 DataTypeController, content::BrowserThread::DeleteOnUIThread>, 31 DataTypeController, content::BrowserThread::DeleteOnUIThread>,
30 public DataTypeErrorHandler { 32 public DataTypeErrorHandler {
31 public: 33 public:
(...skipping 22 matching lines...) Expand all
54 BUSY, // Start() was called while already in progress. 56 BUSY, // Start() was called while already in progress.
55 NOT_ENABLED, // This data type is not enabled for the current user. 57 NOT_ENABLED, // This data type is not enabled for the current user.
56 ASSOCIATION_FAILED, // An error occurred during model association. 58 ASSOCIATION_FAILED, // An error occurred during model association.
57 ABORTED, // Start was aborted by calling Stop(). 59 ABORTED, // Start was aborted by calling Stop().
58 UNRECOVERABLE_ERROR, // An unrecoverable error occured. 60 UNRECOVERABLE_ERROR, // An unrecoverable error occured.
59 NEEDS_CRYPTO, // The data type cannot be started yet because it 61 NEEDS_CRYPTO, // The data type cannot be started yet because it
60 // depends on the cryptographer. 62 // depends on the cryptographer.
61 MAX_START_RESULT 63 MAX_START_RESULT
62 }; 64 };
63 65
64 typedef base::Callback<void(StartResult, const SyncError&)> StartCallback; 66 typedef base::Callback<void(StartResult,
67 const csync::SyncError&)> StartCallback;
65 68
66 typedef base::Callback<void(syncable::ModelType, 69 typedef base::Callback<void(syncable::ModelType,
67 SyncError)> ModelLoadCallback; 70 csync::SyncError)> ModelLoadCallback;
68 71
69 typedef std::map<syncable::ModelType, 72 typedef std::map<syncable::ModelType,
70 scoped_refptr<DataTypeController> > TypeMap; 73 scoped_refptr<DataTypeController> > TypeMap;
71 typedef std::map<syncable::ModelType, DataTypeController::State> StateMap; 74 typedef std::map<syncable::ModelType, DataTypeController::State> StateMap;
72 75
73 // Returns true if the start result should trigger an unrecoverable error. 76 // Returns true if the start result should trigger an unrecoverable error.
74 // Public so unit tests can use this function as well. 77 // Public so unit tests can use this function as well.
75 static bool IsUnrecoverableResult(StartResult result); 78 static bool IsUnrecoverableResult(StartResult result);
76 79
77 // Begins asynchronous operation of loading the model to get it ready for 80 // Begins asynchronous operation of loading the model to get it ready for
(...skipping 22 matching lines...) Expand all
100 // The model safe group of this data type. This should reflect the 103 // The model safe group of this data type. This should reflect the
101 // thread that should be used to modify the data type's native 104 // thread that should be used to modify the data type's native
102 // model. 105 // model.
103 virtual csync::ModelSafeGroup model_safe_group() const = 0; 106 virtual csync::ModelSafeGroup model_safe_group() const = 0;
104 107
105 // Current state of the data type controller. 108 // Current state of the data type controller.
106 virtual State state() const = 0; 109 virtual State state() const = 0;
107 110
108 // Partial implementation of DataTypeErrorHandler. 111 // Partial implementation of DataTypeErrorHandler.
109 // This is thread safe. 112 // This is thread safe.
110 virtual SyncError CreateAndUploadError( 113 virtual csync::SyncError CreateAndUploadError(
111 const tracked_objects::Location& location, 114 const tracked_objects::Location& location,
112 const std::string& message, 115 const std::string& message,
113 syncable::ModelType type) OVERRIDE; 116 syncable::ModelType type) OVERRIDE;
114 117
115 protected: 118 protected:
116 friend struct content::BrowserThread::DeleteOnThread< 119 friend struct content::BrowserThread::DeleteOnThread<
117 content::BrowserThread::UI>; 120 content::BrowserThread::UI>;
118 friend class base::DeleteHelper<DataTypeController>; 121 friend class base::DeleteHelper<DataTypeController>;
119 122
120 // If the DTC is waiting for models to load, once the models are 123 // If the DTC is waiting for models to load, once the models are
121 // loaded the datatype service will call this function on DTC to let 124 // loaded the datatype service will call this function on DTC to let
122 // us know that it is safe to start associating. 125 // us know that it is safe to start associating.
123 virtual void OnModelLoaded() = 0; 126 virtual void OnModelLoaded() = 0;
124 127
125 virtual ~DataTypeController() {} 128 virtual ~DataTypeController() {}
126 129
127 // Handles the reporting of unrecoverable error. It records stuff in 130 // Handles the reporting of unrecoverable error. It records stuff in
128 // UMA and reports to breakpad. 131 // UMA and reports to breakpad.
129 // Virtual for testing purpose. 132 // Virtual for testing purpose.
130 virtual void RecordUnrecoverableError( 133 virtual void RecordUnrecoverableError(
131 const tracked_objects::Location& from_here, 134 const tracked_objects::Location& from_here,
132 const std::string& message); 135 const std::string& message);
133 }; 136 };
134 137
135 } // namespace browser_sync 138 } // namespace browser_sync
136 139
137 #endif // CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_CONTROLLER_H__ 140 #endif // CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_CONTROLLER_H__
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/change_processor_mock.h ('k') | chrome/browser/sync/glue/data_type_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698