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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_custom_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_custom_dictionary.h" 5 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <functional> 9 #include <functional>
10 #include <utility> 10 #include <utility>
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 void SpellcheckCustomDictionary::OnLoaded( 418 void SpellcheckCustomDictionary::OnLoaded(
419 std::unique_ptr<LoadFileResult> result) { 419 std::unique_ptr<LoadFileResult> result) {
420 DCHECK_CURRENTLY_ON(BrowserThread::UI); 420 DCHECK_CURRENTLY_ON(BrowserThread::UI);
421 DCHECK(result); 421 DCHECK(result);
422 Change dictionary_change; 422 Change dictionary_change;
423 dictionary_change.AddWords(result->words); 423 dictionary_change.AddWords(result->words);
424 dictionary_change.Sanitize(GetWords()); 424 dictionary_change.Sanitize(GetWords());
425 Apply(dictionary_change); 425 Apply(dictionary_change);
426 Sync(dictionary_change); 426 Sync(dictionary_change);
427 is_loaded_ = true; 427 is_loaded_ = true;
428 FOR_EACH_OBSERVER(Observer, observers_, OnCustomDictionaryLoaded()); 428 for (Observer& observer : observers_)
429 observer.OnCustomDictionaryLoaded();
429 if (!result->is_valid_file) { 430 if (!result->is_valid_file) {
430 // Save cleaned up data only after startup. 431 // Save cleaned up data only after startup.
431 fix_invalid_file_.Reset( 432 fix_invalid_file_.Reset(
432 base::Bind(&SpellcheckCustomDictionary::FixInvalidFile, 433 base::Bind(&SpellcheckCustomDictionary::FixInvalidFile,
433 weak_ptr_factory_.GetWeakPtr(), base::Passed(&result))); 434 weak_ptr_factory_.GetWeakPtr(), base::Passed(&result)));
434 BrowserThread::PostAfterStartupTask( 435 BrowserThread::PostAfterStartupTask(
435 FROM_HERE, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), 436 FROM_HERE, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
436 fix_invalid_file_.callback()); 437 fix_invalid_file_.callback());
437 } 438 }
438 } 439 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 if (words_.size() > spellcheck::MAX_SYNCABLE_DICTIONARY_WORDS) 516 if (words_.size() > spellcheck::MAX_SYNCABLE_DICTIONARY_WORDS)
516 StopSyncing(syncer::DICTIONARY); 517 StopSyncing(syncer::DICTIONARY);
517 518
518 return error; 519 return error;
519 } 520 }
520 521
521 void SpellcheckCustomDictionary::Notify(const Change& dictionary_change) { 522 void SpellcheckCustomDictionary::Notify(const Change& dictionary_change) {
522 DCHECK_CURRENTLY_ON(BrowserThread::UI); 523 DCHECK_CURRENTLY_ON(BrowserThread::UI);
523 if (!IsLoaded() || dictionary_change.empty()) 524 if (!IsLoaded() || dictionary_change.empty())
524 return; 525 return;
525 FOR_EACH_OBSERVER(Observer, 526 for (Observer& observer : observers_)
526 observers_, 527 observer.OnCustomDictionaryChanged(dictionary_change);
527 OnCustomDictionaryChanged(dictionary_change));
528 } 528 }
OLDNEW
« no previous file with comments | « chrome/browser/search/instant_service.cc ('k') | chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698