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

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

Issue 10827266: [Sync] Add SyncEncryptionHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Created 8 years, 4 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
« no previous file with comments | « chrome/browser/sync/DEPS ('k') | chrome/browser/sync/glue/sync_backend_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "chrome/browser/sync/glue/backend_data_type_configurer.h" 17 #include "chrome/browser/sync/glue/backend_data_type_configurer.h"
18 #include "chrome/browser/sync/glue/chrome_extensions_activity_monitor.h" 18 #include "chrome/browser/sync/glue/chrome_extensions_activity_monitor.h"
19 #include "chrome/common/net/gaia/google_service_auth_error.h" 19 #include "chrome/common/net/gaia/google_service_auth_error.h"
20 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
21 #include "sync/internal_api/public/base/model_type.h" 21 #include "sync/internal_api/public/base/model_type.h"
22 #include "sync/internal_api/public/configure_reason.h" 22 #include "sync/internal_api/public/configure_reason.h"
23 #include "sync/internal_api/public/engine/model_safe_worker.h" 23 #include "sync/internal_api/public/engine/model_safe_worker.h"
24 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 24 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
25 #include "sync/internal_api/public/sync_encryption_handler.h"
25 #include "sync/internal_api/public/sync_manager.h" 26 #include "sync/internal_api/public/sync_manager.h"
26 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" 27 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h"
27 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" 28 #include "sync/internal_api/public/util/unrecoverable_error_handler.h"
28 #include "sync/internal_api/public/util/weak_handle.h" 29 #include "sync/internal_api/public/util/weak_handle.h"
29 #include "sync/notifier/sync_notifier_factory.h" 30 #include "sync/notifier/sync_notifier_factory.h"
30 #include "sync/notifier/sync_notifier_observer.h" 31 #include "sync/notifier/sync_notifier_observer.h"
31 #include "sync/protocol/encryption.pb.h" 32 #include "sync/protocol/encryption.pb.h"
32 #include "sync/protocol/sync_protocol_error.h" 33 #include "sync/protocol/sync_protocol_error.h"
33 34
34 class MessageLoop; 35 class MessageLoop;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, 345 const base::Callback<void(syncer::ModelTypeSet)>& ready_task,
345 const base::Closure& retry_callback); 346 const base::Closure& retry_callback);
346 347
347 // Called when the syncer has finished performing a configuration. 348 // Called when the syncer has finished performing a configuration.
348 void FinishConfigureDataTypesOnFrontendLoop( 349 void FinishConfigureDataTypesOnFrontendLoop(
349 const syncer::ModelTypeSet failed_configuration_types, 350 const syncer::ModelTypeSet failed_configuration_types,
350 const base::Callback<void(syncer::ModelTypeSet)>& ready_task); 351 const base::Callback<void(syncer::ModelTypeSet)>& ready_task);
351 352
352 // Called when the SyncManager has been constructed and initialized. 353 // Called when the SyncManager has been constructed and initialized.
353 virtual void HandleSyncManagerInitializationOnFrontendLoop( 354 virtual void HandleSyncManagerInitializationOnFrontendLoop(
354 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success, 355 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
356 bool success,
355 syncer::ModelTypeSet restored_types); 357 syncer::ModelTypeSet restored_types);
356 358
357 SyncFrontend* frontend() { return frontend_; } 359 SyncFrontend* frontend() { return frontend_; }
358 360
359 private: 361 private:
360 // The real guts of SyncBackendHost, to keep the public client API clean. 362 // The real guts of SyncBackendHost, to keep the public client API clean.
361 class Core; 363 class Core;
362 364
363 // An enum representing the steps to initializing the SyncBackendHost. 365 // An enum representing the steps to initializing the SyncBackendHost.
364 enum InitializationState { 366 enum InitializationState {
365 NOT_ATTEMPTED, 367 NOT_ATTEMPTED,
366 CREATING_SYNC_MANAGER, // We're waiting for the first callback from the 368 CREATING_SYNC_MANAGER, // We're waiting for the first callback from the
367 // sync thread to inform us that the sync manager 369 // sync thread to inform us that the sync manager
368 // has been created. 370 // has been created.
369 NOT_INITIALIZED, // Initialization hasn't completed, but we've 371 NOT_INITIALIZED, // Initialization hasn't completed, but we've
370 // constructed a SyncManager. 372 // constructed a SyncManager.
371 DOWNLOADING_NIGORI, // The SyncManager is initialized, but 373 DOWNLOADING_NIGORI, // The SyncManager is initialized, but
372 // we're fetching encryption information. 374 // we're fetching sync encryption information.
373 REFRESHING_NIGORI, // The SyncManager is initialized, and we 375 ASSOCIATING_NIGORI, // The SyncManager is initialized, and we
374 // have the encryption information, but we 376 // have the sync encryption information, but we
375 // still need to refresh encryption. Also, we need 377 // have to update the local encryption state.
376 // to update the device information in the nigori.
377 INITIALIZED, // Initialization is complete. 378 INITIALIZED, // Initialization is complete.
378 }; 379 };
379 380
380 // Enum used to distinguish which bootstrap encryption token is being updated. 381 // Enum used to distinguish which bootstrap encryption token is being updated.
381 enum BootstrapTokenType { 382 enum BootstrapTokenType {
382 PASSPHRASE_BOOTSTRAP_TOKEN, 383 PASSPHRASE_BOOTSTRAP_TOKEN,
383 KEYSTORE_BOOTSTRAP_TOKEN 384 KEYSTORE_BOOTSTRAP_TOKEN
384 }; 385 };
385 386
386 // Checks if we have received a notice to turn on experimental datatypes 387 // Checks if we have received a notice to turn on experimental datatypes
387 // (via the nigori node) and informs the frontend if that is the case. 388 // (via the nigori node) and informs the frontend if that is the case.
388 // Note: it is illegal to call this before the backend is initialized. 389 // Note: it is illegal to call this before the backend is initialized.
389 void AddExperimentalTypes(); 390 void AddExperimentalTypes();
390 391
391 // Downloading of nigori failed and will be retried. 392 // Downloading of nigori failed and will be retried.
392 void OnNigoriDownloadRetry(); 393 void OnNigoriDownloadRetry();
393 394
394 // InitializationComplete passes through the SyncBackendHost to forward 395 // InitializationComplete passes through the SyncBackendHost to forward
395 // on to |frontend_|, and so that tests can intercept here if they need to 396 // on to |frontend_|, and so that tests can intercept here if they need to
396 // set up initial conditions. 397 // set up initial conditions.
397 void HandleInitializationCompletedOnFrontendLoop( 398 void HandleInitializationCompletedOnFrontendLoop(
398 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
399 bool success); 399 bool success);
400 400
401 // Called from Core::OnSyncCycleCompleted to handle updating frontend 401 // Called from Core::OnSyncCycleCompleted to handle updating frontend
402 // thread components. 402 // thread components.
403 void HandleSyncCycleCompletedOnFrontendLoop( 403 void HandleSyncCycleCompletedOnFrontendLoop(
404 const syncer::sessions::SyncSessionSnapshot& snapshot); 404 const syncer::sessions::SyncSessionSnapshot& snapshot);
405 405
406 // Called when the syncer failed to perform a configuration and will 406 // Called when the syncer failed to perform a configuration and will
407 // eventually retry. FinishingConfigurationOnFrontendLoop(..) will be called 407 // eventually retry. FinishingConfigurationOnFrontendLoop(..) will be called
408 // on successful completion. 408 // on successful completion.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 void HandleStopSyncingPermanentlyOnFrontendLoop(); 457 void HandleStopSyncingPermanentlyOnFrontendLoop();
458 458
459 // Dispatched to from OnConnectionStatusChange to handle updating 459 // Dispatched to from OnConnectionStatusChange to handle updating
460 // frontend UI components. 460 // frontend UI components.
461 void HandleConnectionStatusChangeOnFrontendLoop( 461 void HandleConnectionStatusChangeOnFrontendLoop(
462 syncer::ConnectionStatus status); 462 syncer::ConnectionStatus status);
463 463
464 // Called when configuration of the Nigori node has completed as 464 // Called when configuration of the Nigori node has completed as
465 // part of the initialization process. 465 // part of the initialization process.
466 void HandleNigoriConfigurationCompletedOnFrontendLoop( 466 void HandleNigoriConfigurationCompletedOnFrontendLoop(
467 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
468 syncer::ModelTypeSet failed_configuration_types); 467 syncer::ModelTypeSet failed_configuration_types);
469 468
470 // syncer::SyncNotifierObserver-like functions. 469 // syncer::SyncNotifierObserver-like functions.
471 void HandleNotificationsEnabledOnFrontendLoop(); 470 void HandleNotificationsEnabledOnFrontendLoop();
472 void HandleNotificationsDisabledOnFrontendLoop( 471 void HandleNotificationsDisabledOnFrontendLoop(
473 syncer::NotificationsDisabledReason reason); 472 syncer::NotificationsDisabledReason reason);
474 void HandleIncomingNotificationOnFrontendLoop( 473 void HandleIncomingNotificationOnFrontendLoop(
475 const syncer::ObjectIdPayloadMap& id_payloads, 474 const syncer::ObjectIdPayloadMap& id_payloads,
476 syncer::IncomingNotificationSource source); 475 syncer::IncomingNotificationSource source);
477 476
478 // Must be called on |frontend_loop_|. |done_callback| is called on
479 // |frontend_loop_|.
480 void RefreshNigori(const base::Closure& done_callback);
481
482 // Handles stopping the core's SyncManager, accounting for whether 477 // Handles stopping the core's SyncManager, accounting for whether
483 // initialization is done yet. 478 // initialization is done yet.
484 void StopSyncManagerForShutdown(const base::Closure& closure); 479 void StopSyncManagerForShutdown(const base::Closure& closure);
485 480
486 base::WeakPtrFactory<SyncBackendHost> weak_ptr_factory_; 481 base::WeakPtrFactory<SyncBackendHost> weak_ptr_factory_;
487 482
488 // A thread where all the sync operations happen. 483 // A thread where all the sync operations happen.
489 base::Thread sync_thread_; 484 base::Thread sync_thread_;
490 485
491 // A reference to the MessageLoop used to construct |this|, so we know how 486 // A reference to the MessageLoop used to construct |this|, so we know how
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 // give the user immediate feedback about the passphrase entered by first 518 // give the user immediate feedback about the passphrase entered by first
524 // trying to decrypt the cached pending keys on the UI thread. Note that 519 // trying to decrypt the cached pending keys on the UI thread. Note that
525 // SetDecryptionPassphrase can still fail after the cached pending keys are 520 // SetDecryptionPassphrase can still fail after the cached pending keys are
526 // successfully decrypted if the pending keys have changed since the time they 521 // successfully decrypted if the pending keys have changed since the time they
527 // were cached. 522 // were cached.
528 sync_pb::EncryptedData cached_pending_keys_; 523 sync_pb::EncryptedData cached_pending_keys_;
529 524
530 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. 525 // UI-thread cache of the last SyncSessionSnapshot received from syncapi.
531 syncer::sessions::SyncSessionSnapshot last_snapshot_; 526 syncer::sessions::SyncSessionSnapshot last_snapshot_;
532 527
528 // Temporary holder for the javascript backend. Set by
529 // HandleSyncManagerInitializationOnFrontendLoop, and consumed when we pass
530 // it via OnBackendInitialized in the final state of
531 // HandleInitializationCompletedOnFrontendLoop.
532 syncer::WeakHandle<syncer::JsBackend> js_backend_;
533
533 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); 534 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost);
534 }; 535 };
535 536
536 } // namespace browser_sync 537 } // namespace browser_sync
537 538
538 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 539 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/DEPS ('k') | chrome/browser/sync/glue/sync_backend_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698