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

Unified Diff: chrome/browser/sessions/persistent_tab_restore_service.cc

Issue 1331173002: Eliminate BaseSessionServiceDelegateImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@persistent_tab_restore_service_client
Patch Set: Response to reviewv Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sessions/persistent_tab_restore_service.cc
diff --git a/chrome/browser/sessions/persistent_tab_restore_service.cc b/chrome/browser/sessions/persistent_tab_restore_service.cc
index f616ade59fa088fa06f8d96ae6b08b07cff1a7ea..6d770e0c36d9e5830cabeb4a0292e8e52a9f2c75 100644
--- a/chrome/browser/sessions/persistent_tab_restore_service.cc
+++ b/chrome/browser/sessions/persistent_tab_restore_service.cc
@@ -17,9 +17,9 @@
#include "base/stl_util.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/time/time.h"
-#include "chrome/browser/sessions/base_session_service_delegate_impl.h"
#include "components/sessions/base_session_service.h"
#include "components/sessions/base_session_service_commands.h"
+#include "components/sessions/base_session_service_delegate.h"
#include "components/sessions/core/session_constants.h"
#include "components/sessions/session_command.h"
#include "content/public/browser/session_storage_namespace.h"
@@ -112,16 +112,18 @@ const size_t kMaxEntries = TabRestoreServiceHelper::kMaxEntries;
// PersistentTabRestoreService::Delegate ---------------------------------------
// This restore service will create and own a BaseSessionService and implement
-// the required BaseSessionServiceDelegateImpl.
+// the required sessions::BaseSessionServiceDelegate.
class PersistentTabRestoreService::Delegate
- : public BaseSessionServiceDelegateImpl,
+ : public sessions::BaseSessionServiceDelegate,
public TabRestoreServiceHelper::Observer {
public:
explicit Delegate(sessions::TabRestoreServiceClient* client);
~Delegate() override;
- // BaseSessionServiceDelegateImpl:
+ // sessions::BaseSessionServiceDelegate:
+ base::SequencedWorkerPool* GetBlockingPool() override;
+ bool ShouldUseDelayedSave() override;
void OnWillSaveCommands() override;
// TabRestoreServiceHelper::Observer:
@@ -220,11 +222,11 @@ class PersistentTabRestoreService::Delegate
std::vector<TabRestoreService::Entry*>* entries);
private:
- scoped_ptr<sessions::BaseSessionService> base_session_service_;
-
// The associated client.
sessions::TabRestoreServiceClient* client_;
+ scoped_ptr<sessions::BaseSessionService> base_session_service_;
+
TabRestoreServiceHelper* tab_restore_service_helper_;
// The number of entries to write.
@@ -249,12 +251,11 @@ class PersistentTabRestoreService::Delegate
PersistentTabRestoreService::Delegate::Delegate(
sessions::TabRestoreServiceClient* client)
- : BaseSessionServiceDelegateImpl(true),
+ : client_(client),
base_session_service_(new sessions::BaseSessionService(
sessions::BaseSessionService::TAB_RESTORE,
- client->GetPathToSaveTo(),
+ client_->GetPathToSaveTo(),
this)),
- client_(client),
tab_restore_service_helper_(NULL),
entries_to_write_(0),
entries_written_(0),
@@ -262,6 +263,15 @@ PersistentTabRestoreService::Delegate::Delegate(
PersistentTabRestoreService::Delegate::~Delegate() {}
+base::SequencedWorkerPool*
+PersistentTabRestoreService::Delegate::GetBlockingPool() {
+ return client_->GetBlockingPool();
+}
+
+bool PersistentTabRestoreService::Delegate::ShouldUseDelayedSave() {
+ return true;
+}
+
void PersistentTabRestoreService::Delegate::OnWillSaveCommands() {
const Entries& entries = tab_restore_service_helper_->entries();
int to_write_count = std::min(entries_to_write_,
@@ -434,7 +444,7 @@ void PersistentTabRestoreService::Delegate::ScheduleCommandsForTab(
i >= 0 &&
valid_count_before_selected < sessions::gMaxPersistNavigationCount;
--i) {
- if (ShouldTrackEntry(navigations[i].virtual_url())) {
+ if (client_->ShouldTrackURLForRestore(navigations[i].virtual_url())) {
first_index_to_persist = i;
valid_count_before_selected++;
}
@@ -474,7 +484,7 @@ void PersistentTabRestoreService::Delegate::ScheduleCommandsForTab(
for (int i = first_index_to_persist, wrote_count = 0;
wrote_count < 2 * sessions::gMaxPersistNavigationCount && i < max_index;
++i) {
- if (ShouldTrackEntry(navigations[i].virtual_url())) {
+ if (client_->ShouldTrackURLForRestore(navigations[i].virtual_url())) {
base_session_service_->ScheduleCommand(
CreateUpdateTabNavigationCommand(kCommandUpdateTabNavigation,
tab.id,
@@ -541,9 +551,10 @@ int PersistentTabRestoreService::Delegate::GetSelectedNavigationIndexToPersist(
int max_index = static_cast<int>(navigations.size());
// Find the first navigation to persist. We won't persist the selected
- // navigation if ShouldTrackEntry returns false.
+ // navigation if client_->ShouldTrackURLForRestore returns false.
while (selected_index >= 0 &&
- !ShouldTrackEntry(navigations[selected_index].virtual_url())) {
+ !client_->ShouldTrackURLForRestore(
+ navigations[selected_index].virtual_url())) {
selected_index--;
}
@@ -553,7 +564,8 @@ int PersistentTabRestoreService::Delegate::GetSelectedNavigationIndexToPersist(
// Couldn't find a navigation to persist going back, go forward.
selected_index = tab.current_navigation_index + 1;
while (selected_index < max_index &&
- !ShouldTrackEntry(navigations[selected_index].virtual_url())) {
+ !client_->ShouldTrackURLForRestore(
+ navigations[selected_index].virtual_url())) {
selected_index++;
}
« no previous file with comments | « chrome/browser/sessions/chrome_tab_restore_service_client.cc ('k') | chrome/browser/sessions/session_common_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698