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

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 9853010: ProfileManager: Remove CHECKs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 <set> 5 #include <set>
6 6
7 #include "chrome/browser/profiles/profile_manager.h" 7 #include "chrome/browser/profiles/profile_manager.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 case content::NOTIFICATION_APP_EXITING: { 519 case content::NOTIFICATION_APP_EXITING: {
520 // Ignore any browsers closing from now on. 520 // Ignore any browsers closing from now on.
521 shutdown_started_ = true; 521 shutdown_started_ = true;
522 break; 522 break;
523 } 523 }
524 case chrome::NOTIFICATION_BROWSER_OPENED: { 524 case chrome::NOTIFICATION_BROWSER_OPENED: {
525 Browser* browser = content::Source<Browser>(source).ptr(); 525 Browser* browser = content::Source<Browser>(source).ptr();
526 DCHECK(browser); 526 DCHECK(browser);
527 Profile* profile = browser->profile(); 527 Profile* profile = browser->profile();
528 DCHECK(profile); 528 DCHECK(profile);
529 if (!profile->IsOffTheRecord() && ++browser_counts_[profile] == 1) { 529 if (!profile->IsOffTheRecord() && ++browser_counts_[profile] == 1) {
sail 2012/03/26 16:15:48 It seems like one source of problems is that brows
marja 2012/03/27 08:18:00 That should not be a problem if the strings are un
530 CHECK(std::find(active_profiles_.begin(), active_profiles_.end(),
531 profile) == active_profiles_.end());
532 active_profiles_.push_back(profile); 530 active_profiles_.push_back(profile);
533 update_active_profiles = true; 531 update_active_profiles = true;
534 } 532 }
535 break; 533 break;
536 } 534 }
537 case chrome::NOTIFICATION_BROWSER_CLOSED: { 535 case chrome::NOTIFICATION_BROWSER_CLOSED: {
538 Browser* browser = content::Source<Browser>(source).ptr(); 536 Browser* browser = content::Source<Browser>(source).ptr();
539 DCHECK(browser); 537 DCHECK(browser);
540 Profile* profile = browser->profile(); 538 Profile* profile = browser->profile();
541 DCHECK(profile); 539 DCHECK(profile);
542 if (!profile->IsOffTheRecord() && --browser_counts_[profile] == 0) { 540 if (!profile->IsOffTheRecord() && --browser_counts_[profile] == 0) {
543 CHECK(std::find(active_profiles_.begin(), active_profiles_.end(),
544 profile) != active_profiles_.end());
545 active_profiles_.erase( 541 active_profiles_.erase(
546 std::remove(active_profiles_.begin(), active_profiles_.end(), 542 std::remove(active_profiles_.begin(), active_profiles_.end(),
Bernhard Bauer 2012/03/27 08:35:51 Why are you calling std::remove() *and* erase()? O
marja 2012/03/27 08:57:20 std::remove() arranges the elements so that the re
Bernhard Bauer 2012/03/27 09:13:52 Couldn't you achieve the same thing with `active_p
marja 2012/03/27 09:29:31 Done.
547 profile), 543 profile),
548 active_profiles_.end()); 544 active_profiles_.end());
549 CHECK(std::find(active_profiles_.begin(), active_profiles_.end(),
550 profile) == active_profiles_.end());
551 update_active_profiles = true; 545 update_active_profiles = true;
552 } 546 }
553 break; 547 break;
554 } 548 }
555 default: { 549 default: {
556 NOTREACHED(); 550 NOTREACHED();
557 break; 551 break;
558 } 552 }
559 } 553 }
560 if (update_active_profiles) { 554 if (update_active_profiles) {
561 PrefService* local_state = g_browser_process->local_state(); 555 PrefService* local_state = g_browser_process->local_state();
562 DCHECK(local_state); 556 DCHECK(local_state);
563 ListPrefUpdate update(local_state, prefs::kProfilesLastActive); 557 ListPrefUpdate update(local_state, prefs::kProfilesLastActive);
564 ListValue* profile_list = update.Get(); 558 ListValue* profile_list = update.Get();
565 559
566 profile_list->Clear(); 560 profile_list->Clear();
567 561
568 // Check that the same profile doesn't occur twice in last_opened_profiles. 562 // crbug.com/120112 -> several non-incognito profiles might have the same
569 { 563 // GetPath().BaseName(). In that case, we cannot restore both
570 std::set<Profile*> active_profiles_set; 564 // profiles. Include each base name only once in the last active profile
571 for (std::vector<Profile*>::const_iterator it = active_profiles_.begin(); 565 // list.
572 it != active_profiles_.end(); ++it) {
573 CHECK(active_profiles_set.find(*it) ==
574 active_profiles_set.end());
575 active_profiles_set.insert(*it);
576 }
577 }
578 // Used for checking that the string representations of the profiles differ.
579 std::set<std::string> profile_paths; 566 std::set<std::string> profile_paths;
580
581 std::vector<Profile*>::const_iterator it; 567 std::vector<Profile*>::const_iterator it;
582 for (it = active_profiles_.begin(); it != active_profiles_.end(); ++it) { 568 for (it = active_profiles_.begin(); it != active_profiles_.end(); ++it) {
583 std::string profile_path = (*it)->GetPath().BaseName().MaybeAsASCII(); 569 std::string profile_path = (*it)->GetPath().BaseName().MaybeAsASCII();
584 CHECK(profile_paths.find(profile_path) == 570 if (profile_paths.find(profile_path) == profile_paths.end()) {
marja 2012/03/27 08:18:00 <<< this was the CHECK that seems to fire; the CHE
585 profile_paths.end()); 571 profile_paths.insert(profile_path);
586 profile_paths.insert(profile_path); 572 profile_list->Append(new StringValue(profile_path));
587 profile_list->Append( 573 }
588 new StringValue((*it)->GetPath().BaseName().MaybeAsASCII()));
589 } 574 }
590 } 575 }
591 } 576 }
592 577
593 void ProfileManager::SetWillImport() { 578 void ProfileManager::SetWillImport() {
594 will_import_ = true; 579 will_import_ = true;
595 } 580 }
596 581
597 void ProfileManager::OnImportFinished(Profile* profile) { 582 void ProfileManager::OnImportFinished(Profile* profile) {
598 will_import_ = false; 583 will_import_ = false;
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 AddProfileToCache(profile); 947 AddProfileToCache(profile);
963 } 948 }
964 } 949 }
965 950
966 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks, 951 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks,
967 Profile* profile, 952 Profile* profile,
968 Profile::CreateStatus status) { 953 Profile::CreateStatus status) {
969 for (size_t i = 0; i < callbacks.size(); ++i) 954 for (size_t i = 0; i < callbacks.size(); ++i)
970 callbacks[i].Run(profile, status); 955 callbacks[i].Run(profile, status);
971 } 956 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698