Skip to content

Commit

Permalink
Refactor SyncManager::Init to use a GURL for the sync server URL.
Browse files Browse the repository at this point in the history
Instead of passing the sync server URL as a string, int, and bool, just
pass the GURL.  In a future CL SyncManager will make use of this GURL to
initialize an AttachmentUploader.

clang-format was used to format the modified lines.

BUG=

Review URL: https://codereview.chromium.org/442403003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287893 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
maniscalco@chromium.org committed Aug 6, 2014
1 parent 6ad827a commit f3d8ca5
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 121 deletions.
6 changes: 2 additions & 4 deletions chrome/browser/sync/glue/sync_backend_host_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "sync/internal_api/public/sync_context_proxy.h"
#include "sync/internal_api/public/sync_manager.h"
#include "sync/internal_api/public/sync_manager_factory.h"
#include "url/gurl.h"

// Helper macros to log with the syncer thread name; useful when there
// are multiple syncers involved.
Expand Down Expand Up @@ -431,9 +432,7 @@ void SyncBackendHostCore::DoInitialize(
sync_manager_->AddObserver(this);
sync_manager_->Init(sync_data_folder_path_,
options->event_handler,
options->service_url.host() + options->service_url.path(),
options->service_url.EffectiveIntPort(),
options->service_url.SchemeIsSecure(),
options->service_url,
options->http_bridge_factory.Pass(),
options->workers,
options->extensions_activity,
Expand Down Expand Up @@ -752,4 +751,3 @@ void SyncBackendHostCore::SaveChanges() {
}

} // namespace browser_sync

10 changes: 4 additions & 6 deletions sync/internal_api/public/sync_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "sync/internal_api/public/util/weak_handle.h"
#include "sync/protocol/sync_protocol_error.h"

class GURL;

namespace sync_pb {
class EncryptedData;
} // namespace sync_pb
Expand Down Expand Up @@ -227,9 +229,7 @@ class SYNC_EXPORT SyncManager {
// does not already exist. Returns false on failure.
// |event_handler| is the JsEventHandler used to propagate events to
// chrome://sync-internals. |event_handler| may be uninitialized.
// |sync_server_and_path| and |sync_server_port| represent the Chrome sync
// server to use, and |use_ssl| specifies whether to communicate securely;
// the default is false.
// |service_url| is the URL of the Chrome Sync Server.
// |post_factory| will be owned internally and used to create
// instances of an HttpPostProvider.
// |model_safe_worker| ownership is given to the SyncManager.
Expand All @@ -252,9 +252,7 @@ class SYNC_EXPORT SyncManager {
virtual void Init(
const base::FilePath& database_location,
const WeakHandle<JsEventHandler>& event_handler,
const std::string& sync_server_and_path,
int sync_server_port,
bool use_ssl,
const GURL& service_url,
scoped_ptr<HttpPostProviderFactory> post_factory,
const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
ExtensionsActivity* extensions_activity,
Expand Down
6 changes: 3 additions & 3 deletions sync/internal_api/public/test/fake_sync_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "sync/internal_api/public/test/null_sync_context_proxy.h"
#include "sync/internal_api/public/test/test_user_share.h"

class GURL;

namespace base {
class SequencedTaskRunner;
}
Expand Down Expand Up @@ -78,9 +80,7 @@ class FakeSyncManager : public SyncManager {
virtual void Init(
const base::FilePath& database_location,
const WeakHandle<JsEventHandler>& event_handler,
const std::string& sync_server_and_path,
int sync_server_port,
bool use_ssl,
const GURL& service_url,
scoped_ptr<HttpPostProviderFactory> post_factory,
const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
ExtensionsActivity* extensions_activity,
Expand Down
36 changes: 17 additions & 19 deletions sync/internal_api/sync_backup_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "sync/internal_api/public/write_transaction.h"
#include "sync/syncable/directory.h"
#include "sync/syncable/mutable_entry.h"
#include "url/gurl.h"

namespace syncer {

Expand All @@ -19,25 +20,22 @@ SyncBackupManager::~SyncBackupManager() {
}

void SyncBackupManager::Init(
const base::FilePath& database_location,
const WeakHandle<JsEventHandler>& event_handler,
const std::string& sync_server_and_path,
int sync_server_port,
bool use_ssl,
scoped_ptr<HttpPostProviderFactory> post_factory,
const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
ExtensionsActivity* extensions_activity,
SyncManager::ChangeDelegate* change_delegate,
const SyncCredentials& credentials,
const std::string& invalidator_client_id,
const std::string& restored_key_for_bootstrapping,
const std::string& restored_keystore_key_for_bootstrapping,
InternalComponentsFactory* internal_components_factory,
Encryptor* encryptor,
scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler,
ReportUnrecoverableErrorFunction
report_unrecoverable_error_function,
CancelationSignal* cancelation_signal) {
const base::FilePath& database_location,
const WeakHandle<JsEventHandler>& event_handler,
const GURL& service_url,
scoped_ptr<HttpPostProviderFactory> post_factory,
const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
ExtensionsActivity* extensions_activity,
SyncManager::ChangeDelegate* change_delegate,
const SyncCredentials& credentials,
const std::string& invalidator_client_id,
const std::string& restored_key_for_bootstrapping,
const std::string& restored_keystore_key_for_bootstrapping,
InternalComponentsFactory* internal_components_factory,
Encryptor* encryptor,
scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler,
ReportUnrecoverableErrorFunction report_unrecoverable_error_function,
CancelationSignal* cancelation_signal) {
if (SyncRollbackManagerBase::InitInternal(
database_location,
internal_components_factory,
Expand Down
8 changes: 3 additions & 5 deletions sync/internal_api/sync_backup_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <set>

#include "sync/internal_api/sync_rollback_manager_base.h"
#include "url/gurl.h"

namespace syncer {

Expand All @@ -23,9 +24,7 @@ class SYNC_EXPORT_PRIVATE SyncBackupManager : public SyncRollbackManagerBase {
virtual void Init(
const base::FilePath& database_location,
const WeakHandle<JsEventHandler>& event_handler,
const std::string& sync_server_and_path,
int sync_server_port,
bool use_ssl,
const GURL& service_url,
scoped_ptr<HttpPostProviderFactory> post_factory,
const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
ExtensionsActivity* extensions_activity,
Expand All @@ -37,8 +36,7 @@ class SYNC_EXPORT_PRIVATE SyncBackupManager : public SyncRollbackManagerBase {
InternalComponentsFactory* internal_components_factory,
Encryptor* encryptor,
scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler,
ReportUnrecoverableErrorFunction
report_unrecoverable_error_function,
ReportUnrecoverableErrorFunction report_unrecoverable_error_function,
CancelationSignal* cancelation_signal) OVERRIDE;
virtual void SaveChanges() OVERRIDE;
virtual SyncStatus GetDetailedStatus() const OVERRIDE;
Expand Down
19 changes: 14 additions & 5 deletions sync/internal_api/sync_backup_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "sync/test/test_directory_backing_store.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

using ::testing::_;
using ::testing::Invoke;
Expand Down Expand Up @@ -61,11 +62,20 @@ class SyncBackupManagerTest : public syncer::SyncManager::Observer,
base::RunLoop run_loop;
manager->Init(temp_dir_.path(),
MakeWeakHandle(base::WeakPtr<JsEventHandler>()),
"", 0, true, scoped_ptr<HttpPostProviderFactory>().Pass(),
GURL("https://example.com/"),
scoped_ptr<HttpPostProviderFactory>().Pass(),
std::vector<scoped_refptr<ModelSafeWorker> >(),
NULL, NULL, SyncCredentials(), "", "", "", &factory,
NULL, scoped_ptr<UnrecoverableErrorHandler>().Pass(),
NULL, NULL);
NULL,
NULL,
SyncCredentials(),
"",
"",
"",
&factory,
NULL,
scoped_ptr<UnrecoverableErrorHandler>().Pass(),
NULL,
NULL);
loop_.PostTask(FROM_HERE, run_loop.QuitClosure());
run_loop.Run();
}
Expand Down Expand Up @@ -157,4 +167,3 @@ TEST_F(SyncBackupManagerTest, FailToInitialize) {
} // anonymous namespace

} // namespace syncer

13 changes: 8 additions & 5 deletions sync/internal_api/sync_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
using base::TimeDelta;
using sync_pb::GetUpdatesCallerInfo;

class GURL;

namespace syncer {

using sessions::SyncSessionContext;
Expand Down Expand Up @@ -304,9 +306,7 @@ void SyncManagerImpl::ConfigureSyncer(
void SyncManagerImpl::Init(
const base::FilePath& database_location,
const WeakHandle<JsEventHandler>& event_handler,
const std::string& sync_server_and_path,
int port,
bool use_ssl,
const GURL& service_url,
scoped_ptr<HttpPostProviderFactory> post_factory,
const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
ExtensionsActivity* extensions_activity,
Expand Down Expand Up @@ -384,8 +384,11 @@ void SyncManagerImpl::Init(
}

connection_manager_.reset(new SyncAPIServerConnectionManager(
sync_server_and_path, port, use_ssl,
post_factory.release(), cancelation_signal));
service_url.host() + service_url.path(),
service_url.EffectiveIntPort(),
service_url.SchemeIsSecure(),
post_factory.release(),
cancelation_signal));
connection_manager_->set_client_id(directory()->cache_guid());
connection_manager_->AddListener(this);

Expand Down
9 changes: 4 additions & 5 deletions sync/internal_api/sync_manager_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "sync/util/cryptographer.h"
#include "sync/util/time.h"

class GURL;

namespace syncer {

class ModelTypeRegistry;
Expand Down Expand Up @@ -69,9 +71,7 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl
virtual void Init(
const base::FilePath& database_location,
const WeakHandle<JsEventHandler>& event_handler,
const std::string& sync_server_and_path,
int sync_server_port,
bool use_ssl,
const GURL& service_url,
scoped_ptr<HttpPostProviderFactory> post_factory,
const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
ExtensionsActivity* extensions_activity,
Expand All @@ -83,8 +83,7 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl
InternalComponentsFactory* internal_components_factory,
Encryptor* encryptor,
scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler,
ReportUnrecoverableErrorFunction
report_unrecoverable_error_function,
ReportUnrecoverableErrorFunction report_unrecoverable_error_function,
CancelationSignal* cancelation_signal) OVERRIDE;
virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE;
virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
Expand Down
9 changes: 4 additions & 5 deletions sync/internal_api/sync_manager_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#include "sync/util/time.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

using base::ExpectDictStringValue;
using testing::_;
Expand Down Expand Up @@ -818,9 +819,7 @@ class SyncManagerTest : public testing::Test,
sync_manager_.Init(
temp_dir_.path(),
WeakHandle<JsEventHandler>(),
"bogus",
0,
false,
GURL("https://example.com/"),
scoped_ptr<HttpPostProviderFactory>(new TestHttpPostProviderFactory()),
workers,
extensions_activity_.get(),
Expand All @@ -831,8 +830,8 @@ class SyncManagerTest : public testing::Test,
std::string(), // bootstrap tokens
scoped_ptr<InternalComponentsFactory>(GetFactory()).get(),
&encryptor_,
scoped_ptr<UnrecoverableErrorHandler>(
new TestUnrecoverableErrorHandler).Pass(),
scoped_ptr<UnrecoverableErrorHandler>(new TestUnrecoverableErrorHandler)
.Pass(),
NULL,
&cancelation_signal_);

Expand Down
36 changes: 17 additions & 19 deletions sync/internal_api/sync_rollback_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "sync/internal_api/public/write_transaction.h"
#include "sync/syncable/directory.h"
#include "sync/syncable/mutable_entry.h"
#include "url/gurl.h"

namespace syncer {

Expand All @@ -22,25 +23,22 @@ SyncRollbackManager::~SyncRollbackManager() {
}

void SyncRollbackManager::Init(
const base::FilePath& database_location,
const WeakHandle<JsEventHandler>& event_handler,
const std::string& sync_server_and_path,
int sync_server_port,
bool use_ssl,
scoped_ptr<HttpPostProviderFactory> post_factory,
const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
ExtensionsActivity* extensions_activity,
SyncManager::ChangeDelegate* change_delegate,
const SyncCredentials& credentials,
const std::string& invalidator_client_id,
const std::string& restored_key_for_bootstrapping,
const std::string& restored_keystore_key_for_bootstrapping,
InternalComponentsFactory* internal_components_factory,
Encryptor* encryptor,
scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler,
ReportUnrecoverableErrorFunction
report_unrecoverable_error_function,
CancelationSignal* cancelation_signal) {
const base::FilePath& database_location,
const WeakHandle<JsEventHandler>& event_handler,
const GURL& service_url,
scoped_ptr<HttpPostProviderFactory> post_factory,
const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
ExtensionsActivity* extensions_activity,
SyncManager::ChangeDelegate* change_delegate,
const SyncCredentials& credentials,
const std::string& invalidator_client_id,
const std::string& restored_key_for_bootstrapping,
const std::string& restored_keystore_key_for_bootstrapping,
InternalComponentsFactory* internal_components_factory,
Encryptor* encryptor,
scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler,
ReportUnrecoverableErrorFunction report_unrecoverable_error_function,
CancelationSignal* cancelation_signal) {
if (SyncRollbackManagerBase::InitInternal(
database_location,
internal_components_factory,
Expand Down
9 changes: 4 additions & 5 deletions sync/internal_api/sync_rollback_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "sync/internal_api/sync_rollback_manager_base.h"

class GURL;

namespace syncer {

// SyncRollbackManager restores user's data to pre-sync state using backup
Expand All @@ -23,9 +25,7 @@ class SYNC_EXPORT_PRIVATE SyncRollbackManager : public SyncRollbackManagerBase {
virtual void Init(
const base::FilePath& database_location,
const WeakHandle<JsEventHandler>& event_handler,
const std::string& sync_server_and_path,
int sync_server_port,
bool use_ssl,
const GURL& service_url,
scoped_ptr<HttpPostProviderFactory> post_factory,
const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
ExtensionsActivity* extensions_activity,
Expand All @@ -37,8 +37,7 @@ class SYNC_EXPORT_PRIVATE SyncRollbackManager : public SyncRollbackManagerBase {
InternalComponentsFactory* internal_components_factory,
Encryptor* encryptor,
scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler,
ReportUnrecoverableErrorFunction
report_unrecoverable_error_function,
ReportUnrecoverableErrorFunction report_unrecoverable_error_function,
CancelationSignal* cancelation_signal) OVERRIDE;
virtual void StartSyncingNormally(
const ModelSafeRoutingInfo& routing_info) OVERRIDE;
Expand Down
Loading

0 comments on commit f3d8ca5

Please sign in to comment.