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

Unified Diff: chrome/browser/search/suggestions/suggestions_service.cc

Issue 170743009: Revert of Adding the chrome://suggestions test page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search/suggestions/suggestions_service.cc
diff --git a/chrome/browser/search/suggestions/suggestions_service.cc b/chrome/browser/search/suggestions/suggestions_service.cc
index 3565994173b48609e995049056d42a89acff2281..6d7650bce18c2d783ac4284ac0bb186e81f0a4dc 100644
--- a/chrome/browser/search/suggestions/suggestions_service.cc
+++ b/chrome/browser/search/suggestions/suggestions_service.cc
@@ -48,18 +48,6 @@
key);
}
-// Runs each callback in |requestors| on |suggestions|, then deallocates
-// |requestors|.
-void DispatchRequestsAndClear(
- const SuggestionsProfile& suggestions,
- std::vector<SuggestionsService::ResponseCallback>* requestors) {
- std::vector<SuggestionsService::ResponseCallback>::iterator it;
- for (it = requestors->begin(); it != requestors->end(); ++it) {
- it->Run(suggestions);
- }
- std::vector<SuggestionsService::ResponseCallback>().swap(*requestors);
-}
-
} // namespace
const char kSuggestionsFieldTrialName[] = "ChromeSuggestions";
@@ -82,19 +70,8 @@
kSuggestionsFieldTrialStateEnabled;
}
-void SuggestionsService::FetchSuggestionsData(
- SuggestionsService::ResponseCallback callback) {
+void SuggestionsService::FetchSuggestionsData() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
-
- if (pending_request_.get()) {
- // Request already exists, so just add requestor to queue.
- waiting_requestors_.push_back(callback);
- return;
- }
-
- // Form new request.
- DCHECK(waiting_requestors_.empty());
- waiting_requestors_.push_back(callback);
pending_request_.reset(net::URLFetcher::Create(
0, suggestions_url_, net::URLFetcher::GET, this));
@@ -102,9 +79,9 @@
pending_request_->SetRequestContext(profile_->GetRequestContext());
// Add Chrome experiment state to the request headers.
net::HttpRequestHeaders headers;
- chrome_variations::VariationsHttpHeaderProvider::GetInstance()->
- AppendHeaders(pending_request_->GetOriginalURL(),
- profile_->IsOffTheRecord(), false, &headers);
+ chrome_variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders(
+ pending_request_->GetOriginalURL(), profile_->IsOffTheRecord(), false,
+ &headers);
pending_request_->SetExtraRequestHeaders(headers.ToString());
pending_request_->Start();
@@ -112,7 +89,6 @@
}
void SuggestionsService::OnURLFetchComplete(const net::URLFetcher* source) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
DCHECK_EQ(pending_request_.get(), source);
// The fetcher will be deleted when the request is handled.
@@ -138,28 +114,15 @@
std::string suggestions_data;
bool success = request->GetResponseAsString(&suggestions_data);
+
DCHECK(success);
-
- // Compute suggestions, and dispatch then to requestors. On error still
- // dispatch empty suggestions.
- SuggestionsProfile suggestions;
if (suggestions_data.empty()) {
LogResponseState(RESPONSE_EMPTY);
- } else if (suggestions.ParseFromString(suggestions_data)) {
+ } else if (suggestions_.ParseFromString(suggestions_data)) {
LogResponseState(RESPONSE_VALID);
} else {
LogResponseState(RESPONSE_INVALID);
}
-
- DispatchRequestsAndClear(suggestions, &waiting_requestors_);
-}
-
-void SuggestionsService::Shutdown() {
- // Cancel pending request.
- pending_request_.reset(NULL);
-
- // Dispatch empty suggestions to requestors.
- DispatchRequestsAndClear(SuggestionsProfile(), &waiting_requestors_);
}
} // namespace suggestions

Powered by Google App Engine
This is Rietveld 408576698