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

Side by Side Diff: chrome/browser/search_engines/search_provider_install_data.cc

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/search_engines/search_provider_install_data.h" 5 #include "chrome/browser/search_engines/search_provider_install_data.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <utility>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/sequenced_task_runner_helpers.h" 17 #include "base/sequenced_task_runner_helpers.h"
17 #include "components/google/core/browser/google_url_tracker.h" 18 #include "components/google/core/browser/google_url_tracker.h"
18 #include "components/search_engines/search_host_to_urls_map.h" 19 #include "components/search_engines/search_host_to_urls_map.h"
(...skipping 21 matching lines...) Expand all
40 TemplateURL* original_default_provider = 41 TemplateURL* original_default_provider =
41 template_url_service->GetDefaultSearchProvider(); 42 template_url_service->GetDefaultSearchProvider();
42 for (TemplateURLService::TemplateURLVector::const_iterator it = 43 for (TemplateURLService::TemplateURLVector::const_iterator it =
43 original_template_urls.begin(); 44 original_template_urls.begin();
44 it != original_template_urls.end(); 45 it != original_template_urls.end();
45 ++it) { 46 ++it) {
46 template_url_copies.push_back(new TemplateURL((*it)->data())); 47 template_url_copies.push_back(new TemplateURL((*it)->data()));
47 if (*it == original_default_provider) 48 if (*it == original_default_provider)
48 default_provider_copy = template_url_copies.back(); 49 default_provider_copy = template_url_copies.back();
49 } 50 }
50 BrowserThread::PostTask(BrowserThread::IO, 51 BrowserThread::PostTask(
51 FROM_HERE, 52 BrowserThread::IO, FROM_HERE,
52 base::Bind(callback, 53 base::Bind(callback, base::Passed(std::move(template_url_copies)),
53 base::Passed(template_url_copies.Pass()), 54 base::Unretained(default_provider_copy)));
54 base::Unretained(default_provider_copy)));
55 } 55 }
56 56
57 // Implementation of SearchTermsData that may be used on the I/O thread. 57 // Implementation of SearchTermsData that may be used on the I/O thread.
58 class IOThreadSearchTermsData : public SearchTermsData { 58 class IOThreadSearchTermsData : public SearchTermsData {
59 public: 59 public:
60 explicit IOThreadSearchTermsData(const std::string& google_base_url); 60 explicit IOThreadSearchTermsData(const std::string& google_base_url);
61 61
62 // Implementation of SearchTermsData. 62 // Implementation of SearchTermsData.
63 std::string GoogleBaseURLValue() const override; 63 std::string GoogleBaseURLValue() const override;
64 64
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 void SearchProviderInstallData::OnGoogleURLChange( 255 void SearchProviderInstallData::OnGoogleURLChange(
256 const std::string& google_base_url) { 256 const std::string& google_base_url) {
257 google_base_url_ = google_base_url; 257 google_base_url_ = google_base_url;
258 } 258 }
259 259
260 void SearchProviderInstallData::OnTemplateURLsLoaded( 260 void SearchProviderInstallData::OnTemplateURLsLoaded(
261 ScopedVector<TemplateURL> template_urls, 261 ScopedVector<TemplateURL> template_urls,
262 TemplateURL* default_provider) { 262 TemplateURL* default_provider) {
263 DCHECK_CURRENTLY_ON(BrowserThread::IO); 263 DCHECK_CURRENTLY_ON(BrowserThread::IO);
264 264
265 template_urls_ = template_urls.Pass(); 265 template_urls_ = std::move(template_urls);
266 266
267 IOThreadSearchTermsData search_terms_data(google_base_url_); 267 IOThreadSearchTermsData search_terms_data(google_base_url_);
268 provider_map_.reset(new SearchHostToURLsMap()); 268 provider_map_.reset(new SearchHostToURLsMap());
269 provider_map_->Init(template_urls_.get(), search_terms_data); 269 provider_map_->Init(template_urls_.get(), search_terms_data);
270 SetDefault(default_provider); 270 SetDefault(default_provider);
271 NotifyLoaded(); 271 NotifyLoaded();
272 } 272 }
273 273
274 void SearchProviderInstallData::SetDefault(const TemplateURL* template_url) { 274 void SearchProviderInstallData::SetDefault(const TemplateURL* template_url) {
275 DCHECK_CURRENTLY_ON(BrowserThread::IO); 275 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 std::for_each(closure_queue.begin(), 309 std::for_each(closure_queue.begin(),
310 closure_queue.end(), 310 closure_queue.end(),
311 std::mem_fun_ref(&base::Closure::Run)); 311 std::mem_fun_ref(&base::Closure::Run));
312 312
313 // Since we expect this request to be rare, clear out the information. This 313 // Since we expect this request to be rare, clear out the information. This
314 // also keeps the responses current as the search providers change. 314 // also keeps the responses current as the search providers change.
315 provider_map_.reset(); 315 provider_map_.reset();
316 SetDefault(NULL); 316 SetDefault(NULL);
317 } 317 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698