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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service.cc

Issue 2061563002: To reproduce crashes of JSONPrefStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bug-614753-fix2
Patch Set: Test patch. Do not commit. Created 4 years, 6 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
« no previous file with comments | « chrome/browser/profiles/profile_manager_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/safe_browsing/safe_browsing_service.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 case chrome::NOTIFICATION_PROFILE_CREATED: { 602 case chrome::NOTIFICATION_PROFILE_CREATED: {
603 DCHECK_CURRENTLY_ON(BrowserThread::UI); 603 DCHECK_CURRENTLY_ON(BrowserThread::UI);
604 Profile* profile = content::Source<Profile>(source).ptr(); 604 Profile* profile = content::Source<Profile>(source).ptr();
605 if (!profile->IsOffTheRecord()) 605 if (!profile->IsOffTheRecord())
606 AddPrefService(profile->GetPrefs()); 606 AddPrefService(profile->GetPrefs());
607 break; 607 break;
608 } 608 }
609 case chrome::NOTIFICATION_PROFILE_DESTROYED: { 609 case chrome::NOTIFICATION_PROFILE_DESTROYED: {
610 DCHECK_CURRENTLY_ON(BrowserThread::UI); 610 DCHECK_CURRENTLY_ON(BrowserThread::UI);
611 Profile* profile = content::Source<Profile>(source).ptr(); 611 Profile* profile = content::Source<Profile>(source).ptr();
612 PrefService* pref_service = profile->GetPrefs();
612 if (!profile->IsOffTheRecord()) 613 if (!profile->IsOffTheRecord())
613 RemovePrefService(profile->GetPrefs()); 614 RemovePrefService(pref_service);
614 break; 615 break;
615 } 616 }
616 default: 617 default:
617 NOTREACHED(); 618 NOTREACHED();
618 } 619 }
619 } 620 }
620 621
621 void SafeBrowsingService::AddPrefService(PrefService* pref_service) { 622 void SafeBrowsingService::AddPrefService(PrefService* pref_service) {
622 DCHECK(prefs_map_.find(pref_service) == prefs_map_.end()); 623 DCHECK(prefs_map_.find(pref_service) == prefs_map_.end());
623 PrefChangeRegistrar* registrar = new PrefChangeRegistrar(); 624 PrefChangeRegistrar* registrar = new PrefChangeRegistrar();
(...skipping 11 matching lines...) Expand all
635 636
636 // Record the current pref state. 637 // Record the current pref state.
637 UMA_HISTOGRAM_BOOLEAN("SafeBrowsing.Pref.General", 638 UMA_HISTOGRAM_BOOLEAN("SafeBrowsing.Pref.General",
638 pref_service->GetBoolean(prefs::kSafeBrowsingEnabled)); 639 pref_service->GetBoolean(prefs::kSafeBrowsingEnabled));
639 UMA_HISTOGRAM_BOOLEAN( 640 UMA_HISTOGRAM_BOOLEAN(
640 "SafeBrowsing.Pref.Extended", 641 "SafeBrowsing.Pref.Extended",
641 pref_service->GetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled)); 642 pref_service->GetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled));
642 } 643 }
643 644
644 void SafeBrowsingService::RemovePrefService(PrefService* pref_service) { 645 void SafeBrowsingService::RemovePrefService(PrefService* pref_service) {
646 // If the profile fails to initialize, then |pref_service| was not added
647 // before, and therefore there is nothing to remove.
645 if (prefs_map_.find(pref_service) != prefs_map_.end()) { 648 if (prefs_map_.find(pref_service) != prefs_map_.end()) {
646 delete prefs_map_[pref_service]; 649 delete prefs_map_[pref_service];
647 prefs_map_.erase(pref_service); 650 prefs_map_.erase(pref_service);
648 RefreshState(); 651 RefreshState();
649 } else {
650 NOTREACHED();
651 } 652 }
652 } 653 }
653 654
654 std::unique_ptr<SafeBrowsingService::StateSubscription> 655 std::unique_ptr<SafeBrowsingService::StateSubscription>
655 SafeBrowsingService::RegisterStateCallback( 656 SafeBrowsingService::RegisterStateCallback(
656 const base::Callback<void(void)>& callback) { 657 const base::Callback<void(void)>& callback) {
657 DCHECK_CURRENTLY_ON(BrowserThread::UI); 658 DCHECK_CURRENTLY_ON(BrowserThread::UI);
658 return state_callback_list_.Add(callback); 659 return state_callback_list_.Add(callback);
659 } 660 }
660 661
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 ping_manager()->ReportThreatDetails(report); 699 ping_manager()->ReportThreatDetails(report);
699 } 700 }
700 701
701 void SafeBrowsingService::ProcessResourceRequest( 702 void SafeBrowsingService::ProcessResourceRequest(
702 const ResourceRequestInfo& request) { 703 const ResourceRequestInfo& request) {
703 DCHECK_CURRENTLY_ON(BrowserThread::UI); 704 DCHECK_CURRENTLY_ON(BrowserThread::UI);
704 services_delegate_->ProcessResourceRequest(&request); 705 services_delegate_->ProcessResourceRequest(&request);
705 } 706 }
706 707
707 } // namespace safe_browsing 708 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698