summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-28 18:57:31 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-28 18:57:31 +0000
commitf9ffb8936730abffbb13f6fd7f4d492f028e3019 (patch)
tree17fd0c6b2c42fd7415479e7cc227298d49630db7
parent774e06129e52ac236d8cfe8103152d8a3aa1c305 (diff)
downloadchromium_src-f9ffb8936730abffbb13f6fd7f4d492f028e3019.zip
chromium_src-f9ffb8936730abffbb13f6fd7f4d492f028e3019.tar.gz
chromium_src-f9ffb8936730abffbb13f6fd7f4d492f028e3019.tar.bz2
base::Bind: Convert SessionService::SessionCallback.
BUG=none TEST=none R=csilv@chromium.org Review URL: http://codereview.chromium.org/8714002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111735 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sessions/session_restore.cc8
-rw-r--r--chrome/browser/sessions/session_service.cc13
-rw-r--r--chrome/browser/sessions/session_service.h8
-rw-r--r--chrome/browser/sessions/session_service_unittest.cc8
-rw-r--r--chrome/browser/sessions/tab_restore_service.cc6
5 files changed, 25 insertions, 18 deletions
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index eefb94b..5b3d683 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -9,6 +9,8 @@
#include <set>
#include <vector>
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
@@ -424,9 +426,9 @@ class SessionRestoreImpl : public content::NotificationObserver {
SessionService* session_service =
SessionServiceFactory::GetForProfile(profile_);
DCHECK(session_service);
- SessionService::SessionCallback* callback =
- NewCallback(this, &SessionRestoreImpl::OnGotSession);
- session_service->GetLastSession(&request_consumer_, callback);
+ session_service->GetLastSession(
+ &request_consumer_,
+ base::Bind(&SessionRestoreImpl::OnGotSession, base::Unretained(this)));
if (synchronous_) {
bool old_state = MessageLoop::current()->NestableTasksAllowed();
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc
index 5c78bf6..fc7df95 100644
--- a/chrome/browser/sessions/session_service.cc
+++ b/chrome/browser/sessions/session_service.cc
@@ -79,13 +79,13 @@ class InternalSessionRequest
public:
InternalSessionRequest(
const CallbackType& callback,
- SessionService::SessionCallback* real_callback)
+ const SessionService::SessionCallback& real_callback)
: BaseSessionService::InternalGetCommandsRequest(callback),
real_callback(real_callback) {
}
// The callback supplied to GetLastSession and GetCurrentSession.
- scoped_ptr<SessionService::SessionCallback> real_callback;
+ SessionService::SessionCallback real_callback;
private:
~InternalSessionRequest() {}
@@ -419,7 +419,7 @@ void SessionService::SetSelectedTabInWindow(const SessionID& window_id,
SessionService::Handle SessionService::GetLastSession(
CancelableRequestConsumerBase* consumer,
- SessionCallback* callback) {
+ const SessionCallback& callback) {
return ScheduleGetLastSessionCommands(
new InternalSessionRequest(
base::Bind(&SessionService::OnGotSessionCommands,
@@ -430,7 +430,7 @@ SessionService::Handle SessionService::GetLastSession(
SessionService::Handle SessionService::GetCurrentSession(
CancelableRequestConsumerBase* consumer,
- SessionCallback* callback) {
+ const SessionCallback& callback) {
if (pending_window_close_ids_.empty()) {
// If there are no pending window closes, we can get the current session
// from memory.
@@ -794,13 +794,12 @@ void SessionService::OnGotSessionCommands(
scoped_refptr<InternalGetCommandsRequest> request) {
if (request->canceled())
return;
+
ScopedVector<SessionWindow> valid_windows;
RestoreSessionFromCommands(
request->commands, &(valid_windows.get()));
static_cast<InternalSessionRequest*>(request.get())->
- real_callback->RunWithParams(
- SessionCallback::TupleType(request->handle(),
- &(valid_windows.get())));
+ real_callback.Run(request->handle(), &(valid_windows.get()));
}
void SessionService::RestoreSessionFromCommands(
diff --git a/chrome/browser/sessions/session_service.h b/chrome/browser/sessions/session_service.h
index 8ef3b36..77edb7d 100644
--- a/chrome/browser/sessions/session_service.h
+++ b/chrome/browser/sessions/session_service.h
@@ -10,7 +10,7 @@
#include <string>
#include "base/basictypes.h"
-#include "base/callback_old.h"
+#include "base/callback.h"
#include "base/time.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/sessions/base_session_service.h"
@@ -157,7 +157,7 @@ class SessionService : public BaseSessionService,
// notified. To take ownership of the vector clear it before returning.
//
// The time gives the time the session was closed.
- typedef Callback2<Handle, std::vector<SessionWindow*>*>::Type
+ typedef base::Callback<void(Handle, std::vector<SessionWindow*>*)>
SessionCallback;
// Fetches the contents of the last session, notifying the callback when
@@ -168,7 +168,7 @@ class SessionService : public BaseSessionService,
// callback invokes OnGotSessionCommands from which we map the
// SessionCommands to browser state, then notify the callback.
Handle GetLastSession(CancelableRequestConsumerBase* consumer,
- SessionCallback* callback);
+ const SessionCallback& callback);
// Fetches the contents of the current session, notifying the callback when
// done. If the callback is supplied an empty vector of SessionWindows
@@ -178,7 +178,7 @@ class SessionService : public BaseSessionService,
// callback invokes OnGotSessionCommands from which we map the
// SessionCommands to browser state, then notify the callback.
Handle GetCurrentSession(CancelableRequestConsumerBase* consumer,
- SessionCallback* callback);
+ const SessionCallback& callback);
// Overridden from BaseSessionService because we want some UMA reporting on
// session update activities.
diff --git a/chrome/browser/sessions/session_service_unittest.cc b/chrome/browser/sessions/session_service_unittest.cc
index e79d4cd..75573db 100644
--- a/chrome/browser/sessions/session_service_unittest.cc
+++ b/chrome/browser/sessions/session_service_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
@@ -642,8 +644,10 @@ TEST_F(SessionServiceTest, GetCurrentSession) {
CancelableRequestConsumer consumer;
GetCurrentSessionCallbackHandler handler;
- service()->GetCurrentSession(&consumer,
- NewCallback(&handler, &GetCurrentSessionCallbackHandler::OnGotSession));
+ service()->GetCurrentSession(
+ &consumer,
+ base::Bind(&GetCurrentSessionCallbackHandler::OnGotSession,
+ base::Unretained(&handler)));
}
// Test that the notification for SESSION_SERVICE_SAVED is working properly.
diff --git a/chrome/browser/sessions/tab_restore_service.cc b/chrome/browser/sessions/tab_restore_service.cc
index 2cc53e3..0e26eaf 100644
--- a/chrome/browser/sessions/tab_restore_service.cc
+++ b/chrome/browser/sessions/tab_restore_service.cc
@@ -430,8 +430,10 @@ void TabRestoreService::LoadTabsFromLastSession() {
session_service) {
// The previous session crashed and wasn't restored. Load the tabs/windows
// that were open at the point of crash from the session service.
- session_service->GetLastSession(&crash_consumer_,
- NewCallback(this, &TabRestoreService::OnGotPreviousSession));
+ session_service->GetLastSession(
+ &crash_consumer_,
+ base::Bind(&TabRestoreService::OnGotPreviousSession,
+ base::Unretained(this)));
} else {
load_state_ |= LOADED_LAST_SESSION;
}