| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SYNC_BACKEND_HOST_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 private: | 91 private: |
| 92 DISALLOW_COPY_AND_ASSIGN(SyncFrontend); | 92 DISALLOW_COPY_AND_ASSIGN(SyncFrontend); |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 // A UI-thread safe API into the sync backend that "hosts" the top-level | 95 // A UI-thread safe API into the sync backend that "hosts" the top-level |
| 96 // syncapi element, the SyncManager, on its own thread. This class handles | 96 // syncapi element, the SyncManager, on its own thread. This class handles |
| 97 // dispatch of potentially blocking calls to appropriate threads and ensures | 97 // dispatch of potentially blocking calls to appropriate threads and ensures |
| 98 // that the SyncFrontend is only accessed on the UI loop. | 98 // that the SyncFrontend is only accessed on the UI loop. |
| 99 class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { | 99 class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { |
| 100 public: | 100 public: |
| 101 typedef sync_api::UserShare* UserShareHandle; | |
| 102 typedef sync_api::SyncManager::Status::Summary StatusSummary; | 101 typedef sync_api::SyncManager::Status::Summary StatusSummary; |
| 103 typedef sync_api::SyncManager::Status Status; | 102 typedef sync_api::SyncManager::Status Status; |
| 104 typedef std::map<ModelSafeGroup, | 103 typedef std::map<ModelSafeGroup, |
| 105 scoped_refptr<browser_sync::ModelSafeWorker> > WorkerMap; | 104 scoped_refptr<browser_sync::ModelSafeWorker> > WorkerMap; |
| 106 | 105 |
| 107 // Create a SyncBackendHost with a reference to the |frontend| that it serves | 106 // Create a SyncBackendHost with a reference to the |frontend| that it serves |
| 108 // and communicates to via the SyncFrontend interface (on the same thread | 107 // and communicates to via the SyncFrontend interface (on the same thread |
| 109 // it used to call the constructor). | 108 // it used to call the constructor). |
| 110 SyncBackendHost(SyncFrontend* frontend, Profile* profile); | 109 explicit SyncBackendHost(Profile* profile); |
| 111 // For testing. | 110 // For testing. |
| 112 // TODO(skrul): Extract an interface so this is not needed. | 111 // TODO(skrul): Extract an interface so this is not needed. |
| 113 SyncBackendHost(); | 112 SyncBackendHost(); |
| 114 ~SyncBackendHost(); | 113 ~SyncBackendHost(); |
| 115 | 114 |
| 116 // Called on |frontend_loop_| to kick off asynchronous initialization. | 115 // Called on |frontend_loop_| to kick off asynchronous initialization. |
| 117 // As a fallback when no cached auth information is available, try to | 116 // As a fallback when no cached auth information is available, try to |
| 118 // bootstrap authentication using |lsid|, if it isn't empty. | 117 // bootstrap authentication using |lsid|, if it isn't empty. |
| 119 // Optionally delete the Sync Data folder (if it's corrupt). | 118 // Optionally delete the Sync Data folder (if it's corrupt). |
| 120 void Initialize(const GURL& service_url, | 119 void Initialize(SyncFrontend* frontend, |
| 120 const GURL& service_url, |
| 121 const syncable::ModelTypeSet& types, | 121 const syncable::ModelTypeSet& types, |
| 122 URLRequestContextGetter* baseline_context_getter, | 122 URLRequestContextGetter* baseline_context_getter, |
| 123 const sync_api::SyncCredentials& credentials, | 123 const sync_api::SyncCredentials& credentials, |
| 124 bool delete_sync_data_folder, | 124 bool delete_sync_data_folder, |
| 125 const notifier::NotifierOptions& notifier_options); | 125 const notifier::NotifierOptions& notifier_options); |
| 126 | 126 |
| 127 // Called from |frontend_loop| to update SyncCredentials. | 127 // Called from |frontend_loop| to update SyncCredentials. |
| 128 void UpdateCredentials(const sync_api::SyncCredentials& credentials); | 128 void UpdateCredentials(const sync_api::SyncCredentials& credentials); |
| 129 | 129 |
| 130 // This starts the SyncerThread running a Syncer object to communicate with | 130 // This starts the SyncerThread running a Syncer object to communicate with |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // Requests the backend to resume. Returns true if the request is | 186 // Requests the backend to resume. Returns true if the request is |
| 187 // sent sucessfully. When the backend does resume, a SYNC_RESUMED | 187 // sent sucessfully. When the backend does resume, a SYNC_RESUMED |
| 188 // notification is sent to the notification service. | 188 // notification is sent to the notification service. |
| 189 virtual bool RequestResume(); | 189 virtual bool RequestResume(); |
| 190 | 190 |
| 191 // Asks the server to clear all data associated with ChromeSync. | 191 // Asks the server to clear all data associated with ChromeSync. |
| 192 virtual bool RequestClearServerData(); | 192 virtual bool RequestClearServerData(); |
| 193 | 193 |
| 194 // Called on |frontend_loop_| to obtain a handle to the UserShare needed | 194 // Called on |frontend_loop_| to obtain a handle to the UserShare needed |
| 195 // for creating transactions. | 195 // for creating transactions. |
| 196 UserShareHandle GetUserShareHandle() const; | 196 sync_api::UserShare* GetUserShare() const; |
| 197 | 197 |
| 198 // Called from any thread to obtain current status information in detailed or | 198 // Called from any thread to obtain current status information in detailed or |
| 199 // summarized form. | 199 // summarized form. |
| 200 Status GetDetailedStatus(); | 200 Status GetDetailedStatus(); |
| 201 StatusSummary GetStatusSummary(); | 201 StatusSummary GetStatusSummary(); |
| 202 const GoogleServiceAuthError& GetAuthError() const; | 202 const GoogleServiceAuthError& GetAuthError() const; |
| 203 const sessions::SyncSessionSnapshot* GetLastSessionSnapshot() const; | 203 const sessions::SyncSessionSnapshot* GetLastSessionSnapshot() const; |
| 204 | 204 |
| 205 const FilePath& sync_data_folder_path() const { | 205 const FilePath& sync_data_folder_path() const { |
| 206 return sync_data_folder_path_; | 206 return sync_data_folder_path_; |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 | 534 |
| 535 // Whether we've processed the initialization complete callback. | 535 // Whether we've processed the initialization complete callback. |
| 536 bool syncapi_initialized_; | 536 bool syncapi_initialized_; |
| 537 | 537 |
| 538 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); | 538 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); |
| 539 }; | 539 }; |
| 540 | 540 |
| 541 } // namespace browser_sync | 541 } // namespace browser_sync |
| 542 | 542 |
| 543 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 543 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
| OLD | NEW |