| OLD | NEW |
| 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 #ifndef CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ |
| 6 #define CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ | 6 #define CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ |
| 7 | 7 |
| 8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/render_process_host_observer.h" |
| 11 #include "content/public/browser/notification_registrar.h" | |
| 12 #include "content/public/browser/site_instance.h" | 11 #include "content/public/browser/site_instance.h" |
| 13 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 14 | 13 |
| 15 namespace content { | 14 namespace content { |
| 16 class RenderProcessHostFactory; | 15 class RenderProcessHostFactory; |
| 17 | 16 |
| 18 class CONTENT_EXPORT SiteInstanceImpl : public SiteInstance, | 17 class CONTENT_EXPORT SiteInstanceImpl : public SiteInstance, |
| 19 public NotificationObserver { | 18 public RenderProcessHostObserver { |
| 20 public: | 19 public: |
| 21 // SiteInstance interface overrides. | 20 // SiteInstance interface overrides. |
| 22 virtual int32 GetId() OVERRIDE; | 21 virtual int32 GetId() OVERRIDE; |
| 23 virtual bool HasProcess() const OVERRIDE; | 22 virtual bool HasProcess() const OVERRIDE; |
| 24 virtual RenderProcessHost* GetProcess() OVERRIDE; | 23 virtual RenderProcessHost* GetProcess() OVERRIDE; |
| 25 virtual const GURL& GetSiteURL() const OVERRIDE; | 24 virtual const GURL& GetSiteURL() const OVERRIDE; |
| 26 virtual SiteInstance* GetRelatedSiteInstance(const GURL& url) OVERRIDE; | 25 virtual SiteInstance* GetRelatedSiteInstance(const GURL& url) OVERRIDE; |
| 27 virtual bool IsRelatedSiteInstance(const SiteInstance* instance) OVERRIDE; | 26 virtual bool IsRelatedSiteInstance(const SiteInstance* instance) OVERRIDE; |
| 28 virtual BrowserContext* GetBrowserContext() const OVERRIDE; | 27 virtual BrowserContext* GetBrowserContext() const OVERRIDE; |
| 29 | 28 |
| 30 // Set the web site that this SiteInstance is rendering pages for. | 29 // Set the web site that this SiteInstance is rendering pages for. |
| 31 // This includes the scheme and registered domain, but not the port. If the | 30 // This includes the scheme and registered domain, but not the port. If the |
| 32 // URL does not have a valid registered domain, then the full hostname is | 31 // URL does not have a valid registered domain, then the full hostname is |
| 33 // stored. | 32 // stored. |
| 34 void SetSite(const GURL& url); | 33 void SetSite(const GURL& url); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // Create a new SiteInstance. Protected to give access to BrowsingInstance | 76 // Create a new SiteInstance. Protected to give access to BrowsingInstance |
| 78 // and tests; most callers should use Create or GetRelatedSiteInstance | 77 // and tests; most callers should use Create or GetRelatedSiteInstance |
| 79 // instead. | 78 // instead. |
| 80 explicit SiteInstanceImpl(BrowsingInstance* browsing_instance); | 79 explicit SiteInstanceImpl(BrowsingInstance* browsing_instance); |
| 81 | 80 |
| 82 private: | 81 private: |
| 83 // Get the effective URL for the given actual URL. | 82 // Get the effective URL for the given actual URL. |
| 84 static GURL GetEffectiveURL(BrowserContext* browser_context, | 83 static GURL GetEffectiveURL(BrowserContext* browser_context, |
| 85 const GURL& url); | 84 const GURL& url); |
| 86 | 85 |
| 87 // NotificationObserver implementation. | 86 // RenderProcessHostObserver implementation. |
| 88 virtual void Observe(int type, | 87 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) OVERRIDE; |
| 89 const NotificationSource& source, | |
| 90 const NotificationDetails& details) OVERRIDE; | |
| 91 | 88 |
| 92 // Used to restrict a process' origin access rights. | 89 // Used to restrict a process' origin access rights. |
| 93 void LockToOrigin(); | 90 void LockToOrigin(); |
| 94 | 91 |
| 95 // An object used to construct RenderProcessHosts. | 92 // An object used to construct RenderProcessHosts. |
| 96 static const RenderProcessHostFactory* g_render_process_host_factory_; | 93 static const RenderProcessHostFactory* g_render_process_host_factory_; |
| 97 | 94 |
| 98 // The next available SiteInstance ID. | 95 // The next available SiteInstance ID. |
| 99 static int32 next_site_instance_id_; | 96 static int32 next_site_instance_id_; |
| 100 | 97 |
| 101 // A unique ID for this SiteInstance. | 98 // A unique ID for this SiteInstance. |
| 102 int32 id_; | 99 int32 id_; |
| 103 | 100 |
| 104 // The number of active views under this SiteInstance. | 101 // The number of active views under this SiteInstance. |
| 105 size_t active_view_count_; | 102 size_t active_view_count_; |
| 106 | 103 |
| 107 NotificationRegistrar registrar_; | |
| 108 | |
| 109 // BrowsingInstance to which this SiteInstance belongs. | 104 // BrowsingInstance to which this SiteInstance belongs. |
| 110 scoped_refptr<BrowsingInstance> browsing_instance_; | 105 scoped_refptr<BrowsingInstance> browsing_instance_; |
| 111 | 106 |
| 112 // Current RenderProcessHost that is rendering pages for this SiteInstance. | 107 // Current RenderProcessHost that is rendering pages for this SiteInstance. |
| 113 // This pointer will only change once the RenderProcessHost is destructed. It | 108 // This pointer will only change once the RenderProcessHost is destructed. It |
| 114 // will still remain the same even if the process crashes, since in that | 109 // will still remain the same even if the process crashes, since in that |
| 115 // scenario the RenderProcessHost remains the same. | 110 // scenario the RenderProcessHost remains the same. |
| 116 RenderProcessHost* process_; | 111 RenderProcessHost* process_; |
| 117 | 112 |
| 118 // The web site that this SiteInstance is rendering pages for. | 113 // The web site that this SiteInstance is rendering pages for. |
| 119 GURL site_; | 114 GURL site_; |
| 120 | 115 |
| 121 // Whether SetSite has been called. | 116 // Whether SetSite has been called. |
| 122 bool has_site_; | 117 bool has_site_; |
| 123 | 118 |
| 124 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); | 119 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); |
| 125 }; | 120 }; |
| 126 | 121 |
| 127 } // namespace content | 122 } // namespace content |
| 128 | 123 |
| 129 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ | 124 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ |
| OLD | NEW |