Commit f70f4435 authored by akalin@chromium.org's avatar akalin@chromium.org

[Sync] Make SyncBackendHost::Core use a WeakHandle to its host

This removes a lot of boilerplate with checking host_ (which was never
[locally] thread-safe, anyway).

Make as many things in SyncBackendHost private as possible.

BUG=103410,107279
TEST=


Review URL: http://codereview.chromium.org/8938013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114597 0039d316-1c4b-4281-b951-d872f2087c98
parent 1723bdc2
...@@ -66,21 +66,25 @@ void SyncBackendHostForProfileSyncTest:: ...@@ -66,21 +66,25 @@ void SyncBackendHostForProfileSyncTest::
if (!fail_initial_download_) if (!fail_initial_download_)
sync_ended = syncable::ModelTypeSet::All(); sync_ended = syncable::ModelTypeSet::All();
std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; std::string download_progress_markers[syncable::MODEL_TYPE_COUNT];
core_->HandleSyncCycleCompletedOnFrontendLoop(new SyncSessionSnapshot( HandleSyncCycleCompletedOnFrontendLoop(new SyncSessionSnapshot(
SyncerStatus(), ErrorCounters(), 0, false, SyncerStatus(), ErrorCounters(), 0, false,
sync_ended, download_progress_markers, false, false, 0, 0, 0, false, sync_ended, download_progress_markers, false, false, 0, 0, 0, false,
SyncSourceInfo(), 0, base::Time::Now())); SyncSourceInfo(), 0, base::Time::Now()));
} }
sync_api::HttpPostProviderFactory* namespace {
SyncBackendHostForProfileSyncTest::MakeHttpBridgeFactory(
const scoped_refptr<net::URLRequestContextGetter>& getter) { sync_api::HttpPostProviderFactory* MakeTestHttpBridgeFactory() {
return new browser_sync::TestHttpBridgeFactory; return new browser_sync::TestHttpBridgeFactory();
} }
} // namespace
void SyncBackendHostForProfileSyncTest::InitCore( void SyncBackendHostForProfileSyncTest::InitCore(
const Core::DoInitializeOptions& options) { const DoInitializeOptions& options) {
Core::DoInitializeOptions test_options = options; DoInitializeOptions test_options = options;
test_options.make_http_bridge_factory_fn =
base::Bind(&MakeTestHttpBridgeFactory);
test_options.credentials.email = "testuser@gmail.com"; test_options.credentials.email = "testuser@gmail.com";
test_options.credentials.sync_token = "token"; test_options.credentials.sync_token = "token";
test_options.restored_key_for_bootstrapping = ""; test_options.restored_key_for_bootstrapping = "";
...@@ -97,13 +101,13 @@ void SyncBackendHostForProfileSyncTest::InitCore( ...@@ -97,13 +101,13 @@ void SyncBackendHostForProfileSyncTest::InitCore(
void SyncBackendHostForProfileSyncTest::StartConfiguration( void SyncBackendHostForProfileSyncTest::StartConfiguration(
const base::Closure& callback) { const base::Closure& callback) {
SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop(); SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop();
if (initialization_state_ == DOWNLOADING_NIGORI) { if (IsDownloadingNigoriForTest()) {
syncable::ModelTypeSet sync_ended; syncable::ModelTypeSet sync_ended;
if (!fail_initial_download_) if (!fail_initial_download_)
sync_ended.Put(syncable::NIGORI); sync_ended.Put(syncable::NIGORI);
std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; std::string download_progress_markers[syncable::MODEL_TYPE_COUNT];
core_->HandleSyncCycleCompletedOnFrontendLoop(new SyncSessionSnapshot( HandleSyncCycleCompletedOnFrontendLoop(new SyncSessionSnapshot(
SyncerStatus(), ErrorCounters(), 0, false, SyncerStatus(), ErrorCounters(), 0, false,
sync_ended, download_progress_markers, false, false, 0, 0, 0, false, sync_ended, download_progress_markers, false, false, 0, 0, 0, false,
SyncSourceInfo(), 0, base::Time::Now())); SyncSourceInfo(), 0, base::Time::Now()));
......
...@@ -45,9 +45,6 @@ class SyncBackendHostForProfileSyncTest : public SyncBackendHost { ...@@ -45,9 +45,6 @@ class SyncBackendHostForProfileSyncTest : public SyncBackendHost {
void SimulateSyncCycleCompletedInitialSyncEnded( void SimulateSyncCycleCompletedInitialSyncEnded(
const tracked_objects::Location&); const tracked_objects::Location&);
virtual sync_api::HttpPostProviderFactory* MakeHttpBridgeFactory(
const scoped_refptr<net::URLRequestContextGetter>& getter) OVERRIDE;
virtual void StartConfiguration(const base::Closure& callback) OVERRIDE; virtual void StartConfiguration(const base::Closure& callback) OVERRIDE;
static void SetDefaultExpectationsForWorkerCreation(ProfileMock* profile); static void SetDefaultExpectationsForWorkerCreation(ProfileMock* profile);
...@@ -55,7 +52,7 @@ class SyncBackendHostForProfileSyncTest : public SyncBackendHost { ...@@ -55,7 +52,7 @@ class SyncBackendHostForProfileSyncTest : public SyncBackendHost {
static void SetHistoryServiceExpectations(ProfileMock* profile); static void SetHistoryServiceExpectations(ProfileMock* profile);
protected: protected:
virtual void InitCore(const Core::DoInitializeOptions& options) OVERRIDE; virtual void InitCore(const DoInitializeOptions& options) OVERRIDE;
private: private:
bool synchronous_init_; bool synchronous_init_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment