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 {
~SyncSessionsClientImpl() override {}
// SyncSessionsClient implementation.
bookmarks::BookmarkModel* GetBookmarkModel() override {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
return BookmarkModelFactory::GetForBrowserContext(profile_);
}
favicon::FaviconService* GetFaviconService() override {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
return FaviconServiceFactory::GetForProfile(
......
......@@ -77,14 +77,6 @@ class MockAppMenuModel : public AppMenuModel {
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 {
public:
BrowserRemovedObserver() { BrowserList::AddObserver(this); }
......@@ -132,8 +124,7 @@ class AppMenuControllerTest : public CocoaProfileTest {
ProfileSyncServiceFactory::GetForProfile(profile())
->GetSyncClient()
->GetSyncSessionsClient(),
sync_prefs_.get(), local_device_.get(), &dummy_router_,
base::Closure());
sync_prefs_.get(), local_device_.get(), base::Closure());
manager_->MergeDataAndStartSyncing(
syncer::SESSIONS, syncer::SyncDataList(),
......@@ -190,7 +181,6 @@ class AppMenuControllerTest : public CocoaProfileTest {
private:
std::unique_ptr<syncer::LocalDeviceInfoProviderMock> local_device_;
DummyRouter dummy_router_;
std::unique_ptr<syncer::SyncPrefs> sync_prefs_;
browser_sync::ProfileSyncServiceMock* mock_sync_service_ = nullptr;
std::unique_ptr<sync_sessions::SessionsSyncManager> manager_;
......
......@@ -113,14 +113,6 @@ class TestRecentTabsMenuModelDelegate : public ui::MenuModelDelegate {
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 {
public:
FakeSyncServiceObserverList() {}
......@@ -185,7 +177,7 @@ class RecentTabsSubMenuModelTest
manager_ = std::make_unique<sync_sessions::SessionsSyncManager>(
mock_sync_service_->GetSyncClient()->GetSyncSessionsClient(),
sync_prefs_.get(), local_device_.get(), &dummy_router_,
sync_prefs_.get(), local_device_.get(),
base::Bind(&FakeSyncServiceObserverList::NotifyForeignSessionUpdated,
base::Unretained(&fake_sync_service_observer_list_)));
......@@ -256,7 +248,6 @@ class RecentTabsSubMenuModelTest
will_create_browser_context_services_subscription_;
std::unique_ptr<syncer::LocalDeviceInfoProviderMock> local_device_;
DummyRouter dummy_router_;
std::unique_ptr<syncer::SyncPrefs> sync_prefs_;
FakeSyncServiceObserverList fake_sync_service_observer_list_;
browser_sync::ProfileSyncServiceMock* mock_sync_service_ = nullptr;
......
......@@ -224,8 +224,6 @@ void ProfileSyncService::Initialize() {
base::Bind(&ProfileSyncService::CanEngineStart, base::Unretained(this)),
base::Bind(&ProfileSyncService::StartUpSlowEngineComponents,
weak_factory_.GetWeakPtr()));
sync_sessions::LocalSessionEventRouter* router =
sync_client_->GetSyncSessionsClient()->GetLocalSessionEventRouter();
local_device_ = sync_client_->GetSyncApiComponentFactory()
->CreateLocalDeviceInfoProvider();
sync_stopped_reporter_ = std::make_unique<syncer::SyncStoppedReporter>(
......@@ -233,7 +231,6 @@ void ProfileSyncService::Initialize() {
url_request_context_, syncer::SyncStoppedReporter::ResultCallback());
sessions_sync_manager_ = std::make_unique<SessionsSyncManager>(
sync_client_->GetSyncSessionsClient(), &sync_prefs_, local_device_.get(),
router,
base::Bind(&ProfileSyncService::NotifyForeignSessionUpdated,
sync_enabled_weak_factory_.GetWeakPtr()));
......
......@@ -17,7 +17,6 @@ class MockSyncSessionsClient : public SyncSessionsClient {
MockSyncSessionsClient();
~MockSyncSessionsClient() override;
MOCK_METHOD0(GetBookmarkModel, bookmarks::BookmarkModel*());
MOCK_METHOD0(GetFaviconService, favicon::FaviconService*());
MOCK_METHOD0(GetHistoryService, history::HistoryService*());
MOCK_CONST_METHOD1(ShouldSyncURL, bool(const GURL& url));
......
......@@ -20,6 +20,7 @@
#include "components/sync/model/sync_error_factory.h"
#include "components/sync/model/sync_merge_result.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/tab_node_pool.h"
......@@ -137,7 +138,6 @@ SessionsSyncManager::SessionsSyncManager(
sync_sessions::SyncSessionsClient* sessions_client,
syncer::SyncPrefs* sync_prefs,
LocalDeviceInfoProvider* local_device,
LocalSessionEventRouter* router,
const base::RepeatingClosure& sessions_updated_callback)
: sessions_client_(sessions_client),
session_tracker_(sessions_client),
......@@ -153,9 +153,7 @@ SessionsSyncManager::SessionsSyncManager(
local_tab_pool_out_of_sync_(true),
sync_prefs_(sync_prefs),
local_device_(local_device),
local_session_header_node_id_(TabNodePool::kInvalidTabNodeID),
stale_session_threshold_days_(kDefaultStaleSessionThresholdDays),
local_event_router_(router),
sessions_updated_callback_(sessions_updated_callback) {}
SessionsSyncManager::~SessionsSyncManager() {}
......@@ -201,8 +199,6 @@ syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing(
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
// a conveniently safe time to assert sync is ready and the cache_guid is
// initialized.
......@@ -245,7 +241,8 @@ syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing(
merge_result.set_error(sync_processor_->ProcessSyncChanges(
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;
}
......@@ -263,7 +260,7 @@ bool SessionsSyncManager::RebuildAssociations() {
}
void SessionsSyncManager::StopSyncing(syncer::ModelType type) {
local_event_router_->Stop();
sessions_client_->GetLocalSessionEventRouter()->Stop();
local_session_event_handler_.reset();
if (sync_processor_.get() && lost_navigations_recorder_.get()) {
sync_processor_->RemoveLocalChangeObserver(
......@@ -275,7 +272,6 @@ void SessionsSyncManager::StopSyncing(syncer::ModelType type) {
session_tracker_.Clear();
current_machine_tag_.clear();
current_session_name_.clear();
local_session_header_node_id_ = TabNodePool::kInvalidTabNodeID;
}
syncer::SyncDataList SessionsSyncManager::GetAllSyncData(
......
......@@ -26,7 +26,6 @@
#include "components/sync/model/syncable_service.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_router.h"
#include "components/sync_sessions/lost_navigations_recorder.h"
#include "components/sync_sessions/open_tabs_ui_delegate_impl.h"
#include "components/sync_sessions/sessions_global_id_mapper.h"
......@@ -58,7 +57,6 @@ class SessionsSyncManager : public syncer::SyncableService,
SessionsSyncManager(SyncSessionsClient* sessions_client,
syncer::SyncPrefs* sync_prefs,
syncer::LocalDeviceInfoProvider* local_device,
LocalSessionEventRouter* router,
const base::RepeatingClosure& sessions_updated_callback);
~SessionsSyncManager() override;
......@@ -199,16 +197,10 @@ class SessionsSyncManager : public syncer::SyncableService,
// User-visible machine name to populate header.
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
// stale and a candidate for garbage collection.
int stale_session_threshold_days_;
LocalSessionEventRouter* local_event_router_;
std::unique_ptr<sync_sessions::LostNavigationsRecorder>
lost_navigations_recorder_;
......
......@@ -141,7 +141,7 @@ class TestSyncChangeProcessor : public syncer::SyncChangeProcessor {
}
SyncDataList GetAllSyncData(syncer::ModelType type) const override {
return sync_data_to_return_;
return SyncDataList();
}
void AddLocalChangeObserver(syncer::LocalChangeObserver* observer) override {
......@@ -160,14 +160,9 @@ class TestSyncChangeProcessor : public syncer::SyncChangeProcessor {
void FailProcessSyncChangesWith(const SyncError& error) { error_ = error; }
void SetSyncDataToReturn(const SyncDataList& data) {
sync_data_to_return_ = data;
}
private:
SyncError error_;
SyncChangeList* output_;
SyncDataList sync_data_to_return_;
base::ObserverList<syncer::LocalChangeObserver> local_change_observers_;
};
......@@ -178,6 +173,8 @@ class SessionsSyncManagerTest : public testing::Test {
void SetUp() override {
ON_CALL(mock_sync_sessions_client_, GetSyncedWindowDelegatesGetter())
.WillByDefault(testing::Return(&window_getter_));
ON_CALL(mock_sync_sessions_client_, GetLocalSessionEventRouter())
.WillByDefault(testing::Return(window_getter_.router()));
local_device_ = std::make_unique<LocalDeviceInfoProviderMock>(
"cache_guid", "Wayne Gretzky's Hacking Box", "Chromium 10k",
......@@ -187,7 +184,6 @@ class SessionsSyncManagerTest : public testing::Test {
std::make_unique<syncer::SyncPrefs>(sync_client_->GetPrefService());
manager_ = std::make_unique<SessionsSyncManager>(
&mock_sync_sessions_client_, sync_prefs_.get(), local_device_.get(),
window_getter_.router(),
base::Bind(&SessionNotificationObserver::NotifyOfUpdate,
base::Unretained(&observer_)));
}
......@@ -233,10 +229,6 @@ class SessionsSyncManagerTest : public testing::Test {
FROM_HERE, SyncError::DATATYPE_ERROR, "Error", syncer::SESSIONS));
}
void SetSyncData(const SyncDataList& data) {
test_processor_->SetSyncDataToReturn(data);
}
void VerifyLocalHeaderChange(const SyncChange& change,
int num_windows,
int num_tabs) {
......
......@@ -11,10 +11,6 @@
class GURL;
namespace bookmarks {
class BookmarkModel;
}
namespace favicon {
class FaviconService;
}
......@@ -36,7 +32,6 @@ class SyncSessionsClient {
virtual ~SyncSessionsClient();
// Getters for services that sessions depends on.
virtual bookmarks::BookmarkModel* GetBookmarkModel() = 0;
virtual favicon::FaviconService* GetFaviconService() = 0;
virtual history::HistoryService* GetHistoryService() = 0;
......
......@@ -91,11 +91,6 @@ class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient {
~SyncSessionsClientImpl() override {}
// SyncSessionsClient implementation.
bookmarks::BookmarkModel* GetBookmarkModel() override {
DCHECK_CURRENTLY_ON(web::WebThread::UI);
return ios::BookmarkModelFactory::GetForBrowserState(browser_state_);
}
favicon::FaviconService* GetFaviconService() override {
DCHECK_CURRENTLY_ON(web::WebThread::UI);
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