Commit acf85687 authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Remove unused session sync code

Various unused or redundant APIs are removed trivially.

Bug: 681921
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I6e5b85b69a002b1037e1ee4f778f29af31af1525
Reviewed-on: https://chromium-review.googlesource.com/952922Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541752}
parent 7b72d81c
...@@ -156,10 +156,6 @@ class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient { ...@@ -156,10 +156,6 @@ class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient {
~SyncSessionsClientImpl() override {} ~SyncSessionsClientImpl() override {}
// SyncSessionsClient implementation. // SyncSessionsClient implementation.
bookmarks::BookmarkModel* GetBookmarkModel() override {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
return BookmarkModelFactory::GetForBrowserContext(profile_);
}
favicon::FaviconService* GetFaviconService() override { favicon::FaviconService* GetFaviconService() override {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
return FaviconServiceFactory::GetForProfile( return FaviconServiceFactory::GetForProfile(
......
...@@ -77,14 +77,6 @@ class MockAppMenuModel : public AppMenuModel { ...@@ -77,14 +77,6 @@ class MockAppMenuModel : public AppMenuModel {
MOCK_METHOD2(ExecuteCommand, void(int command_id, int event_flags)); MOCK_METHOD2(ExecuteCommand, void(int command_id, int event_flags));
}; };
class DummyRouter : public sync_sessions::LocalSessionEventRouter {
public:
~DummyRouter() override {}
void StartRoutingTo(
sync_sessions::LocalSessionEventHandler* handler) override {}
void Stop() override {}
};
class BrowserRemovedObserver : public BrowserListObserver { class BrowserRemovedObserver : public BrowserListObserver {
public: public:
BrowserRemovedObserver() { BrowserList::AddObserver(this); } BrowserRemovedObserver() { BrowserList::AddObserver(this); }
...@@ -132,8 +124,7 @@ class AppMenuControllerTest : public CocoaProfileTest { ...@@ -132,8 +124,7 @@ class AppMenuControllerTest : public CocoaProfileTest {
ProfileSyncServiceFactory::GetForProfile(profile()) ProfileSyncServiceFactory::GetForProfile(profile())
->GetSyncClient() ->GetSyncClient()
->GetSyncSessionsClient(), ->GetSyncSessionsClient(),
sync_prefs_.get(), local_device_.get(), &dummy_router_, sync_prefs_.get(), local_device_.get(), base::Closure());
base::Closure());
manager_->MergeDataAndStartSyncing( manager_->MergeDataAndStartSyncing(
syncer::SESSIONS, syncer::SyncDataList(), syncer::SESSIONS, syncer::SyncDataList(),
...@@ -190,7 +181,6 @@ class AppMenuControllerTest : public CocoaProfileTest { ...@@ -190,7 +181,6 @@ class AppMenuControllerTest : public CocoaProfileTest {
private: private:
std::unique_ptr<syncer::LocalDeviceInfoProviderMock> local_device_; std::unique_ptr<syncer::LocalDeviceInfoProviderMock> local_device_;
DummyRouter dummy_router_;
std::unique_ptr<syncer::SyncPrefs> sync_prefs_; std::unique_ptr<syncer::SyncPrefs> sync_prefs_;
browser_sync::ProfileSyncServiceMock* mock_sync_service_ = nullptr; browser_sync::ProfileSyncServiceMock* mock_sync_service_ = nullptr;
std::unique_ptr<sync_sessions::SessionsSyncManager> manager_; std::unique_ptr<sync_sessions::SessionsSyncManager> manager_;
......
...@@ -113,14 +113,6 @@ class TestRecentTabsMenuModelDelegate : public ui::MenuModelDelegate { ...@@ -113,14 +113,6 @@ class TestRecentTabsMenuModelDelegate : public ui::MenuModelDelegate {
DISALLOW_COPY_AND_ASSIGN(TestRecentTabsMenuModelDelegate); DISALLOW_COPY_AND_ASSIGN(TestRecentTabsMenuModelDelegate);
}; };
class DummyRouter : public sync_sessions::LocalSessionEventRouter {
public:
~DummyRouter() override {}
void StartRoutingTo(
sync_sessions::LocalSessionEventHandler* handler) override {}
void Stop() override {}
};
class FakeSyncServiceObserverList { class FakeSyncServiceObserverList {
public: public:
FakeSyncServiceObserverList() {} FakeSyncServiceObserverList() {}
...@@ -185,7 +177,7 @@ class RecentTabsSubMenuModelTest ...@@ -185,7 +177,7 @@ class RecentTabsSubMenuModelTest
manager_ = std::make_unique<sync_sessions::SessionsSyncManager>( manager_ = std::make_unique<sync_sessions::SessionsSyncManager>(
mock_sync_service_->GetSyncClient()->GetSyncSessionsClient(), mock_sync_service_->GetSyncClient()->GetSyncSessionsClient(),
sync_prefs_.get(), local_device_.get(), &dummy_router_, sync_prefs_.get(), local_device_.get(),
base::Bind(&FakeSyncServiceObserverList::NotifyForeignSessionUpdated, base::Bind(&FakeSyncServiceObserverList::NotifyForeignSessionUpdated,
base::Unretained(&fake_sync_service_observer_list_))); base::Unretained(&fake_sync_service_observer_list_)));
...@@ -256,7 +248,6 @@ class RecentTabsSubMenuModelTest ...@@ -256,7 +248,6 @@ class RecentTabsSubMenuModelTest
will_create_browser_context_services_subscription_; will_create_browser_context_services_subscription_;
std::unique_ptr<syncer::LocalDeviceInfoProviderMock> local_device_; std::unique_ptr<syncer::LocalDeviceInfoProviderMock> local_device_;
DummyRouter dummy_router_;
std::unique_ptr<syncer::SyncPrefs> sync_prefs_; std::unique_ptr<syncer::SyncPrefs> sync_prefs_;
FakeSyncServiceObserverList fake_sync_service_observer_list_; FakeSyncServiceObserverList fake_sync_service_observer_list_;
browser_sync::ProfileSyncServiceMock* mock_sync_service_ = nullptr; browser_sync::ProfileSyncServiceMock* mock_sync_service_ = nullptr;
......
...@@ -224,8 +224,6 @@ void ProfileSyncService::Initialize() { ...@@ -224,8 +224,6 @@ void ProfileSyncService::Initialize() {
base::Bind(&ProfileSyncService::CanEngineStart, base::Unretained(this)), base::Bind(&ProfileSyncService::CanEngineStart, base::Unretained(this)),
base::Bind(&ProfileSyncService::StartUpSlowEngineComponents, base::Bind(&ProfileSyncService::StartUpSlowEngineComponents,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
sync_sessions::LocalSessionEventRouter* router =
sync_client_->GetSyncSessionsClient()->GetLocalSessionEventRouter();
local_device_ = sync_client_->GetSyncApiComponentFactory() local_device_ = sync_client_->GetSyncApiComponentFactory()
->CreateLocalDeviceInfoProvider(); ->CreateLocalDeviceInfoProvider();
sync_stopped_reporter_ = std::make_unique<syncer::SyncStoppedReporter>( sync_stopped_reporter_ = std::make_unique<syncer::SyncStoppedReporter>(
...@@ -233,7 +231,6 @@ void ProfileSyncService::Initialize() { ...@@ -233,7 +231,6 @@ void ProfileSyncService::Initialize() {
url_request_context_, syncer::SyncStoppedReporter::ResultCallback()); url_request_context_, syncer::SyncStoppedReporter::ResultCallback());
sessions_sync_manager_ = std::make_unique<SessionsSyncManager>( sessions_sync_manager_ = std::make_unique<SessionsSyncManager>(
sync_client_->GetSyncSessionsClient(), &sync_prefs_, local_device_.get(), sync_client_->GetSyncSessionsClient(), &sync_prefs_, local_device_.get(),
router,
base::Bind(&ProfileSyncService::NotifyForeignSessionUpdated, base::Bind(&ProfileSyncService::NotifyForeignSessionUpdated,
sync_enabled_weak_factory_.GetWeakPtr())); sync_enabled_weak_factory_.GetWeakPtr()));
......
...@@ -17,7 +17,6 @@ class MockSyncSessionsClient : public SyncSessionsClient { ...@@ -17,7 +17,6 @@ class MockSyncSessionsClient : public SyncSessionsClient {
MockSyncSessionsClient(); MockSyncSessionsClient();
~MockSyncSessionsClient() override; ~MockSyncSessionsClient() override;
MOCK_METHOD0(GetBookmarkModel, bookmarks::BookmarkModel*());
MOCK_METHOD0(GetFaviconService, favicon::FaviconService*()); MOCK_METHOD0(GetFaviconService, favicon::FaviconService*());
MOCK_METHOD0(GetHistoryService, history::HistoryService*()); MOCK_METHOD0(GetHistoryService, history::HistoryService*());
MOCK_CONST_METHOD1(ShouldSyncURL, bool(const GURL& url)); MOCK_CONST_METHOD1(ShouldSyncURL, bool(const GURL& url));
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "components/sync/model/sync_error_factory.h" #include "components/sync/model/sync_error_factory.h"
#include "components/sync/model/sync_merge_result.h" #include "components/sync/model/sync_merge_result.h"
#include "components/sync/model/time.h" #include "components/sync/model/time.h"
#include "components/sync_sessions/local_session_event_router.h"
#include "components/sync_sessions/sync_sessions_client.h" #include "components/sync_sessions/sync_sessions_client.h"
#include "components/sync_sessions/tab_node_pool.h" #include "components/sync_sessions/tab_node_pool.h"
...@@ -137,7 +138,6 @@ SessionsSyncManager::SessionsSyncManager( ...@@ -137,7 +138,6 @@ SessionsSyncManager::SessionsSyncManager(
sync_sessions::SyncSessionsClient* sessions_client, sync_sessions::SyncSessionsClient* sessions_client,
syncer::SyncPrefs* sync_prefs, syncer::SyncPrefs* sync_prefs,
LocalDeviceInfoProvider* local_device, LocalDeviceInfoProvider* local_device,
LocalSessionEventRouter* router,
const base::RepeatingClosure& sessions_updated_callback) const base::RepeatingClosure& sessions_updated_callback)
: sessions_client_(sessions_client), : sessions_client_(sessions_client),
session_tracker_(sessions_client), session_tracker_(sessions_client),
...@@ -153,9 +153,7 @@ SessionsSyncManager::SessionsSyncManager( ...@@ -153,9 +153,7 @@ SessionsSyncManager::SessionsSyncManager(
local_tab_pool_out_of_sync_(true), local_tab_pool_out_of_sync_(true),
sync_prefs_(sync_prefs), sync_prefs_(sync_prefs),
local_device_(local_device), local_device_(local_device),
local_session_header_node_id_(TabNodePool::kInvalidTabNodeID),
stale_session_threshold_days_(kDefaultStaleSessionThresholdDays), stale_session_threshold_days_(kDefaultStaleSessionThresholdDays),
local_event_router_(router),
sessions_updated_callback_(sessions_updated_callback) {} sessions_updated_callback_(sessions_updated_callback) {}
SessionsSyncManager::~SessionsSyncManager() {} SessionsSyncManager::~SessionsSyncManager() {}
...@@ -201,8 +199,6 @@ syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing( ...@@ -201,8 +199,6 @@ syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing(
sync_processor_->AddLocalChangeObserver(lost_navigations_recorder_.get()); sync_processor_->AddLocalChangeObserver(lost_navigations_recorder_.get());
} }
local_session_header_node_id_ = TabNodePool::kInvalidTabNodeID;
// Make sure we have a machine tag. We do this now (versus earlier) as it's // Make sure we have a machine tag. We do this now (versus earlier) as it's
// a conveniently safe time to assert sync is ready and the cache_guid is // a conveniently safe time to assert sync is ready and the cache_guid is
// initialized. // initialized.
...@@ -245,7 +241,8 @@ syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing( ...@@ -245,7 +241,8 @@ syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing(
merge_result.set_error(sync_processor_->ProcessSyncChanges( merge_result.set_error(sync_processor_->ProcessSyncChanges(
FROM_HERE, *batch.sync_change_list())); FROM_HERE, *batch.sync_change_list()));
local_event_router_->StartRoutingTo(local_session_event_handler_.get()); sessions_client_->GetLocalSessionEventRouter()->StartRoutingTo(
local_session_event_handler_.get());
return merge_result; return merge_result;
} }
...@@ -263,7 +260,7 @@ bool SessionsSyncManager::RebuildAssociations() { ...@@ -263,7 +260,7 @@ bool SessionsSyncManager::RebuildAssociations() {
} }
void SessionsSyncManager::StopSyncing(syncer::ModelType type) { void SessionsSyncManager::StopSyncing(syncer::ModelType type) {
local_event_router_->Stop(); sessions_client_->GetLocalSessionEventRouter()->Stop();
local_session_event_handler_.reset(); local_session_event_handler_.reset();
if (sync_processor_.get() && lost_navigations_recorder_.get()) { if (sync_processor_.get() && lost_navigations_recorder_.get()) {
sync_processor_->RemoveLocalChangeObserver( sync_processor_->RemoveLocalChangeObserver(
...@@ -275,7 +272,6 @@ void SessionsSyncManager::StopSyncing(syncer::ModelType type) { ...@@ -275,7 +272,6 @@ void SessionsSyncManager::StopSyncing(syncer::ModelType type) {
session_tracker_.Clear(); session_tracker_.Clear();
current_machine_tag_.clear(); current_machine_tag_.clear();
current_session_name_.clear(); current_session_name_.clear();
local_session_header_node_id_ = TabNodePool::kInvalidTabNodeID;
} }
syncer::SyncDataList SessionsSyncManager::GetAllSyncData( syncer::SyncDataList SessionsSyncManager::GetAllSyncData(
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "components/sync/model/syncable_service.h" #include "components/sync/model/syncable_service.h"
#include "components/sync_sessions/favicon_cache.h" #include "components/sync_sessions/favicon_cache.h"
#include "components/sync_sessions/local_session_event_handler_impl.h" #include "components/sync_sessions/local_session_event_handler_impl.h"
#include "components/sync_sessions/local_session_event_router.h"
#include "components/sync_sessions/lost_navigations_recorder.h" #include "components/sync_sessions/lost_navigations_recorder.h"
#include "components/sync_sessions/open_tabs_ui_delegate_impl.h" #include "components/sync_sessions/open_tabs_ui_delegate_impl.h"
#include "components/sync_sessions/sessions_global_id_mapper.h" #include "components/sync_sessions/sessions_global_id_mapper.h"
...@@ -58,7 +57,6 @@ class SessionsSyncManager : public syncer::SyncableService, ...@@ -58,7 +57,6 @@ class SessionsSyncManager : public syncer::SyncableService,
SessionsSyncManager(SyncSessionsClient* sessions_client, SessionsSyncManager(SyncSessionsClient* sessions_client,
syncer::SyncPrefs* sync_prefs, syncer::SyncPrefs* sync_prefs,
syncer::LocalDeviceInfoProvider* local_device, syncer::LocalDeviceInfoProvider* local_device,
LocalSessionEventRouter* router,
const base::RepeatingClosure& sessions_updated_callback); const base::RepeatingClosure& sessions_updated_callback);
~SessionsSyncManager() override; ~SessionsSyncManager() override;
...@@ -199,16 +197,10 @@ class SessionsSyncManager : public syncer::SyncableService, ...@@ -199,16 +197,10 @@ class SessionsSyncManager : public syncer::SyncableService,
// User-visible machine name to populate header. // User-visible machine name to populate header.
std::string current_session_name_; std::string current_session_name_;
// SyncID for the sync node containing all the window information for this
// client.
int local_session_header_node_id_;
// Number of days without activity after which we consider a session to be // Number of days without activity after which we consider a session to be
// stale and a candidate for garbage collection. // stale and a candidate for garbage collection.
int stale_session_threshold_days_; int stale_session_threshold_days_;
LocalSessionEventRouter* local_event_router_;
std::unique_ptr<sync_sessions::LostNavigationsRecorder> std::unique_ptr<sync_sessions::LostNavigationsRecorder>
lost_navigations_recorder_; lost_navigations_recorder_;
......
...@@ -141,7 +141,7 @@ class TestSyncChangeProcessor : public syncer::SyncChangeProcessor { ...@@ -141,7 +141,7 @@ class TestSyncChangeProcessor : public syncer::SyncChangeProcessor {
} }
SyncDataList GetAllSyncData(syncer::ModelType type) const override { SyncDataList GetAllSyncData(syncer::ModelType type) const override {
return sync_data_to_return_; return SyncDataList();
} }
void AddLocalChangeObserver(syncer::LocalChangeObserver* observer) override { void AddLocalChangeObserver(syncer::LocalChangeObserver* observer) override {
...@@ -160,14 +160,9 @@ class TestSyncChangeProcessor : public syncer::SyncChangeProcessor { ...@@ -160,14 +160,9 @@ class TestSyncChangeProcessor : public syncer::SyncChangeProcessor {
void FailProcessSyncChangesWith(const SyncError& error) { error_ = error; } void FailProcessSyncChangesWith(const SyncError& error) { error_ = error; }
void SetSyncDataToReturn(const SyncDataList& data) {
sync_data_to_return_ = data;
}
private: private:
SyncError error_; SyncError error_;
SyncChangeList* output_; SyncChangeList* output_;
SyncDataList sync_data_to_return_;
base::ObserverList<syncer::LocalChangeObserver> local_change_observers_; base::ObserverList<syncer::LocalChangeObserver> local_change_observers_;
}; };
...@@ -178,6 +173,8 @@ class SessionsSyncManagerTest : public testing::Test { ...@@ -178,6 +173,8 @@ class SessionsSyncManagerTest : public testing::Test {
void SetUp() override { void SetUp() override {
ON_CALL(mock_sync_sessions_client_, GetSyncedWindowDelegatesGetter()) ON_CALL(mock_sync_sessions_client_, GetSyncedWindowDelegatesGetter())
.WillByDefault(testing::Return(&window_getter_)); .WillByDefault(testing::Return(&window_getter_));
ON_CALL(mock_sync_sessions_client_, GetLocalSessionEventRouter())
.WillByDefault(testing::Return(window_getter_.router()));
local_device_ = std::make_unique<LocalDeviceInfoProviderMock>( local_device_ = std::make_unique<LocalDeviceInfoProviderMock>(
"cache_guid", "Wayne Gretzky's Hacking Box", "Chromium 10k", "cache_guid", "Wayne Gretzky's Hacking Box", "Chromium 10k",
...@@ -187,7 +184,6 @@ class SessionsSyncManagerTest : public testing::Test { ...@@ -187,7 +184,6 @@ class SessionsSyncManagerTest : public testing::Test {
std::make_unique<syncer::SyncPrefs>(sync_client_->GetPrefService()); std::make_unique<syncer::SyncPrefs>(sync_client_->GetPrefService());
manager_ = std::make_unique<SessionsSyncManager>( manager_ = std::make_unique<SessionsSyncManager>(
&mock_sync_sessions_client_, sync_prefs_.get(), local_device_.get(), &mock_sync_sessions_client_, sync_prefs_.get(), local_device_.get(),
window_getter_.router(),
base::Bind(&SessionNotificationObserver::NotifyOfUpdate, base::Bind(&SessionNotificationObserver::NotifyOfUpdate,
base::Unretained(&observer_))); base::Unretained(&observer_)));
} }
...@@ -233,10 +229,6 @@ class SessionsSyncManagerTest : public testing::Test { ...@@ -233,10 +229,6 @@ class SessionsSyncManagerTest : public testing::Test {
FROM_HERE, SyncError::DATATYPE_ERROR, "Error", syncer::SESSIONS)); FROM_HERE, SyncError::DATATYPE_ERROR, "Error", syncer::SESSIONS));
} }
void SetSyncData(const SyncDataList& data) {
test_processor_->SetSyncDataToReturn(data);
}
void VerifyLocalHeaderChange(const SyncChange& change, void VerifyLocalHeaderChange(const SyncChange& change,
int num_windows, int num_windows,
int num_tabs) { int num_tabs) {
......
...@@ -11,10 +11,6 @@ ...@@ -11,10 +11,6 @@
class GURL; class GURL;
namespace bookmarks {
class BookmarkModel;
}
namespace favicon { namespace favicon {
class FaviconService; class FaviconService;
} }
...@@ -36,7 +32,6 @@ class SyncSessionsClient { ...@@ -36,7 +32,6 @@ class SyncSessionsClient {
virtual ~SyncSessionsClient(); virtual ~SyncSessionsClient();
// Getters for services that sessions depends on. // Getters for services that sessions depends on.
virtual bookmarks::BookmarkModel* GetBookmarkModel() = 0;
virtual favicon::FaviconService* GetFaviconService() = 0; virtual favicon::FaviconService* GetFaviconService() = 0;
virtual history::HistoryService* GetHistoryService() = 0; virtual history::HistoryService* GetHistoryService() = 0;
......
...@@ -91,11 +91,6 @@ class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient { ...@@ -91,11 +91,6 @@ class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient {
~SyncSessionsClientImpl() override {} ~SyncSessionsClientImpl() override {}
// SyncSessionsClient implementation. // SyncSessionsClient implementation.
bookmarks::BookmarkModel* GetBookmarkModel() override {
DCHECK_CURRENTLY_ON(web::WebThread::UI);
return ios::BookmarkModelFactory::GetForBrowserState(browser_state_);
}
favicon::FaviconService* GetFaviconService() override { favicon::FaviconService* GetFaviconService() override {
DCHECK_CURRENTLY_ON(web::WebThread::UI); DCHECK_CURRENTLY_ON(web::WebThread::UI);
return ios::FaviconServiceFactory::GetForBrowserState( return ios::FaviconServiceFactory::GetForBrowserState(
......
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