summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autocomplete/history_contents_provider.cc6
-rw-r--r--chrome/browser/automation/automation_provider_observers.cc36
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc9
-rw-r--r--chrome/browser/bookmarks/bookmark_html_writer.cc5
-rw-r--r--chrome/browser/bookmarks/bookmark_model.cc6
-rw-r--r--chrome/browser/browsing_data_remover.cc4
-rw-r--r--chrome/browser/custom_home_pages_table_model.cc3
-rw-r--r--chrome/browser/download/chrome_download_manager_delegate.cc34
-rw-r--r--chrome/browser/download/download_browsertest.cc5
-rw-r--r--chrome/browser/download/download_history.cc27
-rw-r--r--chrome/browser/download/download_history.h7
-rw-r--r--chrome/browser/download/save_page_browsertest.cc5
-rw-r--r--chrome/browser/extensions/extension_history_api.cc9
-rw-r--r--chrome/browser/extensions/extension_web_ui.cc4
-rw-r--r--chrome/browser/favicon/favicon_handler.cc15
-rw-r--r--chrome/browser/favicon/favicon_handler.h6
-rw-r--r--chrome/browser/favicon/favicon_handler_unittest.cc33
-rw-r--r--chrome/browser/favicon/favicon_service.cc9
-rw-r--r--chrome/browser/favicon/favicon_service.h15
-rw-r--r--chrome/browser/favicon/favicon_tab_helper.h2
-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
-rw-r--r--chrome/browser/jumplist_win.cc3
-rw-r--r--chrome/browser/page_info_model.cc5
-rw-r--r--chrome/browser/safe_browsing/browser_feature_extractor.cc7
-rw-r--r--chrome/browser/safe_browsing/malware_details_history.cc5
-rw-r--r--chrome/browser/sync/profile_sync_service_typed_url_unittest.cc5
-rw-r--r--chrome/browser/tab_contents/thumbnail_generator.cc12
-rw-r--r--chrome/browser/tab_contents/thumbnail_generator.h4
-rw-r--r--chrome/browser/tabs/tab_finder.cc5
-rw-r--r--chrome/browser/ui/cocoa/history_menu_bridge.mm12
-rw-r--r--chrome/browser/ui/cocoa/tabpose_window.mm9
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_controller.cc7
-rw-r--r--chrome/browser/ui/search_engines/template_url_table_model.cc6
-rw-r--r--chrome/browser/ui/toolbar/back_forward_menu_model.cc5
-rw-r--r--chrome/browser/ui/webui/chrome_web_ui_factory.cc4
-rw-r--r--chrome/browser/ui/webui/extension_icon_source.cc6
-rw-r--r--chrome/browser/ui/webui/favicon_source.cc9
-rw-r--r--chrome/browser/ui/webui/history2_ui.cc9
-rw-r--r--chrome/browser/ui/webui/history_ui.cc9
-rw-r--r--chrome/browser/ui/webui/ntp/app_launcher_handler.cc2
-rw-r--r--chrome/browser/ui/webui/ntp/favicon_webui_handler.cc5
-rw-r--r--chrome/test/base/ui_test_utils.cc4
57 files changed, 362 insertions, 397 deletions
diff --git a/chrome/browser/autocomplete/history_contents_provider.cc b/chrome/browser/autocomplete/history_contents_provider.cc
index 6ec694c..7061daf 100644
--- a/chrome/browser/autocomplete/history_contents_provider.cc
+++ b/chrome/browser/autocomplete/history_contents_provider.cc
@@ -4,8 +4,7 @@
#include "chrome/browser/autocomplete/history_contents_provider.h"
-#include "base/bind.h"
-#include "base/bind_helpers.h"
+#include "base/callback.h"
#include "base/metrics/histogram.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
@@ -138,8 +137,7 @@ void HistoryContentsProvider::Start(const AutocompleteInput& input,
options.max_count = kMaxMatches;
history->QueryHistory(input.text(), options,
&request_consumer_,
- base::Bind(&HistoryContentsProvider::QueryComplete,
- base::Unretained(this)));
+ NewCallback(this, &HistoryContentsProvider::QueryComplete));
}
}
}
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index 21e47b6..cb6b2ec 100644
--- a/chrome/browser/automation/automation_provider_observers.cc
+++ b/chrome/browser/automation/automation_provider_observers.cc
@@ -1737,8 +1737,8 @@ void PasswordStoreLoginsChangedObserver::Init() {
BrowserThread::PostTask(
BrowserThread::DB,
FROM_HERE,
- base::Bind(&PasswordStoreLoginsChangedObserver::RegisterObserversTask,
- this));
+ NewRunnableMethod(
+ this, &PasswordStoreLoginsChangedObserver::RegisterObserversTask));
done_event_.Wait();
}
@@ -1764,8 +1764,8 @@ void PasswordStoreLoginsChangedObserver::Observe(
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- base::Bind(&PasswordStoreLoginsChangedObserver::IndicateError, this,
- error));
+ NewRunnableMethod(
+ this, &PasswordStoreLoginsChangedObserver::IndicateError, error));
return;
}
@@ -1775,7 +1775,8 @@ void PasswordStoreLoginsChangedObserver::Observe(
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- base::Bind(&PasswordStoreLoginsChangedObserver::IndicateDone, this));
+ NewRunnableMethod(
+ this, &PasswordStoreLoginsChangedObserver::IndicateDone));
}
void PasswordStoreLoginsChangedObserver::IndicateDone() {
@@ -1908,8 +1909,8 @@ void PageSnapshotTaker::OnDomOperationCompleted(const std::string& json) {
ThumbnailGenerator* generator =
g_browser_process->GetThumbnailGenerator();
- ThumbnailGenerator::ThumbnailReadyCallback callback =
- base::Bind(&PageSnapshotTaker::OnSnapshotTaken, base::Unretained(this));
+ ThumbnailGenerator::ThumbnailReadyCallback* callback =
+ NewCallback(this, &PageSnapshotTaker::OnSnapshotTaken);
// Don't actually start the thumbnail generator, this leads to crashes on
// Mac, crbug.com/62986. Instead, just hook the generator to the
// RenderViewHost manually.
@@ -2272,7 +2273,7 @@ void AutofillChangedObserver::Init() {
BrowserThread::PostTask(
BrowserThread::DB,
FROM_HERE,
- base::Bind(&AutofillChangedObserver::RegisterObserversTask, this));
+ NewRunnableMethod(this, &AutofillChangedObserver::RegisterObserversTask));
done_event_.Wait();
}
@@ -2307,7 +2308,7 @@ void AutofillChangedObserver::Observe(
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- base::Bind(&AutofillChangedObserver::IndicateDone, this));
+ NewRunnableMethod(this, &AutofillChangedObserver::IndicateDone));
}
}
@@ -2689,10 +2690,10 @@ WaitForProcessLauncherThreadToGoIdleObserver(
AddRef();
BrowserThread::PostTask(
BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
- base::Bind(
+ NewRunnableMethod(
+ this,
&WaitForProcessLauncherThreadToGoIdleObserver::
- RunOnProcessLauncherThread,
- this));
+ RunOnProcessLauncherThread));
}
WaitForProcessLauncherThreadToGoIdleObserver::
@@ -2704,10 +2705,10 @@ RunOnProcessLauncherThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::PROCESS_LAUNCHER));
BrowserThread::PostTask(
BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
- base::Bind(
+ NewRunnableMethod(
+ this,
&WaitForProcessLauncherThreadToGoIdleObserver::
- RunOnProcessLauncherThread2,
- this));
+ RunOnProcessLauncherThread2));
}
void WaitForProcessLauncherThreadToGoIdleObserver::
@@ -2715,8 +2716,9 @@ RunOnProcessLauncherThread2() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::PROCESS_LAUNCHER));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- base::Bind(&WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread,
- this));
+ NewRunnableMethod(
+ this,
+ &WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread));
}
void WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread() {
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 4c0a523..2a0739a 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -10,7 +10,6 @@
#include <vector>
#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/json/json_reader.h"
@@ -739,8 +738,8 @@ void TestingAutomationProvider::GetRedirectsFrom(int tab_handle,
// that it's done: OnRedirectQueryComplete.
redirect_query_ = history_service->QueryRedirectsFrom(
source_url, &consumer_,
- base::Bind(&TestingAutomationProvider::OnRedirectQueryComplete,
- base::Unretained(this)));
+ NewCallback(this,
+ &TestingAutomationProvider::OnRedirectQueryComplete));
return; // Response will be sent when query completes.
}
}
@@ -3022,8 +3021,8 @@ void TestingAutomationProvider::GetHistoryInfo(Browser* browser,
search_text,
options,
&consumer_,
- base::Bind(&AutomationProviderHistoryObserver::HistoryQueryComplete,
- base::Unretained(history_observer)));
+ NewCallback(history_observer,
+ &AutomationProviderHistoryObserver::HistoryQueryComplete));
}
// Sample json input: { "command": "AddHistoryItem",
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc
index c6065ac..8952d65 100644
--- a/chrome/browser/bookmarks/bookmark_html_writer.cc
+++ b/chrome/browser/bookmarks/bookmark_html_writer.cc
@@ -5,8 +5,6 @@
#include "chrome/browser/bookmarks/bookmark_html_writer.h"
#include "base/base64.h"
-#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/file_path.h"
#include "base/memory/scoped_ptr.h"
@@ -450,8 +448,7 @@ bool BookmarkFaviconFetcher::FetchNextFavicon() {
profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
favicon_service->GetFaviconForURL(GURL(url), history::FAVICON,
&favicon_consumer_,
- base::Bind(&BookmarkFaviconFetcher::OnFaviconDataAvailable,
- base::Unretained(this)));
+ NewCallback(this, &BookmarkFaviconFetcher::OnFaviconDataAvailable));
return true;
} else {
bookmark_urls_.pop_front();
diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc
index b9db127..18bb942 100644
--- a/chrome/browser/bookmarks/bookmark_model.cc
+++ b/chrome/browser/bookmarks/bookmark_model.cc
@@ -7,8 +7,7 @@
#include <algorithm>
#include <functional>
-#include "base/bind.h"
-#include "base/bind_helpers.h"
+#include "base/callback.h"
#include "base/command_line.h"
#include "base/memory/scoped_vector.h"
#include "build/build_config.h"
@@ -750,8 +749,7 @@ void BookmarkModel::LoadFavicon(BookmarkNode* node) {
return;
FaviconService::Handle handle = favicon_service->GetFaviconForURL(
node->url(), history::FAVICON, &load_consumer_,
- base::Bind(&BookmarkModel::OnFaviconDataAvailable,
- base::Unretained(this)));
+ NewCallback(this, &BookmarkModel::OnFaviconDataAvailable));
load_consumer_.SetClientData(favicon_service, handle, node);
node->set_favicon_load_handle(handle);
}
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index 0cfc15d..0d7f021 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -8,7 +8,6 @@
#include <set>
#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/file_util.h"
#include "base/logging.h"
@@ -137,8 +136,7 @@ void BrowsingDataRemover::Remove(int remove_mask) {
history_service->ExpireHistoryBetween(restrict_urls,
delete_begin_, delete_end_,
&request_consumer_,
- base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone,
- base::Unretained(this)));
+ NewCallback(this, &BrowsingDataRemover::OnHistoryDeletionDone));
}
// Need to clear the host cache and accumulated speculative data, as it also
diff --git a/chrome/browser/custom_home_pages_table_model.cc b/chrome/browser/custom_home_pages_table_model.cc
index e1e2ab7..9f09f92 100644
--- a/chrome/browser/custom_home_pages_table_model.cc
+++ b/chrome/browser/custom_home_pages_table_model.cc
@@ -226,8 +226,7 @@ void CustomHomePagesTableModel::LoadTitleAndFavicon(Entry* entry) {
if (favicon_service) {
entry->favicon_handle = favicon_service->GetFaviconForURL(entry->url,
history::FAVICON, &favicon_query_consumer_,
- base::Bind(&CustomHomePagesTableModel::OnGotFavicon,
- base::Unretained(this)));
+ NewCallback(this, &CustomHomePagesTableModel::OnGotFavicon));
}
}
diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc
index 08f7265..80c6dbc 100644
--- a/chrome/browser/download/chrome_download_manager_delegate.cc
+++ b/chrome/browser/download/chrome_download_manager_delegate.cc
@@ -4,8 +4,6 @@
#include "chrome/browser/download/chrome_download_manager_delegate.h"
-#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/file_util.h"
#include "base/path_service.h"
@@ -61,11 +59,9 @@ void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) {
download_manager_ = dm;
download_history_.reset(new DownloadHistory(profile_));
download_history_->Load(
- base::Bind(&DownloadManager::OnPersistentStoreQueryComplete,
- base::Unretained(dm)));
+ NewCallback(dm, &DownloadManager::OnPersistentStoreQueryComplete));
download_history_->GetNextId(
- base::Bind(&DownloadManager::OnPersistentStoreGetNextId,
- base::Unretained(dm)));
+ NewCallback(dm, &DownloadManager::OnPersistentStoreGetNextId));
}
void ChromeDownloadManagerDelegate::Shutdown() {
@@ -210,8 +206,8 @@ void ChromeDownloadManagerDelegate::OnResponseCompleted(
void ChromeDownloadManagerDelegate::AddItemToPersistentStore(
DownloadItem* item) {
download_history_->AddEntry(item,
- base::Bind(&ChromeDownloadManagerDelegate::OnItemAddedToPersistentStore,
- base::Unretained(this)));
+ NewCallback(this,
+ &ChromeDownloadManagerDelegate::OnItemAddedToPersistentStore));
}
void ChromeDownloadManagerDelegate::UpdateItemInPersistentStore(
@@ -297,10 +293,8 @@ void ChromeDownloadManagerDelegate::CheckDownloadUrlDone(
if (is_dangerous_url)
download->MarkUrlDangerous();
- download_history_->CheckVisitedReferrerBefore(
- download_id, download->referrer_url(),
- NewCallback(
- this,
+ download_history_->CheckVisitedReferrerBefore(download_id,
+ download->referrer_url(), NewCallback(this,
&ChromeDownloadManagerDelegate::CheckVisitedReferrerBeforeDone));
}
@@ -386,9 +380,12 @@ void ChromeDownloadManagerDelegate::CheckVisitedReferrerBeforeDone(
// now and pass the value to the FILE thread.
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- base::Bind(&ChromeDownloadManagerDelegate::CheckIfSuggestedPathExists,
- this, download->id(), state,
- download_prefs_->download_path()));
+ NewRunnableMethod(
+ this,
+ &ChromeDownloadManagerDelegate::CheckIfSuggestedPathExists,
+ download->id(),
+ state,
+ download_prefs_->download_path()));
}
void ChromeDownloadManagerDelegate::CheckIfSuggestedPathExists(
@@ -475,8 +472,11 @@ void ChromeDownloadManagerDelegate::CheckIfSuggestedPathExists(
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- base::Bind(&ChromeDownloadManagerDelegate::OnPathExistenceAvailable,
- this, download_id, state));
+ NewRunnableMethod(
+ this,
+ &ChromeDownloadManagerDelegate::OnPathExistenceAvailable,
+ download_id,
+ state));
}
void ChromeDownloadManagerDelegate::OnPathExistenceAvailable(
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
index a6265d5..f613b27 100644
--- a/chrome/browser/download/download_browsertest.cc
+++ b/chrome/browser/download/download_browsertest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/memory/ref_counted.h"
@@ -522,8 +521,8 @@ class DownloadsHistoryDataCollector {
DCHECK(hs);
hs->QueryDownloads(
&callback_consumer_,
- base::Bind(&DownloadsHistoryDataCollector::OnQueryDownloadsComplete,
- base::Unretained(this)));
+ NewCallback(this,
+ &DownloadsHistoryDataCollector::OnQueryDownloadsComplete));
// TODO(rdsmith): Move message loop out of constructor.
// Cannot complete immediately because the history backend runs on a
diff --git a/chrome/browser/download/download_history.cc b/chrome/browser/download/download_history.cc
index 0398a3c..426a434 100644
--- a/chrome/browser/download/download_history.cc
+++ b/chrome/browser/download/download_history.cc
@@ -28,20 +28,23 @@ DownloadHistory::~DownloadHistory() {
}
void DownloadHistory::GetNextId(
- const HistoryService::DownloadNextIdCallback& callback) {
+ HistoryService::DownloadNextIdCallback* callback) {
+ DCHECK(callback);
HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
- if (!hs)
+ if (!hs) {
+ delete callback;
return;
-
+ }
hs->GetNextDownloadId(&history_consumer_, callback);
}
-void DownloadHistory::Load(
- const HistoryService::DownloadQueryCallback& callback) {
+void DownloadHistory::Load(HistoryService::DownloadQueryCallback* callback) {
+ DCHECK(callback);
HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
- if (!hs)
+ if (!hs) {
+ delete callback;
return;
-
+ }
hs->QueryDownloads(&history_consumer_, callback);
// This is the initial load, so do a cleanup of corrupt in-progress entries.
@@ -59,8 +62,7 @@ void DownloadHistory::CheckVisitedReferrerBefore(
if (hs) {
HistoryService::Handle handle =
hs->GetVisibleVisitCountToHost(referrer_url, &history_consumer_,
- base::Bind(&DownloadHistory::OnGotVisitCountToHost,
- base::Unretained(this)));
+ NewCallback(this, &DownloadHistory::OnGotVisitCountToHost));
visited_before_requests_[handle] = std::make_pair(download_id, callback);
return;
}
@@ -71,7 +73,7 @@ void DownloadHistory::CheckVisitedReferrerBefore(
void DownloadHistory::AddEntry(
DownloadItem* download_item,
- const HistoryService::DownloadCreateCallback& callback) {
+ HistoryService::DownloadCreateCallback* callback) {
DCHECK(download_item);
// Do not store the download in the history database for a few special cases:
// - incognito mode (that is the point of this mode)
@@ -86,7 +88,10 @@ void DownloadHistory::AddEntry(
if (download_item->is_otr() ||
ChromeDownloadManagerDelegate::IsExtensionDownload(download_item) ||
download_item->is_temporary() || !hs) {
- callback.Run(download_item->id(), GetNextFakeDbHandle());
+ callback->RunWithParams(
+ history::DownloadCreateRequest::TupleType(download_item->id(),
+ GetNextFakeDbHandle()));
+ delete callback;
return;
}
diff --git a/chrome/browser/download/download_history.h b/chrome/browser/download/download_history.h
index 06c7df9..45f978b 100644
--- a/chrome/browser/download/download_history.h
+++ b/chrome/browser/download/download_history.h
@@ -9,7 +9,6 @@
#include <map>
#include "base/basictypes.h"
-#include "base/callback_old.h"
#include "chrome/browser/history/history.h"
#include "content/browser/cancelable_request.h"
@@ -31,10 +30,10 @@ class DownloadHistory {
// Retrieves the next_id counter from the sql meta_table.
// Should be much faster than Load so that we may delay downloads until after
// this call with minimal performance penalty.
- void GetNextId(const HistoryService::DownloadNextIdCallback& callback);
+ void GetNextId(HistoryService::DownloadNextIdCallback* callback);
// Retrieves DownloadCreateInfos saved in the history.
- void Load(const HistoryService::DownloadQueryCallback& callback);
+ void Load(HistoryService::DownloadQueryCallback* callback);
// Checks whether |referrer_url| has been visited before today. This takes
// ownership of |callback|.
@@ -44,7 +43,7 @@ class DownloadHistory {
// Adds a new entry for a download to the history database.
void AddEntry(DownloadItem* download_item,
- const HistoryService::DownloadCreateCallback& callback);
+ HistoryService::DownloadCreateCallback* callback);
// Updates the history entry for |download_item|.
void UpdateEntry(DownloadItem* download_item);
diff --git a/chrome/browser/download/save_page_browsertest.cc b/chrome/browser/download/save_page_browsertest.cc
index 8709b1e..b7ae2fb 100644
--- a/chrome/browser/download/save_page_browsertest.cc
+++ b/chrome/browser/download/save_page_browsertest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
@@ -134,8 +133,8 @@ class SavePageBrowserTest : public InProcessBrowserTest {
static_cast<ChromeDownloadManagerDelegate*>(
GetDownloadManager()->delegate());
delegate->download_history()->Load(
- base::Bind(&SavePageBrowserTest::OnQueryDownloadEntriesComplete,
- base::Unretained(this)));
+ NewCallback(this,
+ &SavePageBrowserTest::OnQueryDownloadEntriesComplete));
// Run message loop until a quit message is sent from
// OnQueryDownloadEntriesComplete().
diff --git a/chrome/browser/extensions/extension_history_api.cc b/chrome/browser/extensions/extension_history_api.cc
index e6c6a8a..3f4dda7 100644
--- a/chrome/browser/extensions/extension_history_api.cc
+++ b/chrome/browser/extensions/extension_history_api.cc
@@ -272,8 +272,7 @@ bool SearchHistoryFunction::RunAsyncImpl() {
HistoryService* hs = profile()->GetHistoryService(Profile::EXPLICIT_ACCESS);
hs->QueryHistory(search_text, options, &cancelable_consumer_,
- base::Bind(&SearchHistoryFunction::SearchComplete,
- base::Unretained(this)));
+ NewCallback(this, &SearchHistoryFunction::SearchComplete));
return true;
}
@@ -350,8 +349,7 @@ bool DeleteRangeHistoryFunction::RunAsyncImpl() {
begin_time,
end_time,
&cancelable_consumer_,
- base::Bind(&DeleteRangeHistoryFunction::DeleteComplete,
- base::Unretained(this)));
+ NewCallback(this, &DeleteRangeHistoryFunction::DeleteComplete));
return true;
}
@@ -368,8 +366,7 @@ bool DeleteAllHistoryFunction::RunAsyncImpl() {
base::Time::UnixEpoch(), // From the beginning of the epoch.
base::Time::Now(), // To the current time.
&cancelable_consumer_,
- base::Bind(&DeleteAllHistoryFunction::DeleteComplete,
- base::Unretained(this)));
+ NewCallback(this, &DeleteAllHistoryFunction::DeleteComplete));
return true;
}
diff --git a/chrome/browser/extensions/extension_web_ui.cc b/chrome/browser/extensions/extension_web_ui.cc
index eeca442..ccb77d5 100644
--- a/chrome/browser/extensions/extension_web_ui.cc
+++ b/chrome/browser/extensions/extension_web_ui.cc
@@ -108,7 +108,9 @@ class ExtensionWebUIImageLoadingTracker : public ImageLoadingTracker::Observer {
favicon.known_icon = icon_data.get() != NULL && icon_data->size() > 0;
favicon.image_data = icon_data;
favicon.icon_type = history::FAVICON;
- request_->ForwardResultAsync(request_->handle(), favicon);
+ request_->ForwardResultAsync(
+ FaviconService::FaviconDataCallback::TupleType(request_->handle(),
+ favicon));
delete this;
}
diff --git a/chrome/browser/favicon/favicon_handler.cc b/chrome/browser/favicon/favicon_handler.cc
index 9385c39..b14bf9b 100644
--- a/chrome/browser/favicon/favicon_handler.cc
+++ b/chrome/browser/favicon/favicon_handler.cc
@@ -8,8 +8,6 @@
#include <vector>
-#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/memory/ref_counted_memory.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
@@ -103,8 +101,7 @@ void FaviconHandler::FetchFavicon(const GURL& url) {
// available.
if (GetFaviconService()) {
GetFaviconForURL(url_, icon_types_, &cancelable_consumer_,
- base::Bind(&FaviconHandler::OnFaviconDataForInitialURL,
- base::Unretained(this)));
+ NewCallback(this, &FaviconHandler::OnFaviconDataForInitialURL));
}
}
@@ -270,7 +267,7 @@ void FaviconHandler::UpdateFaviconMappingAndFetch(
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback) {
+ FaviconService::FaviconDataCallback* callback) {
GetFaviconService()->UpdateFaviconMappingAndFetch(page_url, icon_url,
icon_type, consumer, callback);
}
@@ -279,7 +276,7 @@ void FaviconHandler::GetFavicon(
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback) {
+ FaviconService::FaviconDataCallback* callback) {
GetFaviconService()->GetFavicon(icon_url, icon_type, consumer, callback);
}
@@ -287,7 +284,7 @@ void FaviconHandler::GetFaviconForURL(
const GURL& page_url,
int icon_types,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback) {
+ FaviconService::FaviconDataCallback* callback) {
GetFaviconService()->GetFaviconForURL(page_url, icon_types, consumer,
callback);
}
@@ -371,7 +368,7 @@ void FaviconHandler::DownloadFaviconOrAskHistory(
// favicon given the favicon URL.
if (profile_->IsOffTheRecord()) {
GetFavicon(icon_url, icon_type, &cancelable_consumer_,
- base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)));
+ NewCallback(this, &FaviconHandler::OnFaviconData));
} else {
// Ask the history service for the icon. This does two things:
// 1. Attempts to fetch the favicon data from the database.
@@ -381,7 +378,7 @@ void FaviconHandler::DownloadFaviconOrAskHistory(
// Issue the request and associate the current page ID with it.
UpdateFaviconMappingAndFetch(page_url, icon_url, icon_type,
&cancelable_consumer_,
- base::Bind(&FaviconHandler::OnFaviconData, base::Unretained(this)));
+ NewCallback(this, &FaviconHandler::OnFaviconData));
}
}
}
diff --git a/chrome/browser/favicon/favicon_handler.h b/chrome/browser/favicon/favicon_handler.h
index da979f9..ccdae05 100644
--- a/chrome/browser/favicon/favicon_handler.h
+++ b/chrome/browser/favicon/favicon_handler.h
@@ -127,19 +127,19 @@ class FaviconHandler {
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback);
+ FaviconService::FaviconDataCallback* callback);
virtual void GetFavicon(
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback);
+ FaviconService::FaviconDataCallback* callback);
virtual void GetFaviconForURL(
const GURL& page_url,
int icon_types,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback);
+ FaviconService::FaviconDataCallback* callback);
virtual void SetHistoryFavicon(const GURL& page_url,
const GURL& icon_url,
diff --git a/chrome/browser/favicon/favicon_handler_unittest.cc b/chrome/browser/favicon/favicon_handler_unittest.cc
index bdf05d8..3eba39a 100644
--- a/chrome/browser/favicon/favicon_handler_unittest.cc
+++ b/chrome/browser/favicon/favicon_handler_unittest.cc
@@ -86,7 +86,7 @@ class HistoryRequestHandler {
HistoryRequestHandler(const GURL& page_url,
const GURL& icon_url,
int icon_type,
- const FaviconService::FaviconDataCallback& callback)
+ FaviconService::FaviconDataCallback* callback)
: page_url_(page_url),
icon_url_(icon_url),
icon_type_(icon_type),
@@ -97,7 +97,7 @@ class HistoryRequestHandler {
const GURL& icon_url,
int icon_type,
const std::vector<unsigned char>& image_data,
- const FaviconService::FaviconDataCallback& callback)
+ FaviconService::FaviconDataCallback* callback)
: page_url_(page_url),
icon_url_(icon_url),
icon_type_(icon_type),
@@ -105,7 +105,9 @@ class HistoryRequestHandler {
callback_(callback) {
}
- virtual ~HistoryRequestHandler() {}
+ virtual ~HistoryRequestHandler() {
+ delete callback_;
+ }
void InvokeCallback();
const GURL page_url_;
@@ -113,7 +115,7 @@ class HistoryRequestHandler {
const int icon_type_;
const std::vector<unsigned char> image_data_;
history::FaviconData favicon_data_;
- FaviconService::FaviconDataCallback callback_;
+ FaviconService::FaviconDataCallback* callback_;
private:
DISALLOW_COPY_AND_ASSIGN(HistoryRequestHandler);
@@ -217,7 +219,7 @@ class TestFaviconHandler : public FaviconHandler {
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback) OVERRIDE {
+ FaviconService::FaviconDataCallback* callback) OVERRIDE {
history_handler_.reset(new HistoryRequestHandler(page_url, icon_url,
icon_type, callback));
}
@@ -226,7 +228,7 @@ class TestFaviconHandler : public FaviconHandler {
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback) OVERRIDE {
+ FaviconService::FaviconDataCallback* callback) OVERRIDE {
history_handler_.reset(new HistoryRequestHandler(GURL(), icon_url,
icon_type, callback));
}
@@ -235,7 +237,7 @@ class TestFaviconHandler : public FaviconHandler {
const GURL& page_url,
int icon_types,
CancelableRequestConsumerBase* consumer,
- const FaviconService::FaviconDataCallback& callback) OVERRIDE {
+ FaviconService::FaviconDataCallback* callback) OVERRIDE {
history_handler_.reset(new HistoryRequestHandler(page_url, GURL(),
icon_types, callback));
}
@@ -251,9 +253,8 @@ class TestFaviconHandler : public FaviconHandler {
const GURL& icon_url,
const std::vector<unsigned char>& image_data,
history::IconType icon_type) OVERRIDE {
- history_handler_.reset(new HistoryRequestHandler(
- page_url, icon_url,icon_type, image_data,
- FaviconService::FaviconDataCallback()));
+ history_handler_.reset(new HistoryRequestHandler(page_url, icon_url,
+ icon_type, image_data, NULL));
}
virtual FaviconService* GetFaviconService() OVERRIDE {
@@ -301,7 +302,7 @@ void DownloadHandler::InvokeCallback() {
}
void HistoryRequestHandler::InvokeCallback() {
- callback_.Run(0, favicon_data_);
+ callback_->Run(0, favicon_data_);
}
class FaviconHandlerTest : public ChromeRenderViewHostTestHarness {
@@ -785,17 +786,19 @@ TEST_F(FaviconHandlerTest, UpdateDuringDownloading) {
// Reset the history_handler to verify whether favicon is request from
// history.
// Save the callback for late use.
- FaviconService::FaviconDataCallback callback = history_handler->callback_;
+ FaviconService::FaviconDataCallback* callback = history_handler->callback_;
+ // Prevent the callback from being released.
+ history_handler->callback_ = NULL;
helper.set_history_handler(NULL);
- // Simulates download succeed.
+ // Smulates download succeed.
download_handler->InvokeCallback();
- // The downloaded icon should be thrown away as there is favicon update.
+ // The downloaded icon should be thrown away as there is faviocn update.
EXPECT_FALSE(helper.history_handler());
helper.set_download_handler(NULL);
- // Simulates getting the icon from history.
+ // Smulates getting the icon from history.
scoped_ptr<HistoryRequestHandler> handler;
handler.reset(new HistoryRequestHandler(page_url, latest_icon_url,
history::TOUCH_ICON, callback));
diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc
index 5efd081..a276c7c 100644
--- a/chrome/browser/favicon/favicon_service.cc
+++ b/chrome/browser/favicon/favicon_service.cc
@@ -17,7 +17,7 @@ FaviconService::Handle FaviconService::GetFavicon(
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconDataCallback& callback) {
+ FaviconDataCallback* callback) {
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
@@ -33,7 +33,7 @@ FaviconService::Handle FaviconService::UpdateFaviconMappingAndFetch(
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconDataCallback& callback) {
+ FaviconService::FaviconDataCallback* callback) {
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
@@ -48,7 +48,7 @@ FaviconService::Handle FaviconService::GetFaviconForURL(
const GURL& page_url,
int icon_types,
CancelableRequestConsumerBase* consumer,
- const FaviconDataCallback& callback) {
+ FaviconDataCallback* callback) {
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
FaviconService::Handle handle = request->handle();
@@ -92,5 +92,6 @@ FaviconService::~FaviconService() {
}
void FaviconService::ForwardEmptyResultAsync(GetFaviconRequest* request) {
- request->ForwardResultAsync(request->handle(), history::FaviconData());
+ request->ForwardResultAsync(FaviconDataCallback::TupleType(
+ request->handle(), history::FaviconData()));
}
diff --git a/chrome/browser/favicon/favicon_service.h b/chrome/browser/favicon/favicon_service.h
index 4fb313b..2062239 100644
--- a/chrome/browser/favicon/favicon_service.h
+++ b/chrome/browser/favicon/favicon_service.h
@@ -8,7 +8,7 @@
#include <vector>
-#include "base/callback.h"
+#include "base/callback_old.h"
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
#include "base/task.h"
@@ -40,10 +40,9 @@ class FaviconService : public CancelableRequestProvider {
// opposed to not knowing anything). |expired| will be set to true if we
// refreshed the favicon "too long" ago and should be updated if the page
// is visited again.
- typedef base::Callback<
- void(Handle, // handle
- history::FaviconData)> // the type of favicon
- FaviconDataCallback;
+ typedef Callback2<Handle, // handle
+ history::FaviconData>::Type // the type of favicon
+ FaviconDataCallback;
typedef CancelableRequest<FaviconDataCallback> GetFaviconRequest;
@@ -53,7 +52,7 @@ class FaviconService : public CancelableRequestProvider {
Handle GetFavicon(const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconDataCallback& callback);
+ FaviconDataCallback* callback);
// Fetches the |icon_type| of favicon at |icon_url|, sending the results to
// the given |callback|. If the favicon has previously been set via
@@ -64,7 +63,7 @@ class FaviconService : public CancelableRequestProvider {
const GURL& icon_url,
history::IconType icon_type,
CancelableRequestConsumerBase* consumer,
- const FaviconDataCallback& callback);
+ FaviconDataCallback* callback);
// Requests any |icon_types| of favicon for a web page URL. |consumer| is
// notified when the bits have been fetched. |icon_types| can be any
@@ -77,7 +76,7 @@ class FaviconService : public CancelableRequestProvider {
Handle GetFaviconForURL(const GURL& page_url,
int icon_types,
CancelableRequestConsumerBase* consumer,
- const FaviconDataCallback& callback);
+ FaviconDataCallback* callback);
// Marks all types of favicon for the page as being out of date.
void SetFaviconOutOfDateForPage(const GURL& page_url);
diff --git a/chrome/browser/favicon/favicon_tab_helper.h b/chrome/browser/favicon/favicon_tab_helper.h
index 97e8d63..c236f75 100644
--- a/chrome/browser/favicon/favicon_tab_helper.h
+++ b/chrome/browser/favicon/favicon_tab_helper.h
@@ -7,7 +7,7 @@
#pragma once
#include "base/basictypes.h"
-#include "base/callback_old.h"
+#include "base/callback.h"
#include "chrome/browser/favicon/favicon_handler_delegate.h"
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/common/favicon_url.h"
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();
{
diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc
index cc797b9..a032e9f 100644
--- a/chrome/browser/jumplist_win.cc
+++ b/chrome/browser/jumplist_win.cc
@@ -14,6 +14,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/callback.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/path_service.h"
@@ -712,7 +713,7 @@ bool JumpList::StartLoadingFavicon() {
profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
handle_ = favicon_service->GetFaviconForURL(
url, history::FAVICON, &favicon_consumer_,
- base::Bind(&JumpList::OnFaviconDataAvailable, base::Unretained(this)));
+ NewCallback(this, &JumpList::OnFaviconDataAvailable));
return true;
}
diff --git a/chrome/browser/page_info_model.cc b/chrome/browser/page_info_model.cc
index de4b4c2..9e4394d 100644
--- a/chrome/browser/page_info_model.cc
+++ b/chrome/browser/page_info_model.cc
@@ -6,8 +6,6 @@
#include <string>
-#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/i18n/time_formatting.h"
#include "base/string_number_conversions.h"
@@ -286,8 +284,7 @@ PageInfoModel::PageInfoModel(Profile* profile,
history->GetVisibleVisitCountToHost(
url,
&request_consumer_,
- base::Bind(&PageInfoModel::OnGotVisitCountToHost,
- base::Unretained(this)));
+ NewCallback(this, &PageInfoModel::OnGotVisitCountToHost));
}
}
diff --git a/chrome/browser/safe_browsing/browser_feature_extractor.cc b/chrome/browser/safe_browsing/browser_feature_extractor.cc
index b0fd195..9333b9f 100644
--- a/chrome/browser/safe_browsing/browser_feature_extractor.cc
+++ b/chrome/browser/safe_browsing/browser_feature_extractor.cc
@@ -324,8 +324,7 @@ void BrowserFeatureExtractor::QueryUrlHistoryDone(
history->GetVisibleVisitCountToHost(
GURL(request->url()),
&request_consumer_,
- base::Bind(&BrowserFeatureExtractor::QueryHttpHostVisitsDone,
- base::Unretained(this)));
+ NewCallback(this, &BrowserFeatureExtractor::QueryHttpHostVisitsDone));
StorePendingQuery(next_handle, request, callback);
}
@@ -362,8 +361,8 @@ void BrowserFeatureExtractor::QueryHttpHostVisitsDone(
history->GetVisibleVisitCountToHost(
GURL(https_url.replace(0, 5, "https:")),
&request_consumer_,
- base::Bind(&BrowserFeatureExtractor::QueryHttpsHostVisitsDone,
- base::Unretained(this)));
+ NewCallback(this,
+ &BrowserFeatureExtractor::QueryHttpsHostVisitsDone));
StorePendingQuery(next_handle, request, callback);
}
diff --git a/chrome/browser/safe_browsing/malware_details_history.cc b/chrome/browser/safe_browsing/malware_details_history.cc
index 11a0d4c..ed5e36a 100644
--- a/chrome/browser/safe_browsing/malware_details_history.cc
+++ b/chrome/browser/safe_browsing/malware_details_history.cc
@@ -7,7 +7,6 @@
#include "chrome/browser/safe_browsing/malware_details_history.h"
#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/malware_details.h"
#include "chrome/common/chrome_notification_types.h"
@@ -79,8 +78,8 @@ void MalwareDetailsRedirectsCollector::GetRedirects(const GURL& url) {
history->QueryRedirectsTo(
url,
&request_consumer_,
- base::Bind(&MalwareDetailsRedirectsCollector::OnGotQueryRedirectsTo,
- base::Unretained(this)));
+ NewCallback(this,
+ &MalwareDetailsRedirectsCollector::OnGotQueryRedirectsTo));
}
void MalwareDetailsRedirectsCollector::OnGotQueryRedirectsTo(
diff --git a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
index 8586958..2460b1e 100644
--- a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
@@ -98,8 +98,8 @@ class HistoryBackendMock : public HistoryBackend {
class HistoryServiceMock : public HistoryService {
public:
HistoryServiceMock() {}
- MOCK_METHOD2(ScheduleDBTask, void(HistoryDBTask*,
- CancelableRequestConsumerBase*));
+ MOCK_METHOD2(ScheduleDBTask, Handle(HistoryDBTask*,
+ CancelableRequestConsumerBase*));
};
class RunOnDBThreadTask : public Task {
@@ -119,6 +119,7 @@ ACTION_P2(RunTaskOnDBThread, thread, backend) {
thread->message_loop()->PostTask(
FROM_HERE,
new RunOnDBThreadTask(backend, arg0));
+ return 0;
}
ACTION_P4(MakeTypedUrlSyncComponents, profile, service, hb, dtc) {
diff --git a/chrome/browser/tab_contents/thumbnail_generator.cc b/chrome/browser/tab_contents/thumbnail_generator.cc
index 1f431ba..f7c16ba 100644
--- a/chrome/browser/tab_contents/thumbnail_generator.cc
+++ b/chrome/browser/tab_contents/thumbnail_generator.cc
@@ -130,7 +130,7 @@ SkBitmap GetBitmapForBackingStore(
} // namespace
struct ThumbnailGenerator::AsyncRequestInfo {
- ThumbnailReadyCallback callback;
+ scoped_ptr<ThumbnailReadyCallback> callback;
scoped_ptr<TransportDIB> thumbnail_dib;
RenderWidgetHost* renderer; // Not owned.
};
@@ -195,9 +195,11 @@ void ThumbnailGenerator::MonitorRenderer(RenderWidgetHost* renderer,
void ThumbnailGenerator::AskForSnapshot(RenderWidgetHost* renderer,
bool prefer_backing_store,
- const ThumbnailReadyCallback& callback,
+ ThumbnailReadyCallback* callback,
gfx::Size page_size,
gfx::Size desired_size) {
+ scoped_ptr<ThumbnailReadyCallback> callback_deleter(callback);
+
if (prefer_backing_store) {
BackingStore* backing_store = renderer->GetBackingStore(false);
if (backing_store) {
@@ -208,7 +210,7 @@ void ThumbnailGenerator::AskForSnapshot(RenderWidgetHost* renderer,
desired_size.height(),
kNoOptions,
NULL);
- callback.Run(first_try);
+ callback->Run(first_try);
return;
}
@@ -247,7 +249,7 @@ void ThumbnailGenerator::AskForSnapshot(RenderWidgetHost* renderer,
#endif
linked_ptr<AsyncRequestInfo> request_info(new AsyncRequestInfo);
- request_info->callback = callback;
+ request_info->callback.reset(callback_deleter.release());
request_info->thumbnail_dib.reset(thumbnail_dib.release());
request_info->renderer = renderer;
ThumbnailCallbackMap::value_type new_value(sequence_num, request_info);
@@ -316,7 +318,7 @@ void ThumbnailGenerator::WidgetDidReceivePaintAtSizeAck(
// TODO: Figure out a way to avoid this copy?
non_owned_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config);
- item->second->callback.Run(result);
+ item->second->callback->Run(result);
// We're done with the callback, and with the DIB, so delete both.
callback_map_.erase(item);
diff --git a/chrome/browser/tab_contents/thumbnail_generator.h b/chrome/browser/tab_contents/thumbnail_generator.h
index 8329f29..0c0e588 100644
--- a/chrome/browser/tab_contents/thumbnail_generator.h
+++ b/chrome/browser/tab_contents/thumbnail_generator.h
@@ -32,7 +32,7 @@ class TopSites;
class ThumbnailGenerator : public NotificationObserver,
public TabContentsObserver {
public:
- typedef base::Callback<void(const SkBitmap&)> ThumbnailReadyCallback;
+ typedef Callback1<const SkBitmap&>::Type ThumbnailReadyCallback;
// The result of clipping. This can be used to determine if the
// generated thumbnail is good or not.
enum ClipResult {
@@ -80,7 +80,7 @@ class ThumbnailGenerator : public NotificationObserver,
// dimensions, but might not be the exact size requested.
void AskForSnapshot(RenderWidgetHost* renderer,
bool prefer_backing_store,
- const ThumbnailReadyCallback& callback,
+ ThumbnailReadyCallback* callback,
gfx::Size page_size,
gfx::Size desired_size);
diff --git a/chrome/browser/tabs/tab_finder.cc b/chrome/browser/tabs/tab_finder.cc
index 5bf2c59..af32e1f 100644
--- a/chrome/browser/tabs/tab_finder.cc
+++ b/chrome/browser/tabs/tab_finder.cc
@@ -4,8 +4,6 @@
#include "chrome/browser/tabs/tab_finder.h"
-#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/stl_util.h"
#include "chrome/browser/history/history.h"
@@ -218,8 +216,7 @@ void TabFinder::FetchRedirectStart(TabContents* tab) {
history->QueryRedirectsTo(
committed_entry->url(),
&callback_consumer_,
- base::Bind(&TabFinder::QueryRedirectsToComplete,
- base::Unretained(this)));
+ NewCallback(this, &TabFinder::QueryRedirectsToComplete));
callback_consumer_.SetClientData(history, request_handle, tab);
}
}
diff --git a/chrome/browser/ui/cocoa/history_menu_bridge.mm b/chrome/browser/ui/cocoa/history_menu_bridge.mm
index 6c54b81..fa68650 100644
--- a/chrome/browser/ui/cocoa/history_menu_bridge.mm
+++ b/chrome/browser/ui/cocoa/history_menu_bridge.mm
@@ -4,8 +4,7 @@
#include "chrome/browser/ui/cocoa/history_menu_bridge.h"
-#include "base/bind.h"
-#include "base/bind_helpers.h"
+#include "base/callback.h"
#include "base/stl_util.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
@@ -387,8 +386,7 @@ void HistoryMenuBridge::CreateMenu() {
&cancelable_request_consumer_,
base::Time::Now() - base::TimeDelta::FromDays(kMostVisitedScope),
kMostVisitedCount,
- base::Bind(&HistoryMenuBridge::OnVisitedHistoryResults,
- base::Unretained(this)));
+ NewCallback(this, &HistoryMenuBridge::OnVisitedHistoryResults));
}
void HistoryMenuBridge::OnVisitedHistoryResults(
@@ -446,9 +444,9 @@ HistoryMenuBridge::HistoryItem* HistoryMenuBridge::HistoryItemForTab(
void HistoryMenuBridge::GetFaviconForHistoryItem(HistoryItem* item) {
FaviconService* service =
profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
- FaviconService::Handle handle = service->GetFaviconForURL(
- item->url, history::FAVICON, &favicon_consumer_,
- base::Bind(&HistoryMenuBridge::GotFaviconData, base::Unretained(this)));
+ FaviconService::Handle handle = service->GetFaviconForURL(item->url,
+ history::FAVICON, &favicon_consumer_,
+ NewCallback(this, &HistoryMenuBridge::GotFaviconData));
favicon_consumer_.SetClientData(service, handle, item);
item->icon_handle = handle;
item->icon_requested = true;
diff --git a/chrome/browser/ui/cocoa/tabpose_window.mm b/chrome/browser/ui/cocoa/tabpose_window.mm
index 3a75527..6a07d23 100644
--- a/chrome/browser/ui/cocoa/tabpose_window.mm
+++ b/chrome/browser/ui/cocoa/tabpose_window.mm
@@ -10,7 +10,7 @@
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
-#include "base/memory/weak_ptr.h"
+#include "base/memory/scoped_callback_factory.h"
#include "base/sys_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
@@ -136,7 +136,7 @@ namespace tabpose {
class ThumbnailLoader : public base::RefCountedThreadSafe<ThumbnailLoader> {
public:
ThumbnailLoader(gfx::Size size, RenderWidgetHost* rwh, ThumbnailLayer* layer)
- : size_(size), rwh_(rwh), layer_(layer), weak_factory_(this) {}
+ : size_(size), rwh_(rwh), layer_(layer), factory_(this) {}
// Starts the fetch.
void LoadThumbnail();
@@ -160,7 +160,7 @@ class ThumbnailLoader : public base::RefCountedThreadSafe<ThumbnailLoader> {
gfx::Size size_;
RenderWidgetHost* rwh_; // weak
ThumbnailLayer* layer_; // weak, owns us
- base::WeakPtrFactory<ThumbnailLoader> weak_factory_;
+ base::ScopedCallbackFactory<ThumbnailLoader> factory_;
DISALLOW_COPY_AND_ASSIGN(ThumbnailLoader);
};
@@ -185,8 +185,7 @@ void ThumbnailLoader::LoadThumbnail() {
generator->AskForSnapshot(
rwh_,
/*prefer_backing_store=*/false,
- base::Bind(&ThumbnailLoader::DidReceiveBitmap,
- weak_factory_.GetWeakPtr()),
+ factory_.NewCallback(&ThumbnailLoader::DidReceiveBitmap),
page_size,
pixel_size);
}
diff --git a/chrome/browser/ui/intents/web_intent_picker_controller.cc b/chrome/browser/ui/intents/web_intent_picker_controller.cc
index dc89ccf..cbc02ce 100644
--- a/chrome/browser/ui/intents/web_intent_picker_controller.cc
+++ b/chrome/browser/ui/intents/web_intent_picker_controller.cc
@@ -6,8 +6,6 @@
#include <vector>
-#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/intents/web_intents_registry.h"
#include "chrome/browser/intents/web_intents_registry_factory.h"
@@ -261,9 +259,8 @@ void WebIntentPickerController::FaviconFetcher::Fetch(
urls[index],
history::FAVICON,
&load_consumer_,
- base::Bind(
- &WebIntentPickerController::FaviconFetcher::OnFaviconDataAvailable,
- base::Unretained(this)));
+ NewCallback(this, &WebIntentPickerController::FaviconFetcher::
+ OnFaviconDataAvailable));
load_consumer_.SetClientData(favicon_service_, handle, index);
}
}
diff --git a/chrome/browser/ui/search_engines/template_url_table_model.cc b/chrome/browser/ui/search_engines/template_url_table_model.cc
index 30151c9..df098cd 100644
--- a/chrome/browser/ui/search_engines/template_url_table_model.cc
+++ b/chrome/browser/ui/search_engines/template_url_table_model.cc
@@ -4,8 +4,7 @@
#include "chrome/browser/ui/search_engines/template_url_table_model.h"
-#include "base/bind.h"
-#include "base/bind_helpers.h"
+#include "base/callback.h"
#include "base/i18n/rtl.h"
#include "base/stl_util.h"
#include "base/utf_string_conversions.h"
@@ -93,8 +92,7 @@ class ModelEntry {
load_state_ = LOADING;
favicon_service->GetFavicon(favicon_url, history::FAVICON,
&request_consumer_,
- base::Bind(&ModelEntry::OnFaviconDataAvailable,
- base::Unretained(this)));
+ NewCallback(this, &ModelEntry::OnFaviconDataAvailable));
}
void OnFaviconDataAvailable(
diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.cc b/chrome/browser/ui/toolbar/back_forward_menu_model.cc
index c9a9f7e..b634544 100644
--- a/chrome/browser/ui/toolbar/back_forward_menu_model.cc
+++ b/chrome/browser/ui/toolbar/back_forward_menu_model.cc
@@ -6,8 +6,6 @@
#include "chrome/browser/ui/toolbar/back_forward_menu_model.h"
-#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/string_number_conversions.h"
#include "chrome/browser/event_disposition.h"
#include "chrome/browser/prefs/pref_service.h"
@@ -233,8 +231,7 @@ void BackForwardMenuModel::FetchFavicon(NavigationEntry* entry) {
return;
FaviconService::Handle handle = favicon_service->GetFaviconForURL(
entry->url(), history::FAVICON, &load_consumer_,
- base::Bind(&BackForwardMenuModel::OnFavIconDataAvailable,
- base::Unretained(this)));
+ NewCallback(this, &BackForwardMenuModel::OnFavIconDataAvailable));
load_consumer_.SetClientData(favicon_service, handle, entry->unique_id());
}
diff --git a/chrome/browser/ui/webui/chrome_web_ui_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_factory.cc
index bcf2008..09f06cb 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_factory.cc
@@ -340,7 +340,9 @@ void ChromeWebUIFactory::GetFaviconForURL(
favicon.known_icon = favicon.image_data.get() != NULL &&
favicon.image_data->size() > 0;
favicon.icon_type = history::FAVICON;
- request->ForwardResultAsync(request->handle(), favicon);
+ request->ForwardResultAsync(
+ FaviconService::FaviconDataCallback::TupleType(request->handle(),
+ favicon));
}
}
diff --git a/chrome/browser/ui/webui/extension_icon_source.cc b/chrome/browser/ui/webui/extension_icon_source.cc
index 81b0c833..f896457 100644
--- a/chrome/browser/ui/webui/extension_icon_source.cc
+++ b/chrome/browser/ui/webui/extension_icon_source.cc
@@ -4,8 +4,7 @@
#include "chrome/browser/ui/webui/extension_icon_source.h"
-#include "base/bind.h"
-#include "base/bind_helpers.h"
+#include "base/callback.h"
#include "base/memory/ref_counted_memory.h"
#include "base/stl_util.h"
#include "base/string_number_conversions.h"
@@ -242,8 +241,7 @@ void ExtensionIconSource::LoadFaviconImage(int request_id) {
favicon_url,
history::FAVICON,
&cancelable_consumer_,
- base::Bind(&ExtensionIconSource::OnFaviconDataAvailable,
- base::Unretained(this)));
+ NewCallback(this, &ExtensionIconSource::OnFaviconDataAvailable));
cancelable_consumer_.SetClientData(favicon_service, handle, request_id);
}
diff --git a/chrome/browser/ui/webui/favicon_source.cc b/chrome/browser/ui/webui/favicon_source.cc
index 480c2f5..7b66fb7 100644
--- a/chrome/browser/ui/webui/favicon_source.cc
+++ b/chrome/browser/ui/webui/favicon_source.cc
@@ -4,8 +4,7 @@
#include "chrome/browser/ui/webui/favicon_source.h"
-#include "base/bind.h"
-#include "base/bind_helpers.h"
+#include "base/callback.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
#include "grit/ui_resources.h"
@@ -42,8 +41,7 @@ void FaviconSource::StartDataRequest(const std::string& path,
GURL(path.substr(8)),
history::FAVICON,
&cancelable_consumer_,
- base::Bind(&FaviconSource::OnFaviconDataAvailable,
- base::Unretained(this)));
+ NewCallback(this, &FaviconSource::OnFaviconDataAvailable));
} else {
GURL url;
@@ -65,8 +63,7 @@ void FaviconSource::StartDataRequest(const std::string& path,
url,
icon_types_,
&cancelable_consumer_,
- base::Bind(&FaviconSource::OnFaviconDataAvailable,
- base::Unretained(this)));
+ NewCallback(this, &FaviconSource::OnFaviconDataAvailable));
}
// Attach the ChromeURLDataManager request ID to the history request.
cancelable_consumer_.SetClientData(favicon_service, handle, request_id);
diff --git a/chrome/browser/ui/webui/history2_ui.cc b/chrome/browser/ui/webui/history2_ui.cc
index 48cb4fa..7b80a82 100644
--- a/chrome/browser/ui/webui/history2_ui.cc
+++ b/chrome/browser/ui/webui/history2_ui.cc
@@ -150,8 +150,7 @@ void BrowsingHistoryHandler2::HandleGetHistory(const ListValue* args) {
hs->QueryHistory(search_text_,
options,
&cancelable_search_consumer_,
- base::Bind(&BrowsingHistoryHandler2::QueryComplete,
- base::Unretained(this)));
+ NewCallback(this, &BrowsingHistoryHandler2::QueryComplete));
}
void BrowsingHistoryHandler2::HandleSearchHistory(const ListValue* args) {
@@ -176,8 +175,7 @@ void BrowsingHistoryHandler2::HandleSearchHistory(const ListValue* args) {
hs->QueryHistory(search_text_,
options,
&cancelable_search_consumer_,
- base::Bind(&BrowsingHistoryHandler2::QueryComplete,
- base::Unretained(this)));
+ NewCallback(this, &BrowsingHistoryHandler2::QueryComplete));
}
void BrowsingHistoryHandler2::HandleRemoveURLsOnOneDay(const ListValue* args) {
@@ -218,8 +216,7 @@ void BrowsingHistoryHandler2::HandleRemoveURLsOnOneDay(const ListValue* args) {
Profile::FromWebUI(web_ui_)->GetHistoryService(Profile::EXPLICIT_ACCESS);
hs->ExpireHistoryBetween(
urls_to_be_deleted_, begin_time, end_time, &cancelable_delete_consumer_,
- base::Bind(&BrowsingHistoryHandler2::RemoveComplete,
- base::Unretained(this)));
+ NewCallback(this, &BrowsingHistoryHandler2::RemoveComplete));
}
void BrowsingHistoryHandler2::HandleClearBrowsingData(const ListValue* args) {
diff --git a/chrome/browser/ui/webui/history_ui.cc b/chrome/browser/ui/webui/history_ui.cc
index ba1a648..f88d4db 100644
--- a/chrome/browser/ui/webui/history_ui.cc
+++ b/chrome/browser/ui/webui/history_ui.cc
@@ -181,8 +181,7 @@ void BrowsingHistoryHandler::HandleGetHistory(const ListValue* args) {
hs->QueryHistory(search_text_,
options,
&cancelable_search_consumer_,
- base::Bind(&BrowsingHistoryHandler::QueryComplete,
- base::Unretained(this)));
+ NewCallback(this, &BrowsingHistoryHandler::QueryComplete));
}
void BrowsingHistoryHandler::HandleSearchHistory(const ListValue* args) {
@@ -207,8 +206,7 @@ void BrowsingHistoryHandler::HandleSearchHistory(const ListValue* args) {
hs->QueryHistory(search_text_,
options,
&cancelable_search_consumer_,
- base::Bind(&BrowsingHistoryHandler::QueryComplete,
- base::Unretained(this)));
+ NewCallback(this, &BrowsingHistoryHandler::QueryComplete));
}
void BrowsingHistoryHandler::HandleRemoveURLsOnOneDay(const ListValue* args) {
@@ -244,8 +242,7 @@ void BrowsingHistoryHandler::HandleRemoveURLsOnOneDay(const ListValue* args) {
Profile::FromWebUI(web_ui_)->GetHistoryService(Profile::EXPLICIT_ACCESS);
hs->ExpireHistoryBetween(
urls, begin_time, end_time, &cancelable_delete_consumer_,
- base::Bind(&BrowsingHistoryHandler::RemoveComplete,
- base::Unretained(this)));
+ NewCallback(this, &BrowsingHistoryHandler::RemoveComplete));
}
void BrowsingHistoryHandler::HandleClearBrowsingData(const ListValue* args) {
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
index 3651009..111f9a7 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -792,7 +792,7 @@ void AppLauncherHandler::HandleGenerateAppForLink(const ListValue* args) {
FaviconService::Handle h = favicon_service->GetFaviconForURL(
launch_url, history::FAVICON, &favicon_consumer_,
- base::Bind(&AppLauncherHandler::OnFaviconForApp, base::Unretained(this)));
+ NewCallback(this, &AppLauncherHandler::OnFaviconForApp));
favicon_consumer_.SetClientData(favicon_service, h, install_info.release());
}
diff --git a/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc b/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc
index 0ae6443..f4e9688 100644
--- a/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc
+++ b/chrome/browser/ui/webui/ntp/favicon_webui_handler.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h"
#include "base/bind.h"
-#include "base/bind_helpers.h"
+#include "base/callback_old.h"
#include "base/string_split.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
@@ -77,8 +77,7 @@ void FaviconWebUIHandler::HandleGetFaviconDominantColor(const ListValue* args) {
GURL(path),
history::FAVICON,
&consumer_,
- base::Bind(&FaviconWebUIHandler::OnFaviconDataAvailable,
- base::Unretained(this)));
+ NewCallback(this, &FaviconWebUIHandler::OnFaviconDataAvailable));
consumer_.SetClientData(favicon_service, handle, id_++);
}
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index f2e6f8a..c664f77 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -6,8 +6,6 @@
#include <vector>
-#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/file_path.h"
@@ -931,7 +929,7 @@ class SnapshotTaker {
generator->AskForSnapshot(
rwh,
false, // don't use backing_store
- base::Bind(&SnapshotTaker::OnSnapshotTaken, base::Unretained(this)),
+ NewCallback(this, &SnapshotTaker::OnSnapshotTaken),
page_size,
desired_size);
ui_test_utils::RunMessageLoop();