summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/history')
-rw-r--r--chrome/browser/history/expire_history_backend.cc15
-rw-r--r--chrome/browser/history/expire_history_backend.h3
-rw-r--r--chrome/browser/history/history.cc38
-rw-r--r--chrome/browser/history/history.h96
-rw-r--r--chrome/browser/history/history_backend.cc54
-rw-r--r--chrome/browser/history/history_backend.h10
-rw-r--r--chrome/browser/history/history_browsertest.cc9
-rw-r--r--chrome/browser/history/history_marshaling.h8
-rw-r--r--chrome/browser/history/history_querying_unittest.cc9
-rw-r--r--chrome/browser/history/history_unittest.cc40
-rw-r--r--chrome/browser/history/text_database_manager.cc11
-rw-r--r--chrome/browser/history/text_database_manager.h9
-rw-r--r--chrome/browser/history/top_sites.cc11
-rw-r--r--chrome/browser/history/top_sites_backend.cc50
-rw-r--r--chrome/browser/history/top_sites_backend.h16
-rw-r--r--chrome/browser/history/top_sites_unittest.cc7
16 files changed, 193 insertions, 193 deletions
diff --git a/chrome/browser/history/expire_history_backend.cc b/chrome/browser/history/expire_history_backend.cc
index 0149646..0542ab8 100644
--- a/chrome/browser/history/expire_history_backend.cc
+++ b/chrome/browser/history/expire_history_backend.cc
@@ -7,7 +7,6 @@
#include <algorithm>
#include <limits>
-#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/file_util.h"
#include "base/message_loop.h"
@@ -169,7 +168,7 @@ ExpireHistoryBackend::ExpireHistoryBackend(
archived_db_(NULL),
thumb_db_(NULL),
text_db_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)),
bookmark_service_(bookmark_service) {
}
@@ -574,11 +573,8 @@ void ExpireHistoryBackend::ScheduleArchive() {
delay = TimeDelta::FromSeconds(kExpirationDelaySec);
}
- MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&ExpireHistoryBackend::DoArchiveIteration,
- weak_factory_.GetWeakPtr()),
- delay.InMilliseconds());
+ MessageLoop::current()->PostDelayedTask(FROM_HERE, factory_.NewRunnableMethod(
+ &ExpireHistoryBackend::DoArchiveIteration), delay.InMilliseconds());
}
void ExpireHistoryBackend::DoArchiveIteration() {
@@ -670,9 +666,8 @@ void ExpireHistoryBackend::ScheduleExpireHistoryIndexFiles() {
TimeDelta delay = TimeDelta::FromMinutes(kIndexExpirationDelayMin);
MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&ExpireHistoryBackend::DoExpireHistoryIndexFiles,
- weak_factory_.GetWeakPtr()),
+ FROM_HERE, factory_.NewRunnableMethod(
+ &ExpireHistoryBackend::DoExpireHistoryIndexFiles),
delay.InMilliseconds());
}
diff --git a/chrome/browser/history/expire_history_backend.h b/chrome/browser/history/expire_history_backend.h
index babb829..753331a 100644
--- a/chrome/browser/history/expire_history_backend.h
+++ b/chrome/browser/history/expire_history_backend.h
@@ -13,7 +13,6 @@
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
#include "base/task.h"
#include "base/time.h"
#include "chrome/browser/history/history_types.h"
@@ -261,7 +260,7 @@ class ExpireHistoryBackend {
// Used to generate runnable methods to do timers on this class. They will be
// automatically canceled when this class is deleted.
- base::WeakPtrFactory<ExpireHistoryBackend> weak_factory_;
+ ScopedRunnableMethodFactory<ExpireHistoryBackend> factory_;
// The threshold for "old" history where we will automatically expire it to
// the archived database.
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc
index d736f2a..d7508d3 100644
--- a/chrome/browser/history/history.cc
+++ b/chrome/browser/history/history.cc
@@ -263,7 +263,7 @@ HistoryService::Handle HistoryService::GetMostRecentKeywordSearchTerms(
const string16& prefix,
int max_count,
CancelableRequestConsumerBase* consumer,
- const GetMostRecentKeywordSearchTermsCallback& callback) {
+ GetMostRecentKeywordSearchTermsCallback* callback) {
return Schedule(PRIORITY_UI, &HistoryBackend::GetMostRecentKeywordSearchTerms,
consumer,
new history::GetMostRecentKeywordSearchTermsRequest(callback),
@@ -275,19 +275,21 @@ void HistoryService::URLsNoLongerBookmarked(const std::set<GURL>& urls) {
urls);
}
-void HistoryService::ScheduleDBTask(HistoryDBTask* task,
- CancelableRequestConsumerBase* consumer) {
+HistoryService::Handle HistoryService::ScheduleDBTask(
+ HistoryDBTask* task,
+ CancelableRequestConsumerBase* consumer) {
history::HistoryDBTaskRequest* request = new history::HistoryDBTaskRequest(
- base::Bind(&HistoryDBTask::DoneRunOnMainThread, task));
+ NewCallback(task, &HistoryDBTask::DoneRunOnMainThread));
request->value = task; // The value is the task to execute.
- Schedule(PRIORITY_UI, &HistoryBackend::ProcessDBTask, consumer, request);
+ return Schedule(PRIORITY_UI, &HistoryBackend::ProcessDBTask, consumer,
+ request);
}
HistoryService::Handle HistoryService::QuerySegmentUsageSince(
CancelableRequestConsumerBase* consumer,
const Time from_time,
int max_result_count,
- const SegmentQueryCallback& callback) {
+ SegmentQueryCallback* callback) {
return Schedule(PRIORITY_UI, &HistoryBackend::QuerySegmentUsage,
consumer, new history::QuerySegmentUsageRequest(callback),
from_time, max_result_count);
@@ -434,7 +436,7 @@ void HistoryService::SetPageContents(const GURL& url,
HistoryService::Handle HistoryService::GetPageThumbnail(
const GURL& page_url,
CancelableRequestConsumerBase* consumer,
- const ThumbnailDataCallback& callback) {
+ ThumbnailDataCallback* callback) {
return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetPageThumbnail, consumer,
new history::GetPageThumbnailRequest(callback), page_url);
}
@@ -508,7 +510,7 @@ HistoryService::Handle HistoryService::CreateDownload(
int32 id,
const DownloadPersistentStoreInfo& create_info,
CancelableRequestConsumerBase* consumer,
- const HistoryService::DownloadCreateCallback& callback) {
+ HistoryService::DownloadCreateCallback* callback) {
return Schedule(PRIORITY_NORMAL, &HistoryBackend::CreateDownload, consumer,
new history::DownloadCreateRequest(callback), id,
create_info);
@@ -516,7 +518,7 @@ HistoryService::Handle HistoryService::CreateDownload(
HistoryService::Handle HistoryService::GetNextDownloadId(
CancelableRequestConsumerBase* consumer,
- const DownloadNextIdCallback& callback) {
+ DownloadNextIdCallback* callback) {
return Schedule(PRIORITY_NORMAL, &HistoryBackend::GetNextDownloadId, consumer,
new history::DownloadNextIdRequest(callback));
}
@@ -525,7 +527,7 @@ HistoryService::Handle HistoryService::GetNextDownloadId(
// 'downloads' table.
HistoryService::Handle HistoryService::QueryDownloads(
CancelableRequestConsumerBase* consumer,
- const DownloadQueryCallback& callback) {
+ DownloadQueryCallback* callback) {
return Schedule(PRIORITY_NORMAL, &HistoryBackend::QueryDownloads, consumer,
new history::DownloadQueryRequest(callback));
}
@@ -569,7 +571,7 @@ HistoryService::Handle HistoryService::QueryHistory(
const string16& text_query,
const history::QueryOptions& options,
CancelableRequestConsumerBase* consumer,
- const QueryHistoryCallback& callback) {
+ QueryHistoryCallback* callback) {
return Schedule(PRIORITY_UI, &HistoryBackend::QueryHistory, consumer,
new history::QueryHistoryRequest(callback),
text_query, options);
@@ -578,7 +580,7 @@ HistoryService::Handle HistoryService::QueryHistory(
HistoryService::Handle HistoryService::QueryRedirectsFrom(
const GURL& from_url,
CancelableRequestConsumerBase* consumer,
- const QueryRedirectsCallback& callback) {
+ QueryRedirectsCallback* callback) {
return Schedule(PRIORITY_UI, &HistoryBackend::QueryRedirectsFrom, consumer,
new history::QueryRedirectsRequest(callback), from_url);
}
@@ -586,7 +588,7 @@ HistoryService::Handle HistoryService::QueryRedirectsFrom(
HistoryService::Handle HistoryService::QueryRedirectsTo(
const GURL& to_url,
CancelableRequestConsumerBase* consumer,
- const QueryRedirectsCallback& callback) {
+ QueryRedirectsCallback* callback) {
return Schedule(PRIORITY_NORMAL, &HistoryBackend::QueryRedirectsTo, consumer,
new history::QueryRedirectsRequest(callback), to_url);
}
@@ -594,7 +596,7 @@ HistoryService::Handle HistoryService::QueryRedirectsTo(
HistoryService::Handle HistoryService::GetVisibleVisitCountToHost(
const GURL& url,
CancelableRequestConsumerBase* consumer,
- const GetVisibleVisitCountToHostCallback& callback) {
+ GetVisibleVisitCountToHostCallback* callback) {
return Schedule(PRIORITY_UI, &HistoryBackend::GetVisibleVisitCountToHost,
consumer, new history::GetVisibleVisitCountToHostRequest(callback), url);
}
@@ -602,7 +604,7 @@ HistoryService::Handle HistoryService::GetVisibleVisitCountToHost(
HistoryService::Handle HistoryService::QueryTopURLsAndRedirects(
int result_count,
CancelableRequestConsumerBase* consumer,
- const QueryTopURLsAndRedirectsCallback& callback) {
+ QueryTopURLsAndRedirectsCallback* callback) {
return Schedule(PRIORITY_NORMAL, &HistoryBackend::QueryTopURLsAndRedirects,
consumer, new history::QueryTopURLsAndRedirectsRequest(callback),
result_count);
@@ -612,7 +614,7 @@ HistoryService::Handle HistoryService::QueryMostVisitedURLs(
int result_count,
int days_back,
CancelableRequestConsumerBase* consumer,
- const QueryMostVisitedURLsCallback& callback) {
+ QueryMostVisitedURLsCallback* callback) {
return Schedule(PRIORITY_NORMAL, &HistoryBackend::QueryMostVisitedURLs,
consumer,
new history::QueryMostVisitedURLsRequest(callback),
@@ -745,11 +747,11 @@ void HistoryService::ExpireHistoryBetween(
const std::set<GURL>& restrict_urls,
Time begin_time, Time end_time,
CancelableRequestConsumerBase* consumer,
- const base::Closure& callback) {
+ ExpireHistoryCallback* callback) {
// We will update the visited links when we observe the delete notifications.
Schedule(PRIORITY_UI, &HistoryBackend::ExpireHistoryBetween, consumer,
- new CancelableRequest<base::Closure>(callback),
+ new history::ExpireHistoryRequest(callback),
restrict_urls, begin_time, end_time);
}
diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h
index 7b9d219..af513c2 100644
--- a/chrome/browser/history/history.h
+++ b/chrome/browser/history/history.h
@@ -10,7 +10,7 @@
#include <vector>
#include "base/basictypes.h"
-#include "base/callback.h"
+#include "base/callback_old.h"
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
@@ -284,7 +284,7 @@ class HistoryService : public CancelableRequestProvider,
// Provides the result of a query. See QueryResults in history_types.h.
// The common use will be to use QueryResults.Swap to suck the contents of
// the results out of the passed in parameter and take ownership of them.
- typedef base::Callback<void(Handle, history::QueryResults*)>
+ typedef Callback2<Handle, history::QueryResults*>::Type
QueryHistoryCallback;
// Queries all history with the given options (see QueryOptions in
@@ -297,7 +297,7 @@ class HistoryService : public CancelableRequestProvider,
Handle QueryHistory(const string16& text_query,
const history::QueryOptions& options,
CancelableRequestConsumerBase* consumer,
- const QueryHistoryCallback& callback);
+ QueryHistoryCallback* callback);
// Called when the results of QueryRedirectsFrom are available.
// The given vector will contain a list of all redirects, not counting
@@ -308,30 +308,30 @@ class HistoryService : public CancelableRequestProvider,
// redirect, the vector will be empty. If the history system failed for
// some reason, success will additionally be false. If the given page
// has redirected to multiple destinations, this will pick a random one.
- typedef base::Callback<void(Handle,
- GURL, // from_url
- bool, // success
- history::RedirectList*)> QueryRedirectsCallback;
+ typedef Callback4<Handle,
+ GURL, // from_url
+ bool, // success
+ history::RedirectList*>::Type
+ QueryRedirectsCallback;
// Schedules a query for the most recent redirect coming out of the given
// URL. See the RedirectQuerySource above, which is guaranteed to be called
// if the request is not canceled.
Handle QueryRedirectsFrom(const GURL& from_url,
CancelableRequestConsumerBase* consumer,
- const QueryRedirectsCallback& callback);
+ QueryRedirectsCallback* callback);
// Schedules a query to get the most recent redirects ending at the given
// URL.
Handle QueryRedirectsTo(const GURL& to_url,
CancelableRequestConsumerBase* consumer,
- const QueryRedirectsCallback& callback);
-
- typedef base::Callback<
- void(Handle,
- bool, // Were we able to determine the # of visits?
- int, // Number of visits.
- base::Time)> // Time of first visit. Only set if bool
- // is true and int is > 0.
+ QueryRedirectsCallback* callback);
+
+ typedef Callback4<Handle,
+ bool, // Were we able to determine the # of visits?
+ int, // Number of visits.
+ base::Time>::Type // Time of first visit. Only set if bool
+ // is true and int is > 0.
GetVisibleVisitCountToHostCallback;
// Requests the number of user-visible visits (i.e. no redirects or subframes)
@@ -340,37 +340,35 @@ class HistoryService : public CancelableRequestProvider,
Handle GetVisibleVisitCountToHost(
const GURL& url,
CancelableRequestConsumerBase* consumer,
- const GetVisibleVisitCountToHostCallback& callback);
+ GetVisibleVisitCountToHostCallback* callback);
// Called when QueryTopURLsAndRedirects completes. The vector contains a list
// of the top |result_count| URLs. For each of these URLs, there is an entry
// in the map containing redirects from the URL. For example, if we have the
// redirect chain A -> B -> C and A is a top visited URL, then A will be in
// the vector and "A => {B -> C}" will be in the map.
- typedef base::Callback<
- void(Handle,
- bool, // Did we get the top urls and redirects?
- std::vector<GURL>*, // List of top URLs.
- history::RedirectMap*)> // Redirects for top URLs.
+ typedef Callback4<Handle,
+ bool, // Did we get the top urls and redirects?
+ std::vector<GURL>*, // List of top URLs.
+ history::RedirectMap*>::Type // Redirects for top URLs.
QueryTopURLsAndRedirectsCallback;
// Request the top |result_count| most visited URLs and the chain of redirects
// leading to each of these URLs.
// TODO(Nik): remove this. Use QueryMostVisitedURLs instead.
- Handle QueryTopURLsAndRedirects(
- int result_count,
- CancelableRequestConsumerBase* consumer,
- const QueryTopURLsAndRedirectsCallback& callback);
+ Handle QueryTopURLsAndRedirects(int result_count,
+ CancelableRequestConsumerBase* consumer,
+ QueryTopURLsAndRedirectsCallback* callback);
- typedef base::Callback<void(Handle, history::MostVisitedURLList)>
- QueryMostVisitedURLsCallback;
+ typedef Callback2<Handle, history::MostVisitedURLList>::Type
+ QueryMostVisitedURLsCallback;
// Request the |result_count| most visited URLs and the chain of
// redirects leading to each of these URLs. |days_back| is the
// number of days of history to use. Used by TopSites.
Handle QueryMostVisitedURLs(int result_count, int days_back,
CancelableRequestConsumerBase* consumer,
- const QueryMostVisitedURLsCallback& callback);
+ QueryMostVisitedURLsCallback* callback);
// Thumbnails ----------------------------------------------------------------
@@ -380,19 +378,23 @@ class HistoryService : public CancelableRequestProvider,
//
// This function will be called even on error conditions or if there is no
// thumbnail for that page. In these cases, the data pointer will be NULL.
- typedef base::Callback<void(Handle, scoped_refptr<RefCountedBytes>)>
+ typedef Callback2<Handle, scoped_refptr<RefCountedBytes> >::Type
ThumbnailDataCallback;
// Requests a page thumbnail. See ThumbnailDataCallback definition above.
Handle GetPageThumbnail(const GURL& page_url,
CancelableRequestConsumerBase* consumer,
- const ThumbnailDataCallback& callback);
+ ThumbnailDataCallback* callback);
// Database management operations --------------------------------------------
// Delete all the information related to a single url.
void DeleteURL(const GURL& url);
+ // Implemented by the caller of ExpireHistoryBetween, and
+ // is called when the history service has deleted the history.
+ typedef Callback0::Type ExpireHistoryCallback;
+
// Removes all visits in the selected time range (including the start time),
// updating the URLs accordingly. This deletes the associated data, including
// the full text index. This function also deletes the associated favicons,
@@ -404,13 +406,14 @@ class HistoryService : public CancelableRequestProvider,
void ExpireHistoryBetween(const std::set<GURL>& restrict_urls,
base::Time begin_time, base::Time end_time,
CancelableRequestConsumerBase* consumer,
- const base::Closure& callback);
+ ExpireHistoryCallback* callback);
// Downloads -----------------------------------------------------------------
// Implemented by the caller of 'CreateDownload' below, and is called when the
// history service has created a new entry for a download in the history db.
- typedef base::Callback<void(int32, int64)> DownloadCreateCallback;
+ typedef Callback2<int32, int64>::Type
+ DownloadCreateCallback;
// Begins a history request to create a new persistent entry for a download.
// 'info' contains all the download's creation state, and 'callback' runs
@@ -418,18 +421,18 @@ class HistoryService : public CancelableRequestProvider,
Handle CreateDownload(int32 id,
const DownloadPersistentStoreInfo& info,
CancelableRequestConsumerBase* consumer,
- const DownloadCreateCallback& callback);
+ DownloadCreateCallback* callback);
// Implemented by the caller of 'GetNextDownloadId' below.
- typedef base::Callback<void(int)> DownloadNextIdCallback;
+ typedef Callback1<int/*next_download_id*/>::Type DownloadNextIdCallback;
// Runs the callback with the next available download id.
Handle GetNextDownloadId(CancelableRequestConsumerBase* consumer,
- const DownloadNextIdCallback& callback);
+ DownloadNextIdCallback* callback);
// Implemented by the caller of 'QueryDownloads' below, and is called when the
// history service has retrieved a list of all download state. The call
- typedef base::Callback<void(std::vector<DownloadPersistentStoreInfo>*)>
+ typedef Callback1<std::vector<DownloadPersistentStoreInfo>*>::Type
DownloadQueryCallback;
// Begins a history request to retrieve the state of all downloads in the
@@ -437,7 +440,7 @@ class HistoryService : public CancelableRequestProvider,
// at which point 'info' contains an array of DownloadPersistentStoreInfo, one
// per download.
Handle QueryDownloads(CancelableRequestConsumerBase* consumer,
- const DownloadQueryCallback& callback);
+ DownloadQueryCallback* callback);
// Begins a request to clean up entries that has been corrupted (because of
// the crash, for example).
@@ -465,7 +468,7 @@ class HistoryService : public CancelableRequestProvider,
// Visit Segments ------------------------------------------------------------
- typedef base::Callback<void(Handle, std::vector<PageUsageData*>*)>
+ typedef Callback2<Handle, std::vector<PageUsageData*>*>::Type
SegmentQueryCallback;
// Query usage data for all visit segments since the provided time.
@@ -484,7 +487,7 @@ class HistoryService : public CancelableRequestProvider,
Handle QuerySegmentUsageSince(CancelableRequestConsumerBase* consumer,
const base::Time from_time,
int max_result_count,
- const SegmentQueryCallback& callback);
+ SegmentQueryCallback* callback);
// Set the presentation index for the segment identified by |segment_id|.
void SetSegmentPresentationIndex(int64 segment_id, int index);
@@ -500,9 +503,8 @@ class HistoryService : public CancelableRequestProvider,
// Deletes all search terms for the specified keyword.
void DeleteAllSearchTermsForKeyword(TemplateURLID keyword_id);
- typedef base::Callback<
- void(Handle, std::vector<history::KeywordSearchTermVisit>*)>
- GetMostRecentKeywordSearchTermsCallback;
+ typedef Callback2<Handle, std::vector<history::KeywordSearchTermVisit>*>::Type
+ GetMostRecentKeywordSearchTermsCallback;
// Returns up to max_count of the most recent search terms starting with the
// specified text. The matching is case insensitive. The results are ordered
@@ -513,7 +515,7 @@ class HistoryService : public CancelableRequestProvider,
const string16& prefix,
int max_count,
CancelableRequestConsumerBase* consumer,
- const GetMostRecentKeywordSearchTermsCallback& callback);
+ GetMostRecentKeywordSearchTermsCallback* callback);
// Bookmarks -----------------------------------------------------------------
@@ -522,10 +524,12 @@ class HistoryService : public CancelableRequestProvider,
// Generic Stuff -------------------------------------------------------------
+ typedef Callback0::Type HistoryDBTaskCallback;
+
// Schedules a HistoryDBTask for running on the history backend thread. See
// HistoryDBTask for details on what this does.
- virtual void ScheduleDBTask(HistoryDBTask* task,
- CancelableRequestConsumerBase* consumer);
+ virtual Handle ScheduleDBTask(HistoryDBTask* task,
+ CancelableRequestConsumerBase* consumer);
// Returns true if top sites needs to be migrated out of history into its own
// db.
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
index f9ef759..d9cac45 100644
--- a/chrome/browser/history/history_backend.cc
+++ b/chrome/browser/history/history_backend.cc
@@ -28,7 +28,6 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/url_constants.h"
-#include "content/browser/cancelable_request.h"
#include "content/browser/download/download_persistent_store_info.h"
#include "googleurl/src/gurl.h"
#include "grit/chromium_strings.h"
@@ -1025,7 +1024,9 @@ void HistoryBackend::QuerySegmentUsage(
NewRunnableMethod(this, &HistoryBackend::DeleteOldSegmentData));
}
}
- request->ForwardResult(request->handle(), &request->value.get());
+ request->ForwardResult(
+ QuerySegmentUsageRequest::TupleType(request->handle(),
+ &request->value.get()));
}
// Keyword visits --------------------------------------------------------------
@@ -1078,7 +1079,9 @@ void HistoryBackend::GetMostRecentKeywordSearchTerms(
db_->GetMostRecentKeywordSearchTerms(keyword_id, prefix, max_count,
&(request->value));
}
- request->ForwardResult(request->handle(), &request->value);
+ request->ForwardResult(
+ GetMostRecentKeywordSearchTermsRequest::TupleType(request->handle(),
+ &request->value));
}
// Downloads -------------------------------------------------------------------
@@ -1091,7 +1094,7 @@ void HistoryBackend::GetNextDownloadId(
} else {
request->value = 0;
}
- request->ForwardResult(request->value);
+ request->ForwardResult(DownloadNextIdRequest::TupleType(request->value));
}
// Get all the download entries from the database.
@@ -1101,7 +1104,7 @@ void HistoryBackend::QueryDownloads(
return;
if (db_.get())
db_->QueryDownloads(&request->value);
- request->ForwardResult(&request->value);
+ request->ForwardResult(DownloadQueryRequest::TupleType(&request->value));
}
// Clean up entries that has been corrupted (because of the crash, for example).
@@ -1137,7 +1140,7 @@ void HistoryBackend::CreateDownload(
if (!request->canceled()) {
if (db_.get())
db_handle = db_->CreateDownload(history_info);
- request->ForwardResult(id, db_handle);
+ request->ForwardResult(DownloadCreateRequest::TupleType(id, db_handle));
}
}
@@ -1178,7 +1181,8 @@ void HistoryBackend::QueryHistory(scoped_refptr<QueryHistoryRequest> request,
}
}
- request->ForwardResult(request->handle(), &request->value);
+ request->ForwardResult(QueryHistoryRequest::TupleType(request->handle(),
+ &request->value));
UMA_HISTOGRAM_TIMES("History.QueryHistory",
TimeTicks::Now() - beginning_time);
@@ -1296,7 +1300,8 @@ void HistoryBackend::QueryRedirectsFrom(
if (request->canceled())
return;
bool success = GetMostRecentRedirectsFrom(url, &request->value);
- request->ForwardResult(request->handle(), url, success, &request->value);
+ request->ForwardResult(QueryRedirectsRequest::TupleType(
+ request->handle(), url, success, &request->value));
}
void HistoryBackend::QueryRedirectsTo(
@@ -1305,7 +1310,8 @@ void HistoryBackend::QueryRedirectsTo(
if (request->canceled())
return;
bool success = GetMostRecentRedirectsTo(url, &request->value);
- request->ForwardResult(request->handle(), url, success, &request->value);
+ request->ForwardResult(QueryRedirectsRequest::TupleType(
+ request->handle(), url, success, &request->value));
}
void HistoryBackend::GetVisibleVisitCountToHost(
@@ -1317,7 +1323,8 @@ void HistoryBackend::GetVisibleVisitCountToHost(
Time first_visit;
const bool success = db_.get() &&
db_->GetVisibleVisitCountToHost(url, &count, &first_visit);
- request->ForwardResult(request->handle(), success, count, first_visit);
+ request->ForwardResult(GetVisibleVisitCountToHostRequest::TupleType(
+ request->handle(), success, count, first_visit));
}
void HistoryBackend::QueryTopURLsAndRedirects(
@@ -1327,7 +1334,8 @@ void HistoryBackend::QueryTopURLsAndRedirects(
return;
if (!db_.get()) {
- request->ForwardResult(request->handle(), false, NULL, NULL);
+ request->ForwardResult(QueryTopURLsAndRedirectsRequest::TupleType(
+ request->handle(), false, NULL, NULL));
return;
}
@@ -1345,7 +1353,8 @@ void HistoryBackend::QueryTopURLsAndRedirects(
(*redirects)[top_urls->back()] = list;
}
- request->ForwardResult(request->handle(), true, top_urls, redirects);
+ request->ForwardResult(QueryTopURLsAndRedirectsRequest::TupleType(
+ request->handle(), true, top_urls, redirects));
}
// Will replace QueryTopURLsAndRedirectsRequest.
@@ -1358,13 +1367,15 @@ void HistoryBackend::QueryMostVisitedURLs(
if (!db_.get()) {
// No History Database - return an empty list.
- request->ForwardResult(request->handle(), MostVisitedURLList());
+ request->ForwardResult(QueryMostVisitedURLsRequest::TupleType(
+ request->handle(), MostVisitedURLList()));
return;
}
MostVisitedURLList* result = &request->value;
QueryMostVisitedURLsImpl(result_count, days_back, result);
- request->ForwardResult(request->handle(), *result);
+ request->ForwardResult(QueryMostVisitedURLsRequest::TupleType(
+ request->handle(), *result));
}
void HistoryBackend::QueryMostVisitedURLsImpl(int result_count,
@@ -1499,7 +1510,8 @@ void HistoryBackend::GetPageThumbnail(
scoped_refptr<RefCountedBytes> data;
GetPageThumbnailDirectly(page_url, &data);
- request->ForwardResult(request->handle(), data);
+ request->ForwardResult(GetPageThumbnailRequest::TupleType(
+ request->handle(), data));
}
void HistoryBackend::GetPageThumbnailDirectly(
@@ -1715,7 +1727,8 @@ void HistoryBackend::UpdateFaviconMappingAndFetchImpl(
// else case, haven't cached entry yet. Caller is responsible for
// downloading the favicon and invoking SetFavicon.
}
- request->ForwardResult(request->handle(), favicon);
+ request->ForwardResult(GetFaviconRequest::TupleType(
+ request->handle(), favicon));
}
void HistoryBackend::GetFaviconForURL(
@@ -1730,7 +1743,8 @@ void HistoryBackend::GetFaviconForURL(
// Get the favicon from DB.
GetFaviconFromDB(page_url, icon_types, &favicon);
- request->ForwardResult(request->handle(), favicon);
+ request->ForwardResult(
+ GetFaviconRequest::TupleType(request->handle(), favicon));
}
void HistoryBackend::SetFavicon(
@@ -1913,7 +1927,7 @@ void HistoryBackend::ProcessDBTaskImpl() {
db_task_requests_.pop_front();
if (request->value->RunOnDBThread(this, db_.get())) {
// The task is done. Notify the callback.
- request->ForwardResult();
+ request->ForwardResult(HistoryDBTaskRequest::TupleType());
// We AddRef'd the request before adding, need to release it now.
request->Release();
} else {
@@ -1961,7 +1975,7 @@ void HistoryBackend::DeleteURL(const GURL& url) {
}
void HistoryBackend::ExpireHistoryBetween(
- scoped_refptr<CancelableRequest<base::Closure> > request,
+ scoped_refptr<ExpireHistoryRequest> request,
const std::set<GURL>& restrict_urls,
Time begin_time,
Time end_time) {
@@ -1986,7 +2000,7 @@ void HistoryBackend::ExpireHistoryBetween(
if (begin_time <= first_recorded_time_)
db_->GetStartDate(&first_recorded_time_);
- request->ForwardResult();
+ request->ForwardResult(ExpireHistoryRequest::TupleType());
if (history_publisher_.get() && restrict_urls.empty())
history_publisher_->DeleteUserHistoryBetween(begin_time, end_time);
diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h
index f9625c2..5d43bed 100644
--- a/chrome/browser/history/history_backend.h
+++ b/chrome/browser/history/history_backend.h
@@ -22,7 +22,6 @@
#include "chrome/browser/history/thumbnail_database.h"
#include "chrome/browser/history/visit_tracker.h"
#include "chrome/browser/search_engines/template_url_id.h"
-#include "content/browser/cancelable_request.h"
#include "sql/init_status.h"
class BookmarkService;
@@ -310,11 +309,10 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
virtual void DeleteURL(const GURL& url);
// Calls ExpireHistoryBackend::ExpireHistoryBetween and commits the change.
- void ExpireHistoryBetween(
- scoped_refptr<CancelableRequest<base::Closure> > request,
- const std::set<GURL>& restrict_urls,
- base::Time begin_time,
- base::Time end_time);
+ void ExpireHistoryBetween(scoped_refptr<ExpireHistoryRequest> request,
+ const std::set<GURL>& restrict_urls,
+ base::Time begin_time,
+ base::Time end_time);
// Bookmarks -----------------------------------------------------------------
diff --git a/chrome/browser/history/history_browsertest.cc b/chrome/browser/history/history_browsertest.cc
index a2dc9f3..82cbb99 100644
--- a/chrome/browser/history/history_browsertest.cc
+++ b/chrome/browser/history/history_browsertest.cc
@@ -4,7 +4,6 @@
#include <vector>
-#include "base/bind.h"
#include "base/message_loop.h"
#include "chrome/browser/history/history.h"
#include "chrome/browser/prefs/pref_service.h"
@@ -55,7 +54,7 @@ class HistoryEnumerator : public HistoryService::URLEnumerator {
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- base::Bind(&HistoryService::IterateURLs, history, this));
+ NewRunnableMethod(history, &HistoryService::IterateURLs, this));
ui_test_utils::RunMessageLoop();
}
@@ -109,8 +108,10 @@ class HistoryBrowserTest : public InProcessBrowserTest {
HistoryService* history = GetHistoryService();
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
- base::Bind(&HistoryService::ScheduleDBTask,
- history, task, &request_consumer));
+ NewRunnableMethod(history,
+ &HistoryService::ScheduleDBTask,
+ task,
+ &request_consumer));
ui_test_utils::RunMessageLoop();
}
diff --git a/chrome/browser/history/history_marshaling.h b/chrome/browser/history/history_marshaling.h
index ac3a702..845ea9c 100644
--- a/chrome/browser/history/history_marshaling.h
+++ b/chrome/browser/history/history_marshaling.h
@@ -67,6 +67,11 @@ typedef CancelableRequest1<HistoryService::DownloadQueryCallback,
typedef CancelableRequest<HistoryService::DownloadCreateCallback>
DownloadCreateRequest;
+// Deletion --------------------------------------------------------------------
+
+typedef CancelableRequest<HistoryService::ExpireHistoryCallback>
+ ExpireHistoryRequest;
+
// Segment usage --------------------------------------------------------------
typedef CancelableRequest1<HistoryService::SegmentQueryCallback,
@@ -85,7 +90,8 @@ typedef
// The argument here is an input value, which is the task to run on the
// background thread. The callback is used to execute the portion of the task
// that executes on the main thread.
-typedef CancelableRequest1<base::Closure, scoped_refptr<HistoryDBTask> >
+typedef CancelableRequest1<HistoryService::HistoryDBTaskCallback,
+ scoped_refptr<HistoryDBTask> >
HistoryDBTaskRequest;
} // namespace history
diff --git a/chrome/browser/history/history_querying_unittest.cc b/chrome/browser/history/history_querying_unittest.cc
index 7c11dc4..609f78a 100644
--- a/chrome/browser/history/history_querying_unittest.cc
+++ b/chrome/browser/history/history_querying_unittest.cc
@@ -3,8 +3,7 @@
// found in the LICENSE file.
#include "base/basictypes.h"
-#include "base/bind.h"
-#include "base/bind_helpers.h"
+#include "base/callback.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
@@ -77,10 +76,8 @@ class HistoryQueryTest : public testing::Test {
void QueryHistory(const std::string& text_query,
const QueryOptions& options,
QueryResults* results) {
- history_->QueryHistory(
- UTF8ToUTF16(text_query), options, &consumer_,
- base::Bind(&HistoryQueryTest::QueryHistoryComplete,
- base::Unretained(this)));
+ history_->QueryHistory(UTF8ToUTF16(text_query), options, &consumer_,
+ NewCallback(this, &HistoryQueryTest::QueryHistoryComplete));
MessageLoop::current()->Run(); // Will go until ...Complete calls Quit.
results->Swap(&last_query_results_);
}
diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc
index ac38745..2cd7a2d 100644
--- a/chrome/browser/history/history_unittest.cc
+++ b/chrome/browser/history/history_unittest.cc
@@ -231,8 +231,7 @@ class HistoryTest : public testing::Test {
// returning true on success. False means the URL was not found.
bool QueryRedirectsFrom(HistoryService* history, const GURL& url) {
history->QueryRedirectsFrom(url, &consumer_,
- base::Bind(&HistoryTest::OnRedirectQueryComplete,
- base::Unretained(this)));
+ NewCallback(this, &HistoryTest::OnRedirectQueryComplete));
MessageLoop::current()->Run(); // Will be exited in *QueryComplete.
return redirect_query_success_;
}
@@ -629,8 +628,8 @@ TEST_F(HistoryTest, Segments) {
// Make sure a segment was created.
history->QuerySegmentUsageSince(
&consumer_, Time::Now() - TimeDelta::FromDays(1), 10,
- base::Bind(&HistoryTest::OnSegmentUsageAvailable,
- base::Unretained(this)));
+ NewCallback(static_cast<HistoryTest*>(this),
+ &HistoryTest::OnSegmentUsageAvailable));
// Wait for processing.
MessageLoop::current()->Run();
@@ -648,8 +647,8 @@ TEST_F(HistoryTest, Segments) {
// Query again
history->QuerySegmentUsageSince(
&consumer_, Time::Now() - TimeDelta::FromDays(1), 10,
- base::Bind(&HistoryTest::OnSegmentUsageAvailable,
- base::Unretained(this)));
+ NewCallback(static_cast<HistoryTest*>(this),
+ &HistoryTest::OnSegmentUsageAvailable));
// Wait for processing.
MessageLoop::current()->Run();
@@ -666,8 +665,8 @@ TEST_F(HistoryTest, Segments) {
// Query again
history->QuerySegmentUsageSince(
&consumer_, Time::Now() - TimeDelta::FromDays(1), 10,
- base::Bind(&HistoryTest::OnSegmentUsageAvailable,
- base::Unretained(this)));
+ NewCallback(static_cast<HistoryTest*>(this),
+ &HistoryTest::OnSegmentUsageAvailable));
// Wait for processing.
MessageLoop::current()->Run();
@@ -701,9 +700,8 @@ TEST_F(HistoryTest, MostVisitedURLs) {
PageTransition::TYPED, history::RedirectList(),
history::SOURCE_BROWSED, false);
history->QueryMostVisitedURLs(20, 90, &consumer_,
- base::Bind(
- &HistoryTest::OnMostVisitedURLsAvailable,
- base::Unretained(this)));
+ NewCallback(static_cast<HistoryTest*>(this),
+ &HistoryTest::OnMostVisitedURLsAvailable));
MessageLoop::current()->Run();
EXPECT_EQ(2U, most_visited_urls_.size());
@@ -715,9 +713,8 @@ TEST_F(HistoryTest, MostVisitedURLs) {
PageTransition::TYPED, history::RedirectList(),
history::SOURCE_BROWSED, false);
history->QueryMostVisitedURLs(20, 90, &consumer_,
- base::Bind(
- &HistoryTest::OnMostVisitedURLsAvailable,
- base::Unretained(this)));
+ NewCallback(static_cast<HistoryTest*>(this),
+ &HistoryTest::OnMostVisitedURLsAvailable));
MessageLoop::current()->Run();
EXPECT_EQ(3U, most_visited_urls_.size());
@@ -730,9 +727,8 @@ TEST_F(HistoryTest, MostVisitedURLs) {
PageTransition::TYPED, history::RedirectList(),
history::SOURCE_BROWSED, false);
history->QueryMostVisitedURLs(20, 90, &consumer_,
- base::Bind(
- &HistoryTest::OnMostVisitedURLsAvailable,
- base::Unretained(this)));
+ NewCallback(static_cast<HistoryTest*>(this),
+ &HistoryTest::OnMostVisitedURLsAvailable));
MessageLoop::current()->Run();
EXPECT_EQ(3U, most_visited_urls_.size());
@@ -745,9 +741,8 @@ TEST_F(HistoryTest, MostVisitedURLs) {
PageTransition::TYPED, history::RedirectList(),
history::SOURCE_BROWSED, false);
history->QueryMostVisitedURLs(20, 90, &consumer_,
- base::Bind(
- &HistoryTest::OnMostVisitedURLsAvailable,
- base::Unretained(this)));
+ NewCallback(static_cast<HistoryTest*>(this),
+ &HistoryTest::OnMostVisitedURLsAvailable));
MessageLoop::current()->Run();
EXPECT_EQ(3U, most_visited_urls_.size());
@@ -765,9 +760,8 @@ TEST_F(HistoryTest, MostVisitedURLs) {
PageTransition::TYPED, redirects,
history::SOURCE_BROWSED, false);
history->QueryMostVisitedURLs(20, 90, &consumer_,
- base::Bind(
- &HistoryTest::OnMostVisitedURLsAvailable,
- base::Unretained(this)));
+ NewCallback(static_cast<HistoryTest*>(this),
+ &HistoryTest::OnMostVisitedURLsAvailable));
MessageLoop::current()->Run();
EXPECT_EQ(4U, most_visited_urls_.size());
diff --git a/chrome/browser/history/text_database_manager.cc b/chrome/browser/history/text_database_manager.cc
index 98e5990..09a79cf 100644
--- a/chrome/browser/history/text_database_manager.cc
+++ b/chrome/browser/history/text_database_manager.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/history/text_database_manager.h"
-#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/file_util.h"
#include "base/metrics/histogram.h"
@@ -86,7 +85,7 @@ TextDatabaseManager::TextDatabaseManager(const FilePath& dir,
transaction_nesting_(0),
db_cache_(DBCache::NO_AUTO_EVICT),
present_databases_loaded_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)),
history_publisher_(NULL) {
}
@@ -533,11 +532,9 @@ TextDatabase* TextDatabaseManager::GetDBForTime(Time time,
}
void TextDatabaseManager::ScheduleFlushOldChanges() {
- weak_factory_.InvalidateWeakPtrs();
- MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&TextDatabaseManager::FlushOldChanges,
- weak_factory_.GetWeakPtr()),
+ factory_.RevokeAll();
+ MessageLoop::current()->PostDelayedTask(FROM_HERE, factory_.NewRunnableMethod(
+ &TextDatabaseManager::FlushOldChanges),
kExpirationSec * Time::kMillisecondsPerSecond);
}
diff --git a/chrome/browser/history/text_database_manager.h b/chrome/browser/history/text_database_manager.h
index 89b750a..120f4b1 100644
--- a/chrome/browser/history/text_database_manager.h
+++ b/chrome/browser/history/text_database_manager.h
@@ -12,7 +12,6 @@
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/gtest_prod_util.h"
-#include "base/memory/weak_ptr.h"
#include "base/string16.h"
#include "base/task.h"
#include "base/memory/mru_cache.h"
@@ -33,7 +32,7 @@ class VisitDatabase;
// It will also keep a list of partial changes, such as page adds and title and
// body sets, all of which come in at different times for a given page. When
// all data is received or enough time has elapsed since adding, the indexed
-// data will be committed.
+// data will be comitted.
//
// This allows us to minimize inserts and modifications, which are slow for the
// full text database, since each page's information is added exactly once.
@@ -127,7 +126,7 @@ class TextDatabaseManager {
// The text database manager keeps a list of changes that are made to the
// file AddPageURL/Title/Body that may not be committed to the database yet.
- // This function removes entries from this list happening between the given
+ // This function removes entires from this list happening between the given
// time range. It is called when the user clears their history for a time
// range, and we don't want any of our data to "leak." If restrict_urls is
// not empty, only changes on those URLs are deleted.
@@ -278,7 +277,7 @@ class TextDatabaseManager {
DBCache db_cache_;
// Tells us about the existence of database files on disk. All existing
- // databases will be in here, and non-existent ones will not, so we don't
+ // databases will be in here, and non-existant ones will not, so we don't
// have to check the disk every time.
//
// This set is populated LAZILY by InitDBList(), you should call that function
@@ -297,7 +296,7 @@ class TextDatabaseManager {
QueryParser query_parser_;
// Generates tasks for our periodic checking of expired "recent changes".
- base::WeakPtrFactory<TextDatabaseManager> weak_factory_;
+ ScopedRunnableMethodFactory<TextDatabaseManager> factory_;
// This object is created and managed by the history backend. We maintain an
// opaque pointer to the object for our use.
diff --git a/chrome/browser/history/top_sites.cc b/chrome/browser/history/top_sites.cc
index 9228217..17c8940 100644
--- a/chrome/browser/history/top_sites.cc
+++ b/chrome/browser/history/top_sites.cc
@@ -7,8 +7,6 @@
#include <algorithm>
#include <set>
-#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/logging.h"
#include "base/md5.h"
#include "base/string_util.h"
@@ -177,8 +175,7 @@ void TopSites::Init(const FilePath& db_name) {
backend_->Init(db_name);
backend_->GetMostVisitedThumbnails(
&top_sites_consumer_,
- base::Bind(&TopSites::OnGotMostVisitedThumbnails,
- base::Unretained(this)));
+ NewCallback(this, &TopSites::OnGotMostVisitedThumbnails));
// History may have already finished loading by the time we're created.
HistoryService* history = profile_->GetHistoryServiceWithoutCreating();
@@ -332,8 +329,7 @@ void TopSites::FinishHistoryMigration(const ThumbnailMigration& data) {
// we can tell history to finish its part of migration.
backend_->DoEmptyRequest(
&top_sites_consumer_,
- base::Bind(&TopSites::OnHistoryMigrationWrittenToDisk,
- base::Unretained(this)));
+ NewCallback(this, &TopSites::OnHistoryMigrationWrittenToDisk));
}
void TopSites::HistoryLoaded() {
@@ -535,8 +531,7 @@ CancelableRequestProvider::Handle TopSites::StartQueryForMostVisited() {
num_results_to_request_from_history(),
kDaysOfHistory,
&history_consumer_,
- base::Bind(&TopSites::OnTopSitesAvailableFromHistory,
- base::Unretained(this)));
+ NewCallback(this, &TopSites::OnTopSitesAvailableFromHistory));
}
return 0;
}
diff --git a/chrome/browser/history/top_sites_backend.cc b/chrome/browser/history/top_sites_backend.cc
index 94355cc..bb25e1f 100644
--- a/chrome/browser/history/top_sites_backend.cc
+++ b/chrome/browser/history/top_sites_backend.cc
@@ -4,10 +4,8 @@
#include "chrome/browser/history/top_sites_backend.h"
-#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
-#include "base/memory/ref_counted.h"
#include "chrome/browser/history/top_sites_database.h"
#include "content/browser/browser_thread.h"
@@ -20,60 +18,62 @@ TopSitesBackend::TopSitesBackend()
void TopSitesBackend::Init(const FilePath& path) {
db_path_ = path;
BrowserThread::PostTask(
- BrowserThread::DB, FROM_HERE,
- base::Bind(&TopSitesBackend::InitDBOnDBThread, this, path));
+ BrowserThread::DB, FROM_HERE, NewRunnableMethod(
+ this, &TopSitesBackend::InitDBOnDBThread, path));
}
void TopSitesBackend::Shutdown() {
BrowserThread::PostTask(
- BrowserThread::DB, FROM_HERE,
- base::Bind(&TopSitesBackend::ShutdownDBOnDBThread, this));
+ BrowserThread::DB, FROM_HERE, NewRunnableMethod(
+ this, &TopSitesBackend::ShutdownDBOnDBThread));
}
TopSitesBackend::Handle TopSitesBackend::GetMostVisitedThumbnails(
CancelableRequestConsumerBase* consumer,
- const GetMostVisitedThumbnailsCallback& callback) {
+ GetMostVisitedThumbnailsCallback* callback) {
GetMostVisitedThumbnailsRequest* request =
new GetMostVisitedThumbnailsRequest(callback);
request->value = new MostVisitedThumbnails;
AddRequest(request, consumer);
BrowserThread::PostTask(
- BrowserThread::DB, FROM_HERE,
- base::Bind(&TopSitesBackend::GetMostVisitedThumbnailsOnDBThread, this,
- make_scoped_refptr(request)));
+ BrowserThread::DB, FROM_HERE, NewRunnableMethod(
+ this,
+ &TopSitesBackend::GetMostVisitedThumbnailsOnDBThread,
+ scoped_refptr<GetMostVisitedThumbnailsRequest>(request)));
return request->handle();
}
void TopSitesBackend::UpdateTopSites(const TopSitesDelta& delta) {
BrowserThread::PostTask(
- BrowserThread::DB, FROM_HERE,
- base::Bind(&TopSitesBackend::UpdateTopSitesOnDBThread, this, delta));
+ BrowserThread::DB, FROM_HERE, NewRunnableMethod(
+ this, &TopSitesBackend::UpdateTopSitesOnDBThread, delta));
}
void TopSitesBackend::SetPageThumbnail(const MostVisitedURL& url,
int url_rank,
const Images& thumbnail) {
BrowserThread::PostTask(
- BrowserThread::DB, FROM_HERE,
- base::Bind(&TopSitesBackend::SetPageThumbnailOnDBThread, this, url,
- url_rank, thumbnail));
+ BrowserThread::DB, FROM_HERE, NewRunnableMethod(
+ this, &TopSitesBackend::SetPageThumbnailOnDBThread, url,
+ url_rank, thumbnail));
}
void TopSitesBackend::ResetDatabase() {
BrowserThread::PostTask(
- BrowserThread::DB, FROM_HERE,
- base::Bind(&TopSitesBackend::ResetDatabaseOnDBThread, this, db_path_));
+ BrowserThread::DB, FROM_HERE, NewRunnableMethod(
+ this, &TopSitesBackend::ResetDatabaseOnDBThread, db_path_));
}
TopSitesBackend::Handle TopSitesBackend::DoEmptyRequest(
CancelableRequestConsumerBase* consumer,
- const EmptyRequestCallback& callback) {
+ EmptyRequestCallback* callback) {
EmptyRequestRequest* request = new EmptyRequestRequest(callback);
AddRequest(request, consumer);
BrowserThread::PostTask(
- BrowserThread::DB, FROM_HERE,
- base::Bind(&TopSitesBackend::DoEmptyRequestOnDBThread, this,
- make_scoped_refptr(request)));
+ BrowserThread::DB, FROM_HERE, NewRunnableMethod(
+ this,
+ &TopSitesBackend::DoEmptyRequestOnDBThread,
+ scoped_refptr<EmptyRequestRequest>(request)));
return request->handle();
}
@@ -108,8 +108,10 @@ void TopSitesBackend::GetMostVisitedThumbnailsOnDBThread(
&(request->value->url_to_images_map));
may_need_history_migration = db_->may_need_history_migration();
}
- request->ForwardResult(request->handle(), request->value,
- may_need_history_migration);
+ request->ForwardResult(GetMostVisitedThumbnailsRequest::TupleType(
+ request->handle(),
+ request->value,
+ may_need_history_migration));
}
void TopSitesBackend::UpdateTopSitesOnDBThread(const TopSitesDelta& delta) {
@@ -145,7 +147,7 @@ void TopSitesBackend::ResetDatabaseOnDBThread(const FilePath& file_path) {
void TopSitesBackend::DoEmptyRequestOnDBThread(
scoped_refptr<EmptyRequestRequest> request) {
- request->ForwardResult(request->handle());
+ request->ForwardResult(EmptyRequestRequest::TupleType(request->handle()));
}
} // namespace history
diff --git a/chrome/browser/history/top_sites_backend.h b/chrome/browser/history/top_sites_backend.h
index 95ff242..a2a5b61 100644
--- a/chrome/browser/history/top_sites_backend.h
+++ b/chrome/browser/history/top_sites_backend.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_HISTORY_TOP_SITES_BACKEND_H_
#pragma once
-#include "base/callback.h"
+#include "base/callback_old.h"
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
@@ -35,17 +35,15 @@ class TopSitesBackend
// The boolean parameter indicates if the DB existed on disk or needs to be
// migrated.
- typedef base::Callback<
- void(Handle, scoped_refptr<MostVisitedThumbnails>, bool)>
- GetMostVisitedThumbnailsCallback;
+ typedef Callback3<Handle, scoped_refptr<MostVisitedThumbnails>, bool >::Type
+ GetMostVisitedThumbnailsCallback;
typedef CancelableRequest1<TopSitesBackend::GetMostVisitedThumbnailsCallback,
scoped_refptr<MostVisitedThumbnails> >
GetMostVisitedThumbnailsRequest;
// Fetches MostVisitedThumbnails.
- Handle GetMostVisitedThumbnails(
- CancelableRequestConsumerBase* consumer,
- const GetMostVisitedThumbnailsCallback& callback);
+ Handle GetMostVisitedThumbnails(CancelableRequestConsumerBase* consumer,
+ GetMostVisitedThumbnailsCallback* callback);
// Updates top sites database from the specified delta.
void UpdateTopSites(const TopSitesDelta& delta);
@@ -58,7 +56,7 @@ class TopSitesBackend
// Deletes the database and recreates it.
void ResetDatabase();
- typedef base::Callback<void(Handle)> EmptyRequestCallback;
+ typedef Callback1<Handle>::Type EmptyRequestCallback;
typedef CancelableRequest<TopSitesBackend::EmptyRequestCallback>
EmptyRequestRequest;
@@ -66,7 +64,7 @@ class TopSitesBackend
// the callback on the calling thread. This is used to make sure the db has
// finished processing a request.
Handle DoEmptyRequest(CancelableRequestConsumerBase* consumer,
- const EmptyRequestCallback& callback);
+ EmptyRequestCallback* callback);
private:
friend class base::RefCountedThreadSafe<TopSitesBackend>;
diff --git a/chrome/browser/history/top_sites_unittest.cc b/chrome/browser/history/top_sites_unittest.cc
index df81625..5d6ef8f 100644
--- a/chrome/browser/history/top_sites_unittest.cc
+++ b/chrome/browser/history/top_sites_unittest.cc
@@ -194,8 +194,7 @@ class TopSitesTest : public HistoryUnitTestBase {
void WaitForTopSites() {
top_sites()->backend_->DoEmptyRequest(
&consumer_,
- base::Bind(&TopSitesTest::QuitCallback,
- base::Unretained(this)));
+ NewCallback(this, &TopSitesTest::QuitCallback));
MessageLoop::current()->Run();
}
@@ -896,8 +895,8 @@ TEST_F(TopSitesTest, PinnedURLsDeleted) {
history_service()->ExpireHistoryBetween(
std::set<GURL>(), base::Time(), base::Time(),
- consumer(), base::Bind(&TopSitesTest::EmptyCallback,
- base::Unretained(this))),
+ consumer(), NewCallback(static_cast<TopSitesTest*>(this),
+ &TopSitesTest::EmptyCallback)),
WaitForHistory();
{