diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-08 14:00:11 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-08 14:00:11 +0000 |
commit | 4bf6afd4a6c3c6c506a2b846b4ebf0c2c3f27805 (patch) | |
tree | 0293e2a7dbe89dfd0fb111cd9f0ecaee73d14155 | |
parent | 2dd1eb91fa07a6ec9a708093525834d7eab5a95e (diff) | |
download | chromium_src-4bf6afd4a6c3c6c506a2b846b4ebf0c2c3f27805.zip chromium_src-4bf6afd4a6c3c6c506a2b846b4ebf0c2c3f27805.tar.gz chromium_src-4bf6afd4a6c3c6c506a2b846b4ebf0c2c3f27805.tar.bz2 |
Committing change 255087 for Roger:
TBR=amit
http://codereview.chromium.org/255087
Adding a unique runtime Id to Profile objects, that can be used as the key
of the ProfileSiteInstanceMap type. This is used to make sure that Profile
objects can correctly share site information when one profile is derived
from another.
BUG=0
TEST=See unit tests
Review URL: http://codereview.chromium.org/261012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28390 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/automation_profile_impl.h | 3 | ||||
-rw-r--r-- | chrome/browser/automation/automation_resource_message_filter.cc | 2 | ||||
-rw-r--r-- | chrome/browser/browsing_instance.cc | 4 | ||||
-rw-r--r-- | chrome/browser/browsing_instance.h | 7 | ||||
-rw-r--r-- | chrome/browser/profile.cc | 11 | ||||
-rw-r--r-- | chrome/browser/profile.h | 24 | ||||
-rw-r--r-- | chrome/test/testing_profile.h | 20 |
7 files changed, 53 insertions, 18 deletions
diff --git a/chrome/browser/automation/automation_profile_impl.h b/chrome/browser/automation/automation_profile_impl.h index 797d94e..42ad978 100644 --- a/chrome/browser/automation/automation_profile_impl.h +++ b/chrome/browser/automation/automation_profile_impl.h @@ -30,6 +30,9 @@ class AutomationProfileImpl : public Profile { } // Profile implementation. + virtual ProfileId GetRuntimeId() { + return original_profile_->GetRuntimeId(); + } virtual FilePath GetPath() { return original_profile_->GetPath(); } diff --git a/chrome/browser/automation/automation_resource_message_filter.cc b/chrome/browser/automation/automation_resource_message_filter.cc index 9d899b9..c06eb66 100644 --- a/chrome/browser/automation/automation_resource_message_filter.cc +++ b/chrome/browser/automation/automation_resource_message_filter.cc @@ -166,7 +166,7 @@ void AutomationResourceMessageFilter::UnRegisterRenderViewInIOThread( filtered_render_views_.find(RendererId(renderer_pid, renderer_id))); if (automation_details_iter == filtered_render_views_.end()) { - NOTREACHED(); + LOG(INFO) << "UnRegisterRenderViewInIOThread: already unregistered"; return; } diff --git a/chrome/browser/browsing_instance.cc b/chrome/browser/browsing_instance.cc index ea23646..ff3346a 100644 --- a/chrome/browser/browsing_instance.cc +++ b/chrome/browser/browsing_instance.cc @@ -53,7 +53,9 @@ BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap( // Otherwise, process-per-site is in use, at least for this URL. Look up the // global map for this profile, creating an entry if necessary. - return &profile_site_instance_map_[profile]; + ProfileId runtime_id = profile ? profile->GetRuntimeId() + : Profile::InvalidProfileId; + return &profile_site_instance_map_[runtime_id]; } bool BrowsingInstance::HasSiteInstance(const GURL& url) { diff --git a/chrome/browser/browsing_instance.h b/chrome/browser/browsing_instance.h index 27ef405..c067a0d 100644 --- a/chrome/browser/browsing_instance.h +++ b/chrome/browser/browsing_instance.h @@ -8,9 +8,9 @@ #include "base/hash_tables.h" #include "base/logging.h" #include "base/ref_counted.h" +#include "chrome/browser/profile.h" class GURL; -class Profile; class SiteInstance; /////////////////////////////////////////////////////////////////////////////// @@ -100,8 +100,9 @@ class BrowsingInstance : public base::RefCounted<BrowsingInstance> { // obtained with SiteInstance::GetSiteForURL. typedef base::hash_map<std::string, SiteInstance*> SiteInstanceMap; - // Map of Profile to SiteInstanceMap, for use in the process-per-site model. - typedef base::hash_map<Profile*, SiteInstanceMap> ProfileSiteInstanceMap; + // Map of Profile runtime Id to SiteInstanceMap, for use in the + // process-per-site model. + typedef base::hash_map<ProfileId, SiteInstanceMap> ProfileSiteInstanceMap; // Returns a pointer to the relevant SiteInstanceMap for this object. If the // process-per-site model is in use, or if process-per-site-instance is in diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index ebf96c7..2099e99 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -147,6 +147,9 @@ static void CleanupAppCacheService(ChromeAppCacheService* appcache_service) { } // static +const ProfileId Profile::InvalidProfileId = static_cast<ProfileId>(0); + +// static void Profile::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kSearchSuggestEnabled, true); prefs->RegisterBooleanPref(prefs::kSessionExitedCleanly, true); @@ -227,6 +230,10 @@ class OffTheRecordProfileImpl : public Profile, CleanupAppCacheService(appcache_service_); } + virtual ProfileId GetRuntimeId() { + return reinterpret_cast<ProfileId>(this); + } + virtual FilePath GetPath() { return profile_->GetPath(); } virtual bool IsOffTheRecord() { @@ -798,6 +805,10 @@ ProfileImpl::~ProfileImpl() { MarkAsCleanShutdown(); } +ProfileId ProfileImpl::GetRuntimeId() { + return reinterpret_cast<ProfileId>(this); +} + FilePath ProfileImpl::GetPath() { return path_; } diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h index a2f055f..45ed081 100644 --- a/chrome/browser/profile.h +++ b/chrome/browser/profile.h @@ -60,6 +60,8 @@ class VisitedLinkEventListener; class WebDataService; class WebKitContext; +typedef intptr_t ProfileId; + class Profile { public: // Profile services are accessed with the following parameter. This parameter @@ -86,6 +88,10 @@ class Profile { // off the record mode. IMPLICIT_ACCESS }; + + // Value that represents no profile Id. + static const ProfileId InvalidProfileId; + Profile() : restored_last_session_(false) {} virtual ~Profile() {} @@ -105,6 +111,10 @@ class Profile { // keep it alive longer than the profile) must Release() it on the I/O thread. static URLRequestContext* GetDefaultRequestContext(); + // Returns a unique Id that can be used to identify this profile at runtime. + // This Id is not persistent and will not survive a restart of the browser. + virtual ProfileId GetRuntimeId() = 0; + // Returns the path of the directory where this profile's data is stored. virtual FilePath GetPath() = 0; @@ -371,6 +381,7 @@ class ProfileImpl : public Profile, virtual ~ProfileImpl(); // Profile implementation. + virtual ProfileId GetRuntimeId(); virtual FilePath GetPath(); virtual bool IsOffTheRecord(); virtual Profile* GetOffTheRecordProfile(); @@ -537,19 +548,6 @@ class ProfileImpl : public Profile, DISALLOW_COPY_AND_ASSIGN(ProfileImpl); }; -#if defined(COMPILER_GCC) -namespace __gnu_cxx { - -template<> -struct hash<Profile*> { - std::size_t operator()(Profile* const& p) const { - return reinterpret_cast<std::size_t>(p); - } -}; - -} // namespace __gnu_cxx -#endif - // This struct is used to pass the spellchecker object through the notification // SPELLCHECKER_REINITIALIZED. This is used as the details for the notification // service. diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h index 14c31443..5fd855a 100644 --- a/chrome/test/testing_profile.h +++ b/chrome/test/testing_profile.h @@ -57,6 +57,10 @@ class TestingProfile : public Profile { // ownership of |theme_provider|. void UseThemeProvider(BrowserThemeProvider* theme_provider); + virtual ProfileId GetRuntimeId() { + return reinterpret_cast<ProfileId>(this); + } + virtual FilePath GetPath() { return path_; } @@ -221,4 +225,20 @@ class TestingProfile : public Profile { bool last_session_exited_cleanly_; }; +// A profile that derives from another profile. This does not actually +// override anything except the GetRuntimeId() in order to test sharing of +// site information. +class DerivedTestingProfile : public TestingProfile { + public: + DerivedTestingProfile(Profile* profile) : original_profile_(profile) { + } + + virtual ProfileId GetRuntimeId() { + return original_profile_->GetRuntimeId(); + } + + protected: + Profile* original_profile_; +}; + #endif // CHROME_TEST_TESTING_PROFILE_H_ |