OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
20 #include "base/timer.h" | 20 #include "base/timer.h" |
21 #include "chrome/browser/sync/engine/model_safe_worker.h" | 21 #include "chrome/browser/sync/engine/model_safe_worker.h" |
22 #include "chrome/browser/sync/internal_api/configure_reason.h" | 22 #include "chrome/browser/sync/internal_api/configure_reason.h" |
23 #include "chrome/browser/sync/internal_api/sync_manager.h" | 23 #include "chrome/browser/sync/internal_api/sync_manager.h" |
24 #include "chrome/browser/sync/notifier/sync_notifier_factory.h" | 24 #include "chrome/browser/sync/notifier/sync_notifier_factory.h" |
25 #include "chrome/browser/sync/protocol/sync_protocol_error.h" | 25 #include "chrome/browser/sync/protocol/sync_protocol_error.h" |
26 #include "chrome/browser/sync/syncable/model_type.h" | 26 #include "chrome/browser/sync/syncable/model_type.h" |
| 27 #include "chrome/browser/sync/unrecoverable_error_handler.h" |
27 #include "chrome/browser/sync/util/weak_handle.h" | 28 #include "chrome/browser/sync/util/weak_handle.h" |
28 #include "chrome/common/net/gaia/google_service_auth_error.h" | 29 #include "chrome/common/net/gaia/google_service_auth_error.h" |
29 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
30 #include "net/url_request/url_request_context_getter.h" | 31 #include "net/url_request/url_request_context_getter.h" |
31 | 32 |
32 class MessageLoop; | 33 class MessageLoop; |
33 class Profile; | 34 class Profile; |
34 | 35 |
35 namespace browser_sync { | 36 namespace browser_sync { |
36 | 37 |
37 namespace sessions { | 38 namespace sessions { |
38 struct SyncSessionSnapshot; | 39 struct SyncSessionSnapshot; |
39 } | 40 } |
40 | 41 |
41 class ChangeProcessor; | 42 class ChangeProcessor; |
42 class JsBackend; | 43 class JsBackend; |
43 class JsEventHandler; | 44 class JsEventHandler; |
44 class SyncBackendRegistrar; | 45 class SyncBackendRegistrar; |
45 class SyncPrefs; | 46 class SyncPrefs; |
46 | 47 |
47 // SyncFrontend is the interface used by SyncBackendHost to communicate with | 48 // SyncFrontend is the interface used by SyncBackendHost to communicate with |
48 // the entity that created it and, presumably, is interested in sync-related | 49 // the entity that created it and, presumably, is interested in sync-related |
49 // activity. | 50 // activity. |
50 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread | 51 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread |
51 // used to create that SyncBackendHost. | 52 // used to create that SyncBackendHost. |
52 class SyncFrontend { | 53 class SyncFrontend : public browser_sync::UnrecoverableErrorHandler { |
53 public: | 54 public: |
54 SyncFrontend() {} | 55 SyncFrontend() {} |
55 | 56 |
56 // The backend has completed initialization and it is now ready to | 57 // The backend has completed initialization and it is now ready to |
57 // accept and process changes. If success is false, initialization | 58 // accept and process changes. If success is false, initialization |
58 // wasn't able to be completed and should be retried. | 59 // wasn't able to be completed and should be retried. |
59 // | 60 // |
60 // |js_backend| is what about:sync interacts with; it's different | 61 // |js_backend| is what about:sync interacts with; it's different |
61 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It | 62 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It |
62 // is initialized only if |success| is true. | 63 // is initialized only if |success| is true. |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 virtual void OnPassphraseAccepted( | 287 virtual void OnPassphraseAccepted( |
287 const std::string& bootstrap_token) OVERRIDE; | 288 const std::string& bootstrap_token) OVERRIDE; |
288 virtual void OnStopSyncingPermanently() OVERRIDE; | 289 virtual void OnStopSyncingPermanently() OVERRIDE; |
289 virtual void OnUpdatedToken(const std::string& token) OVERRIDE; | 290 virtual void OnUpdatedToken(const std::string& token) OVERRIDE; |
290 virtual void OnClearServerDataFailed() OVERRIDE; | 291 virtual void OnClearServerDataFailed() OVERRIDE; |
291 virtual void OnClearServerDataSucceeded() OVERRIDE; | 292 virtual void OnClearServerDataSucceeded() OVERRIDE; |
292 virtual void OnEncryptionComplete( | 293 virtual void OnEncryptionComplete( |
293 const syncable::ModelTypeSet& encrypted_types); | 294 const syncable::ModelTypeSet& encrypted_types); |
294 virtual void OnActionableError( | 295 virtual void OnActionableError( |
295 const browser_sync::SyncProtocolError& sync_error); | 296 const browser_sync::SyncProtocolError& sync_error); |
| 297 virtual void OnUnrecoverableError( |
| 298 const tracked_objects::Location& location, |
| 299 const std::string& message) OVERRIDE; |
296 | 300 |
297 struct DoInitializeOptions { | 301 struct DoInitializeOptions { |
298 DoInitializeOptions( | 302 DoInitializeOptions( |
299 MessageLoop* sync_loop, | 303 MessageLoop* sync_loop, |
300 SyncBackendRegistrar* registrar, | 304 SyncBackendRegistrar* registrar, |
301 const WeakHandle<JsEventHandler>& event_handler, | 305 const WeakHandle<JsEventHandler>& event_handler, |
302 const GURL& service_url, | 306 const GURL& service_url, |
303 const scoped_refptr<net::URLRequestContextGetter>& | 307 const scoped_refptr<net::URLRequestContextGetter>& |
304 request_context_getter, | 308 request_context_getter, |
305 const sync_api::SyncCredentials& credentials, | 309 const sync_api::SyncCredentials& credentials, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 // This is called from the thread we were created on (which is the | 427 // This is called from the thread we were created on (which is the |
424 // SyncBackendHost |sync_thread_|), using a repeating timer that is kicked | 428 // SyncBackendHost |sync_thread_|), using a repeating timer that is kicked |
425 // off as soon as the SyncManager tells us it completed | 429 // off as soon as the SyncManager tells us it completed |
426 // initialization. | 430 // initialization. |
427 void SaveChanges(); | 431 void SaveChanges(); |
428 | 432 |
429 // Let the front end handle the actionable error event. | 433 // Let the front end handle the actionable error event. |
430 void HandleActionableErrorEventOnFrontendLoop( | 434 void HandleActionableErrorEventOnFrontendLoop( |
431 const browser_sync::SyncProtocolError& sync_error); | 435 const browser_sync::SyncProtocolError& sync_error); |
432 | 436 |
| 437 // Informs the front end of the unrecoverable error. |
| 438 void HandleUnrecoverableErrorOnFrontendLoop( |
| 439 const tracked_objects::Location& location, |
| 440 const std::string& message); |
| 441 |
433 // Dispatched to from OnAuthError to handle updating frontend UI | 442 // Dispatched to from OnAuthError to handle updating frontend UI |
434 // components. | 443 // components. |
435 void HandleAuthErrorEventOnFrontendLoop( | 444 void HandleAuthErrorEventOnFrontendLoop( |
436 const GoogleServiceAuthError& new_auth_error); | 445 const GoogleServiceAuthError& new_auth_error); |
437 | 446 |
438 // Invoked when a passphrase is required to decrypt a set of Nigori keys, | 447 // Invoked when a passphrase is required to decrypt a set of Nigori keys, |
439 // or for encrypting. |reason| denotes why the passhrase was required. | 448 // or for encrypting. |reason| denotes why the passhrase was required. |
440 void NotifyPassphraseRequired(sync_api::PassphraseRequiredReason reason); | 449 void NotifyPassphraseRequired(sync_api::PassphraseRequiredReason reason); |
441 | 450 |
442 // Invoked when the passphrase provided by the user has been accepted. | 451 // Invoked when the passphrase provided by the user has been accepted. |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 | 591 |
583 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. | 592 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. |
584 scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_; | 593 scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_; |
585 | 594 |
586 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); | 595 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); |
587 }; | 596 }; |
588 | 597 |
589 } // namespace browser_sync | 598 } // namespace browser_sync |
590 | 599 |
591 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 600 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
OLD | NEW |