Chromium Code Reviews| Index: chrome/browser/search_engines/search_provider_install_data.cc |
| diff --git a/chrome/browser/search_engines/search_provider_install_data.cc b/chrome/browser/search_engines/search_provider_install_data.cc |
| index bc1b77b04e6c15433d4ce4125e5a464c99582a5e..9da94b3d0342bc42e8d8a50206d184d119fa5fdb 100644 |
| --- a/chrome/browser/search_engines/search_provider_install_data.cc |
| +++ b/chrome/browser/search_engines/search_provider_install_data.cc |
| @@ -7,9 +7,9 @@ |
| #include <vector> |
| #include "base/basictypes.h" |
| +#include "base/bind.h" |
| #include "base/logging.h" |
| #include "base/memory/ref_counted.h" |
| -#include "base/task.h" |
| #include "chrome/browser/search_engines/search_host_to_urls_map.h" |
| #include "chrome/browser/search_engines/search_terms_data.h" |
| #include "chrome/browser/search_engines/template_url.h" |
| @@ -138,9 +138,9 @@ void GoogleURLObserver::Observe(int type, |
| const content::NotificationDetails& details) { |
| if (type == chrome::NOTIFICATION_GOOGLE_URL_UPDATED) { |
| BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| - NewRunnableMethod(change_notifier_.get(), |
| - &GoogleURLChangeNotifier::OnChange, |
| - UIThreadSearchTermsData().GoogleBaseURLValue())); |
| + base::Bind(&GoogleURLChangeNotifier::OnChange, |
| + change_notifier_.get(), |
| + UIThreadSearchTermsData().GoogleBaseURLValue())); |
| } else { |
| // This must be the death notification. |
| delete this; |
| @@ -185,16 +185,15 @@ SearchProviderInstallData::~SearchProviderInstallData() { |
| } |
| } |
| -void SearchProviderInstallData::CallWhenLoaded(Task* task) { |
| +void SearchProviderInstallData::CallWhenLoaded(const base::Closure& closure) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| if (provider_map_.get()) { |
| - task->Run(); |
| - delete task; |
| + closure.Run(); |
| return; |
| } |
| - task_queue_.Push(task); |
| + closure_queue_.push_back(closure); |
| if (load_handle_) |
| return; |
| @@ -300,7 +299,12 @@ void SearchProviderInstallData::OnLoadFailed() { |
| void SearchProviderInstallData::NotifyLoaded() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| - task_queue_.Run(); |
| + for (std::vector<base::Closure>::const_iterator it = closure_queue_.begin(); |
| + it != closure_queue_.end(); |
| + ++it) { |
| + it->Run(); |
| + } |
| + closure_queue_.clear(); |
|
sky
2011/11/16 04:42:17
I've feel better if you created a vector on the st
dcheng
2011/11/16 10:00:39
Done for both, but any particular reason for prefe
|
| // Since we expect this request to be rare, clear out the information. This |
| // also keeps the responses current as the search providers change. |