| 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/notification_observer.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // Returns whether there is currently a related SiteInstance (registered with | 37 // Returns whether there is currently a related SiteInstance (registered with |
| 38 // BrowsingInstance) for the site of the given url. If so, we should try to | 38 // BrowsingInstance) for the site of the given url. If so, we should try to |
| 39 // avoid dedicating an unused SiteInstance to it (e.g., in a new tab). | 39 // avoid dedicating an unused SiteInstance to it (e.g., in a new tab). |
| 40 bool HasRelatedSiteInstance(const GURL& url); | 40 bool HasRelatedSiteInstance(const GURL& url); |
| 41 | 41 |
| 42 // Returns whether this SiteInstance has a process that is the wrong type for | 42 // Returns whether this SiteInstance has a process that is the wrong type for |
| 43 // the given URL. If so, the browser should force a process swap when | 43 // the given URL. If so, the browser should force a process swap when |
| 44 // navigating to the URL. | 44 // navigating to the URL. |
| 45 bool HasWrongProcessForURL(const GURL& url); | 45 bool HasWrongProcessForURL(const GURL& url); |
| 46 | 46 |
| 47 // Sets the factory used to create new RenderProcessHosts. This will also be | 47 // Sets the global factory used to create new RenderProcessHosts. It may be |
| 48 // passed on to SiteInstances spawned by this one. | 48 // NULL, in which case the default BrowserRenderProcessHost will be created |
| 49 // The factory must outlive the SiteInstance; ownership is not transferred. It | 49 // (this is the behavior if you don't call this function). The factory must |
| 50 // may be NULL, in which case the default BrowserRenderProcessHost will be | 50 // be set back to NULL before it's destroyed; ownership is not transferred. |
| 51 // created (this is the behavior if you don't call this function). | 51 static void set_render_process_host_factory( |
| 52 void set_render_process_host_factory(RenderProcessHostFactory* rph_factory) { | 52 const RenderProcessHostFactory* rph_factory); |
| 53 render_process_host_factory_ = rph_factory; | |
| 54 } | |
| 55 | 53 |
| 56 protected: | 54 protected: |
| 57 friend class BrowsingInstance; | 55 friend class BrowsingInstance; |
| 58 friend class SiteInstance; | 56 friend class SiteInstance; |
| 59 | 57 |
| 60 // Virtual to allow tests to extend it. | 58 // Virtual to allow tests to extend it. |
| 61 virtual ~SiteInstanceImpl(); | 59 virtual ~SiteInstanceImpl(); |
| 62 | 60 |
| 63 // Create a new SiteInstance. Protected to give access to BrowsingInstance | 61 // Create a new SiteInstance. Protected to give access to BrowsingInstance |
| 64 // and tests; most callers should use Create or GetRelatedSiteInstance | 62 // and tests; most callers should use Create or GetRelatedSiteInstance |
| 65 // instead. | 63 // instead. |
| 66 explicit SiteInstanceImpl(BrowsingInstance* browsing_instance); | 64 explicit SiteInstanceImpl(BrowsingInstance* browsing_instance); |
| 67 | 65 |
| 68 private: | 66 private: |
| 69 // Get the effective URL for the given actual URL. | 67 // Get the effective URL for the given actual URL. |
| 70 static GURL GetEffectiveURL(BrowserContext* browser_context, | 68 static GURL GetEffectiveURL(BrowserContext* browser_context, |
| 71 const GURL& url); | 69 const GURL& url); |
| 72 | 70 |
| 73 // NotificationObserver implementation. | 71 // NotificationObserver implementation. |
| 74 virtual void Observe(int type, | 72 virtual void Observe(int type, |
| 75 const NotificationSource& source, | 73 const NotificationSource& source, |
| 76 const NotificationDetails& details) OVERRIDE; | 74 const NotificationDetails& details) OVERRIDE; |
| 77 | 75 |
| 78 // Used to restrict a process' origin access rights. | 76 // Used to restrict a process' origin access rights. |
| 79 void LockToOrigin(); | 77 void LockToOrigin(); |
| 80 | 78 |
| 79 // An object used to construct RenderProcessHosts. |
| 80 static const RenderProcessHostFactory* g_render_process_host_factory_; |
| 81 |
| 81 // The next available SiteInstance ID. | 82 // The next available SiteInstance ID. |
| 82 static int32 next_site_instance_id_; | 83 static int32 next_site_instance_id_; |
| 83 | 84 |
| 84 // A unique ID for this SiteInstance. | 85 // A unique ID for this SiteInstance. |
| 85 int32 id_; | 86 int32 id_; |
| 86 | 87 |
| 87 NotificationRegistrar registrar_; | 88 NotificationRegistrar registrar_; |
| 88 | 89 |
| 89 // BrowsingInstance to which this SiteInstance belongs. | 90 // BrowsingInstance to which this SiteInstance belongs. |
| 90 scoped_refptr<BrowsingInstance> browsing_instance_; | 91 scoped_refptr<BrowsingInstance> browsing_instance_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 104 | 105 |
| 105 // Whether SetSite has been called. | 106 // Whether SetSite has been called. |
| 106 bool has_site_; | 107 bool has_site_; |
| 107 | 108 |
| 108 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); | 109 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 } // namespace content | 112 } // namespace content |
| 112 | 113 |
| 113 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ | 114 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ |
| OLD | NEW |