| 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" |
| 11 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
| 12 #include "content/public/browser/site_instance.h" | 12 #include "content/public/browser/site_instance.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 class RenderProcessHostFactory; | 16 class RenderProcessHostFactory; |
| 17 | 17 |
| 18 class CONTENT_EXPORT SiteInstanceImpl : public SiteInstance, | 18 class CONTENT_EXPORT SiteInstanceImpl : public SiteInstance, |
| 19 public NotificationObserver { | 19 public NotificationObserver { |
| 20 public: | 20 public: |
| 21 // SiteInstance interface overrides. | 21 // SiteInstance interface overrides. |
| 22 virtual int32 GetId() OVERRIDE; | 22 virtual int32 GetId() OVERRIDE; |
| 23 virtual bool HasProcess() const OVERRIDE; | 23 virtual bool HasProcess() const OVERRIDE; |
| 24 virtual RenderProcessHost* GetProcess() OVERRIDE; | 24 virtual RenderProcessHost* GetProcess() OVERRIDE; |
| 25 virtual const GURL& GetSiteURL() const OVERRIDE; | 25 virtual const GURL& GetSiteURL() const OVERRIDE; |
| 26 virtual SiteInstance* GetRelatedSiteInstance(const GURL& url) OVERRIDE; | 26 virtual SiteInstance* GetRelatedSiteInstance(const GURL& url) OVERRIDE; |
| 27 virtual bool IsRelatedSiteInstance(const SiteInstance* instance) OVERRIDE; | 27 virtual bool IsRelatedSiteInstance(const SiteInstance* instance) OVERRIDE; |
| 28 virtual BrowserContext* GetBrowserContext() const OVERRIDE; | 28 virtual BrowserContext* GetBrowserContext() const OVERRIDE; |
| 29 virtual void SetRenderProcessHostFactory( |
| 30 const RenderProcessHostFactory* rph_factory) OVERRIDE; |
| 29 | 31 |
| 30 // Set the web site that this SiteInstance is rendering pages for. | 32 // 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 | 33 // 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 | 34 // URL does not have a valid registered domain, then the full hostname is |
| 33 // stored. | 35 // stored. |
| 34 void SetSite(const GURL& url); | 36 void SetSite(const GURL& url); |
| 35 bool HasSite() const; | 37 bool HasSite() const; |
| 36 | 38 |
| 37 // Returns whether there is currently a related SiteInstance (registered with | 39 // 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 | 40 // 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). | 41 // avoid dedicating an unused SiteInstance to it (e.g., in a new tab). |
| 40 bool HasRelatedSiteInstance(const GURL& url); | 42 bool HasRelatedSiteInstance(const GURL& url); |
| 41 | 43 |
| 42 // Returns whether this SiteInstance has a process that is the wrong type for | 44 // 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 | 45 // the given URL. If so, the browser should force a process swap when |
| 44 // navigating to the URL. | 46 // navigating to the URL. |
| 45 bool HasWrongProcessForURL(const GURL& url); | 47 bool HasWrongProcessForURL(const GURL& url); |
| 46 | 48 |
| 47 // Sets the factory used to create new RenderProcessHosts. This will also be | |
| 48 // passed on to SiteInstances spawned by this one. | |
| 49 // The factory must outlive the SiteInstance; ownership is not transferred. It | |
| 50 // may be NULL, in which case the default BrowserRenderProcessHost will be | |
| 51 // created (this is the behavior if you don't call this function). | |
| 52 void set_render_process_host_factory(RenderProcessHostFactory* rph_factory) { | |
| 53 render_process_host_factory_ = rph_factory; | |
| 54 } | |
| 55 | |
| 56 protected: | 49 protected: |
| 57 friend class BrowsingInstance; | 50 friend class BrowsingInstance; |
| 58 friend class SiteInstance; | 51 friend class SiteInstance; |
| 59 | 52 |
| 60 // Virtual to allow tests to extend it. | 53 // Virtual to allow tests to extend it. |
| 61 virtual ~SiteInstanceImpl(); | 54 virtual ~SiteInstanceImpl(); |
| 62 | 55 |
| 63 // Create a new SiteInstance. Protected to give access to BrowsingInstance | 56 // Create a new SiteInstance. Protected to give access to BrowsingInstance |
| 64 // and tests; most callers should use Create or GetRelatedSiteInstance | 57 // and tests; most callers should use Create or GetRelatedSiteInstance |
| 65 // instead. | 58 // instead. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 97 |
| 105 // Whether SetSite has been called. | 98 // Whether SetSite has been called. |
| 106 bool has_site_; | 99 bool has_site_; |
| 107 | 100 |
| 108 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); | 101 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); |
| 109 }; | 102 }; |
| 110 | 103 |
| 111 } // namespace content | 104 } // namespace content |
| 112 | 105 |
| 113 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ | 106 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ |
| OLD | NEW |