OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/test/base/testing_profile_manager.h" | 5 #include "chrome/test/base/testing_profile_manager.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/profiles/profile_info_cache.h" | 10 #include "chrome/browser/profiles/profile_info_cache.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 DCHECK(called_set_up_); | 72 DCHECK(called_set_up_); |
73 return CreateTestingProfile(name, UTF8ToUTF16(name), 0); | 73 return CreateTestingProfile(name, UTF8ToUTF16(name), 0); |
74 } | 74 } |
75 | 75 |
76 void TestingProfileManager::DeleteTestingProfile(const std::string& name) { | 76 void TestingProfileManager::DeleteTestingProfile(const std::string& name) { |
77 DCHECK(called_set_up_); | 77 DCHECK(called_set_up_); |
78 | 78 |
79 TestingProfilesMap::iterator it = testing_profiles_.find(name); | 79 TestingProfilesMap::iterator it = testing_profiles_.find(name); |
80 DCHECK(it != testing_profiles_.end()); | 80 DCHECK(it != testing_profiles_.end()); |
81 | 81 |
82 scoped_ptr<TestingProfile> profile(it->second); | 82 TestingProfile* profile = it->second; |
83 | |
84 profile_manager_->profiles_info_.erase(profile->GetPath()); | |
85 | 83 |
86 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); | 84 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); |
87 cache.DeleteProfileFromCache(profile->GetPath()); | 85 cache.DeleteProfileFromCache(profile->GetPath()); |
| 86 |
| 87 profile_manager_->profiles_info_.erase(profile->GetPath()); |
88 } | 88 } |
89 | 89 |
90 ProfileManager* TestingProfileManager::profile_manager() { | 90 ProfileManager* TestingProfileManager::profile_manager() { |
91 DCHECK(called_set_up_); | 91 DCHECK(called_set_up_); |
92 return profile_manager_; | 92 return profile_manager_; |
93 } | 93 } |
94 | 94 |
95 ProfileInfoCache* TestingProfileManager::profile_info_cache() { | 95 ProfileInfoCache* TestingProfileManager::profile_info_cache() { |
96 DCHECK(called_set_up_); | 96 DCHECK(called_set_up_); |
97 return &profile_manager_->GetProfileInfoCache(); | 97 return &profile_manager_->GetProfileInfoCache(); |
98 } | 98 } |
99 | 99 |
100 void TestingProfileManager::SetUpInternal() { | 100 void TestingProfileManager::SetUpInternal() { |
101 ASSERT_FALSE(browser_process_->profile_manager()) | 101 ASSERT_FALSE(browser_process_->profile_manager()) |
102 << "ProfileManager already exists"; | 102 << "ProfileManager already exists"; |
103 | 103 |
104 // Set up the directory for profiles. | 104 // Set up the directory for profiles. |
105 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); | 105 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); |
106 | 106 |
107 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); | 107 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); |
108 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. | 108 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. |
109 | 109 |
110 called_set_up_ = true; | 110 called_set_up_ = true; |
111 } | 111 } |
OLD | NEW |