| 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_TEST_TEST_RENDER_VIEW_HOST_FACTORY_H_ | 5 #ifndef CONTENT_TEST_TEST_RENDER_VIEW_HOST_FACTORY_H_ |
| 6 #define CONTENT_TEST_TEST_RENDER_VIEW_HOST_FACTORY_H_ | 6 #define CONTENT_TEST_TEST_RENDER_VIEW_HOST_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "content/browser/renderer_host/render_view_host_factory.h" | 10 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 class SiteInstance; | 14 class SiteInstance; |
| 15 class RenderViewHostDelegate; | 15 class RenderViewHostDelegate; |
| 16 class RenderProcessHostFactory; | 16 class RenderProcessHostFactory; |
| 17 class SessionStorageNamespace; | 17 class SessionStorageNamespace; |
| 18 | 18 |
| 19 // Manages creation of the RenderViewHosts using our special subclass. This | 19 // Manages creation of the RenderViewHosts using our special subclass. This |
| 20 // automatically registers itself when it goes in scope, and unregisters itself | 20 // automatically registers itself when it goes in scope, and unregisters itself |
| 21 // when it goes out of scope. Since you can't have more than one factory | 21 // when it goes out of scope. Since you can't have more than one factory |
| 22 // registered at a time, you can only have one of these objects at a time. | 22 // registered at a time, you can only have one of these objects at a time. |
| 23 class TestRenderViewHostFactory : public RenderViewHostFactory { | 23 class TestRenderViewHostFactory : public RenderViewHostFactory { |
| 24 public: | 24 public: |
| 25 explicit TestRenderViewHostFactory( | 25 explicit TestRenderViewHostFactory( |
| 26 content::RenderProcessHostFactory* rph_factory); | 26 RenderProcessHostFactory* rph_factory); |
| 27 virtual ~TestRenderViewHostFactory(); | 27 virtual ~TestRenderViewHostFactory(); |
| 28 | 28 |
| 29 virtual void set_render_process_host_factory( | 29 virtual void set_render_process_host_factory( |
| 30 content::RenderProcessHostFactory* rph_factory); | 30 RenderProcessHostFactory* rph_factory); |
| 31 virtual content::RenderViewHost* CreateRenderViewHost( | 31 virtual RenderViewHost* CreateRenderViewHost( |
| 32 content::SiteInstance* instance, | 32 SiteInstance* instance, |
| 33 content::RenderViewHostDelegate* delegate, | 33 RenderViewHostDelegate* delegate, |
| 34 content::RenderWidgetHostDelegate* widget_delegate, | 34 RenderWidgetHostDelegate* widget_delegate, |
| 35 int routing_id, | 35 int routing_id, |
| 36 bool swapped_out, | 36 bool swapped_out, |
| 37 content::SessionStorageNamespace* session_storage) OVERRIDE; | 37 SessionStorageNamespace* session_storage) OVERRIDE; |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 // This is a bit of a hack. With the current design of the site instances / | 40 // This is a bit of a hack. With the current design of the site instances / |
| 41 // browsing instances, it's difficult to pass a RenderProcessHostFactory | 41 // browsing instances, it's difficult to pass a RenderProcessHostFactory |
| 42 // around properly. | 42 // around properly. |
| 43 // | 43 // |
| 44 // Instead, we set it right before we create a new RenderViewHost, which | 44 // Instead, we set it right before we create a new RenderViewHost, which |
| 45 // happens before the RenderProcessHost is created. This way, the instance | 45 // happens before the RenderProcessHost is created. This way, the instance |
| 46 // has the correct factory and creates our special RenderProcessHosts. | 46 // has the correct factory and creates our special RenderProcessHosts. |
| 47 content::RenderProcessHostFactory* render_process_host_factory_; | 47 RenderProcessHostFactory* render_process_host_factory_; |
| 48 | 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(TestRenderViewHostFactory); | 49 DISALLOW_COPY_AND_ASSIGN(TestRenderViewHostFactory); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 } // namespace content | 52 } // namespace content |
| 53 | 53 |
| 54 #endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_FACTORY_H_ | 54 #endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_FACTORY_H_ |
| OLD | NEW |