summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-05 18:09:30 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-05 18:09:30 +0000
commit75b3ac9112bcc3a126d260cd7b3f2f0b08d041dd (patch)
tree028a2620aa7037c882adfa32a5e114b69a9e9288
parent557730ad6fc06e82c1270142c25540046c35226d (diff)
downloadchromium_src-75b3ac9112bcc3a126d260cd7b3f2f0b08d041dd.zip
chromium_src-75b3ac9112bcc3a126d260cd7b3f2f0b08d041dd.tar.gz
chromium_src-75b3ac9112bcc3a126d260cd7b3f2f0b08d041dd.tar.bz2
base::Bind: Cleanup in history/ plus dependencies.
cancelable_request.h change by ajwong@chromium.org BUG=none TEST=none R=ajwong@chromium.org Review URL: http://codereview.chromium.org/8142021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104136 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browsing_data_remover_unittest.cc4
-rw-r--r--chrome/browser/custom_home_pages_table_model.cc5
-rw-r--r--chrome/browser/extensions/extension_history_api.cc5
-rw-r--r--chrome/browser/history/history.cc2
-rw-r--r--chrome/browser/history/history.h12
-rw-r--r--chrome/browser/history/history_backend.cc3
-rw-r--r--chrome/browser/history/history_unittest.cc5
-rw-r--r--chrome/browser/safe_browsing/browser_feature_extractor.cc6
-rw-r--r--chrome/browser/search_engines/template_url_service_unittest.cc5
-rw-r--r--content/browser/cancelable_request.h5
10 files changed, 36 insertions, 16 deletions
diff --git a/chrome/browser/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data_remover_unittest.cc
index ad501dc..afc0249 100644
--- a/chrome/browser/browsing_data_remover_unittest.cc
+++ b/chrome/browser/browsing_data_remover_unittest.cc
@@ -7,6 +7,7 @@
#include <set>
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/message_loop.h"
#include "base/platform_file.h"
#include "chrome/browser/extensions/mock_extension_special_storage_policy.h"
@@ -148,7 +149,8 @@ class RemoveHistoryTester : public BrowsingDataRemoverTester {
url,
true,
&consumer_,
- NewCallback(this, &RemoveHistoryTester::SaveResultAndQuit));
+ base::Bind(&RemoveHistoryTester::SaveResultAndQuit,
+ base::Unretained(this)));
BlockUntilNotified();
return query_url_success_;
}
diff --git a/chrome/browser/custom_home_pages_table_model.cc b/chrome/browser/custom_home_pages_table_model.cc
index 3e9fd56..9f09f92 100644
--- a/chrome/browser/custom_home_pages_table_model.cc
+++ b/chrome/browser/custom_home_pages_table_model.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/custom_home_pages_table_model.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/i18n/rtl.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/prefs/pref_service.h"
@@ -216,7 +218,8 @@ void CustomHomePagesTableModel::LoadTitleAndFavicon(Entry* entry) {
if (history_service) {
entry->title_handle = history_service->QueryURL(entry->url, false,
&history_query_consumer_,
- NewCallback(this, &CustomHomePagesTableModel::OnGotTitle));
+ base::Bind(&CustomHomePagesTableModel::OnGotTitle,
+ base::Unretained(this)));
}
FaviconService* favicon_service =
profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
diff --git a/chrome/browser/extensions/extension_history_api.cc b/chrome/browser/extensions/extension_history_api.cc
index b88113c..3f4dda7 100644
--- a/chrome/browser/extensions/extension_history_api.cc
+++ b/chrome/browser/extensions/extension_history_api.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/extensions/extension_history_api.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/json/json_writer.h"
#include "base/message_loop.h"
@@ -218,7 +220,8 @@ bool GetVisitsHistoryFunction::RunAsyncImpl() {
hs->QueryURL(url,
true, // Retrieve full history of a URL.
&cancelable_consumer_,
- NewCallback(this, &GetVisitsHistoryFunction::QueryComplete));
+ base::Bind(&GetVisitsHistoryFunction::QueryComplete,
+ base::Unretained(this)));
return true;
}
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc
index 6957e3a4..d7508d3 100644
--- a/chrome/browser/history/history.cc
+++ b/chrome/browser/history/history.cc
@@ -497,7 +497,7 @@ HistoryService::Handle HistoryService::QueryURL(
const GURL& url,
bool want_visits,
CancelableRequestConsumerBase* consumer,
- QueryURLCallback* callback) {
+ const QueryURLCallback& callback) {
return Schedule(PRIORITY_UI, &HistoryBackend::QueryURL, consumer,
new history::QueryURLRequest(callback), url, want_visits);
}
diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h
index 4c79d5d..af513c2 100644
--- a/chrome/browser/history/history.h
+++ b/chrome/browser/history/history.h
@@ -266,11 +266,11 @@ class HistoryService : public CancelableRequestProvider,
// empty.
//
// If success is false, neither the row nor the vector will be valid.
- typedef Callback4<Handle,
- bool, // Success flag, when false, nothing else is valid.
- const history::URLRow*,
- history::VisitVector*>::Type
- QueryURLCallback;
+ typedef base::Callback<void(
+ Handle,
+ bool, // Success flag, when false, nothing else is valid.
+ const history::URLRow*,
+ history::VisitVector*)> QueryURLCallback;
// Queries the basic information about the URL in the history database. If
// the caller is interested in the visits (each time the URL is visited),
@@ -279,7 +279,7 @@ class HistoryService : public CancelableRequestProvider,
Handle QueryURL(const GURL& url,
bool want_visits,
CancelableRequestConsumerBase* consumer,
- QueryURLCallback* callback);
+ const QueryURLCallback& callback);
// 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
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
index e6b3593..d9cac45 100644
--- a/chrome/browser/history/history_backend.cc
+++ b/chrome/browser/history/history_backend.cc
@@ -988,8 +988,7 @@ void HistoryBackend::QueryURL(scoped_refptr<QueryURLRequest> request,
db_->GetVisitsForURL(row->id(), visits);
}
}
- request->ForwardResult(QueryURLRequest::TupleType(request->handle(), success,
- row, visits));
+ request->ForwardResult(request->handle(), success, row, visits);
}
// Segment usage ---------------------------------------------------------------
diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc
index def4f40..2cd7a2d 100644
--- a/chrome/browser/history/history_unittest.cc
+++ b/chrome/browser/history/history_unittest.cc
@@ -23,6 +23,8 @@
#include <string>
#include "base/basictypes.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/file_path.h"
@@ -203,7 +205,8 @@ class HistoryTest : public testing::Test {
// found, this will return false and those structures will not be changed.
bool QueryURL(HistoryService* history, const GURL& url) {
history->QueryURL(url, true, &consumer_,
- NewCallback(this, &HistoryTest::SaveURLAndQuit));
+ base::Bind(&HistoryTest::SaveURLAndQuit,
+ base::Unretained(this)));
MessageLoop::current()->Run(); // Will be exited in SaveURLAndQuit.
return query_url_success_;
}
diff --git a/chrome/browser/safe_browsing/browser_feature_extractor.cc b/chrome/browser/safe_browsing/browser_feature_extractor.cc
index 69415a5..9333b9f 100644
--- a/chrome/browser/safe_browsing/browser_feature_extractor.cc
+++ b/chrome/browser/safe_browsing/browser_feature_extractor.cc
@@ -7,6 +7,8 @@
#include <map>
#include <utility>
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/stl_util.h"
#include "base/stringprintf.h"
#include "base/string_util.h"
@@ -249,8 +251,8 @@ void BrowserFeatureExtractor::StartExtractFeatures(
GURL(request->url()),
true /* wants_visits */,
&request_consumer_,
- NewCallback(this,
- &BrowserFeatureExtractor::QueryUrlHistoryDone));
+ base::Bind(&BrowserFeatureExtractor::QueryUrlHistoryDone,
+ base::Unretained(this)));
StorePendingQuery(handle, request, callback);
}
diff --git a/chrome/browser/search_engines/template_url_service_unittest.cc b/chrome/browser/search_engines/template_url_service_unittest.cc
index 7661ec1..efbbe9d 100644
--- a/chrome/browser/search_engines/template_url_service_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
@@ -941,7 +943,8 @@ TEST_F(TemplateURLServiceTest, GenerateVisitOnKeyword) {
CancelableRequestConsumer consumer;
QueryHistoryCallbackImpl callback;
history->QueryURL(GURL("http://keyword"), true, &consumer,
- NewCallback(&callback, &QueryHistoryCallbackImpl::Callback));
+ base::Bind(&QueryHistoryCallbackImpl::Callback,
+ base::Unretained(&callback)));
// Wait for the request to be processed.
profile()->BlockUntilHistoryProcessesPendingRequests();
diff --git a/content/browser/cancelable_request.h b/content/browser/cancelable_request.h
index 0e51a9e..6df0c63 100644
--- a/content/browser/cancelable_request.h
+++ b/content/browser/cancelable_request.h
@@ -966,6 +966,11 @@ class CancelableRequest1 : public CancelableRequest<CB> {
: CancelableRequest<CB>(callback) {
}
+ explicit CancelableRequest1(
+ const typename CancelableRequest<CB>::CallbackType& callback)
+ : CancelableRequest<CB>(callback) {
+ }
+
// The value.
Type value;