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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc

Issue 2439493002: Reduce usage of FOR_EACH_OBSERVER macro in chrome/browser (Closed)
Patch Set: Created 4 years, 2 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/spellchecker/spellcheck_hunspell_dictionary.h" 5 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 240
241 return GURL(std::string(kDownloadServerUrl) + 241 return GURL(std::string(kDownloadServerUrl) +
242 base::ToLowerASCII(bdict_file)); 242 base::ToLowerASCII(bdict_file));
243 } 243 }
244 244
245 void SpellcheckHunspellDictionary::DownloadDictionary(GURL url) { 245 void SpellcheckHunspellDictionary::DownloadDictionary(GURL url) {
246 DCHECK_CURRENTLY_ON(BrowserThread::UI); 246 DCHECK_CURRENTLY_ON(BrowserThread::UI);
247 DCHECK(request_context_getter_); 247 DCHECK(request_context_getter_);
248 248
249 download_status_ = DOWNLOAD_IN_PROGRESS; 249 download_status_ = DOWNLOAD_IN_PROGRESS;
250 FOR_EACH_OBSERVER(Observer, observers_, 250 for (Observer& observer : observers_)
251 OnHunspellDictionaryDownloadBegin(language_)); 251 observer.OnHunspellDictionaryDownloadBegin(language_);
252 252
253 fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this); 253 fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this);
254 data_use_measurement::DataUseUserData::AttachToFetcher( 254 data_use_measurement::DataUseUserData::AttachToFetcher(
255 fetcher_.get(), data_use_measurement::DataUseUserData::SPELL_CHECKER); 255 fetcher_.get(), data_use_measurement::DataUseUserData::SPELL_CHECKER);
256 fetcher_->SetRequestContext(request_context_getter_); 256 fetcher_->SetRequestContext(request_context_getter_);
257 fetcher_->SetLoadFlags( 257 fetcher_->SetLoadFlags(
258 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); 258 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES);
259 fetcher_->Start(); 259 fetcher_->Start();
260 // Attempt downloading the dictionary only once. 260 // Attempt downloading the dictionary only once.
261 request_context_getter_ = NULL; 261 request_context_getter_ = NULL;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 353
354 InformListenersOfInitialization(); 354 InformListenersOfInitialization();
355 } 355 }
356 356
357 void SpellcheckHunspellDictionary::SaveDictionaryDataComplete( 357 void SpellcheckHunspellDictionary::SaveDictionaryDataComplete(
358 bool dictionary_saved) { 358 bool dictionary_saved) {
359 DCHECK_CURRENTLY_ON(BrowserThread::UI); 359 DCHECK_CURRENTLY_ON(BrowserThread::UI);
360 360
361 if (dictionary_saved) { 361 if (dictionary_saved) {
362 download_status_ = DOWNLOAD_NONE; 362 download_status_ = DOWNLOAD_NONE;
363 FOR_EACH_OBSERVER(Observer, 363 for (Observer& observer : observers_)
364 observers_, 364 observer.OnHunspellDictionaryDownloadSuccess(language_);
365 OnHunspellDictionaryDownloadSuccess(language_));
366 Load(); 365 Load();
367 } else { 366 } else {
368 InformListenersOfDownloadFailure(); 367 InformListenersOfDownloadFailure();
369 InformListenersOfInitialization(); 368 InformListenersOfInitialization();
370 } 369 }
371 } 370 }
372 371
373 void SpellcheckHunspellDictionary::InformListenersOfInitialization() { 372 void SpellcheckHunspellDictionary::InformListenersOfInitialization() {
374 FOR_EACH_OBSERVER(Observer, observers_, 373 for (Observer& observer : observers_)
375 OnHunspellDictionaryInitialized(language_)); 374 observer.OnHunspellDictionaryInitialized(language_);
376 } 375 }
377 376
378 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { 377 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() {
379 download_status_ = DOWNLOAD_FAILED; 378 download_status_ = DOWNLOAD_FAILED;
380 FOR_EACH_OBSERVER(Observer, 379 for (Observer& observer : observers_)
381 observers_, 380 observer.OnHunspellDictionaryDownloadFailure(language_);
382 OnHunspellDictionaryDownloadFailure(language_));
383 } 381 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_custom_dictionary.cc ('k') | chrome/browser/task_manager/task_manager_interface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698