OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ |
6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 | 9 |
10 class RenderViewHost; | 10 class RenderViewHost; |
11 class RenderViewHostDelegate; | 11 class RenderViewHostDelegate; |
12 class SiteInstance; | 12 class SiteInstance; |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class WaitableEvent; | 15 class WaitableEvent; |
16 } // namespace base | 16 } // namespace base |
17 | 17 |
18 // A factory for creating RenderViewHosts. There is a global factory function | 18 // A factory for creating RenderViewHosts. There is a global factory function |
19 // that can be installed for the purposes of testing to provide a specialized | 19 // that can be installed for the purposes of testing to provide a specialized |
20 // RenderViewHost class. | 20 // RenderViewHost class. |
21 class RenderViewHostFactory { | 21 class RenderViewHostFactory { |
22 public: | 22 public: |
23 // Creates a RenderViewHost using the currently registered factory, or the | 23 // Creates a RenderViewHost using the currently registered factory, or the |
24 // default one if no factory is registered. Ownership of the returned | 24 // default one if no factory is registered. Ownership of the returned |
25 // pointer will be passed to the caller. | 25 // pointer will be passed to the caller. |
26 static RenderViewHost* Create(SiteInstance* instance, | 26 static RenderViewHost* Create(SiteInstance* instance, |
27 RenderViewHostDelegate* delegate, | 27 RenderViewHostDelegate* delegate, |
28 int routing_id); | 28 int routing_id, |
| 29 int64 session_storage_namespace_id); |
29 | 30 |
30 // Returns true if there is currently a globally-registered factory. | 31 // Returns true if there is currently a globally-registered factory. |
31 static bool has_factory() { | 32 static bool has_factory() { |
32 return !!factory_; | 33 return !!factory_; |
33 } | 34 } |
34 | 35 |
35 protected: | 36 protected: |
36 RenderViewHostFactory() {} | 37 RenderViewHostFactory() {} |
37 virtual ~RenderViewHostFactory() {} | 38 virtual ~RenderViewHostFactory() {} |
38 | 39 |
39 // You can derive from this class and specify an implementation for this | 40 // You can derive from this class and specify an implementation for this |
40 // function to create a different kind of RenderViewHost for testing. | 41 // function to create a different kind of RenderViewHost for testing. |
41 virtual RenderViewHost* CreateRenderViewHost( | 42 virtual RenderViewHost* CreateRenderViewHost( |
42 SiteInstance* instance, | 43 SiteInstance* instance, |
43 RenderViewHostDelegate* delegate, | 44 RenderViewHostDelegate* delegate, |
44 int routing_id) = 0; | 45 int routing_id, |
| 46 int64 session_storage_namespace_id) = 0; |
45 | 47 |
46 // Registers your factory to be called when new RenderViewHosts are created. | 48 // Registers your factory to be called when new RenderViewHosts are created. |
47 // We have only one global factory, so there must be no factory registered | 49 // We have only one global factory, so there must be no factory registered |
48 // before the call. This class does NOT take ownership of the pointer. | 50 // before the call. This class does NOT take ownership of the pointer. |
49 static void RegisterFactory(RenderViewHostFactory* factory); | 51 static void RegisterFactory(RenderViewHostFactory* factory); |
50 | 52 |
51 // Unregister the previously registered factory. With no factory registered, | 53 // Unregister the previously registered factory. With no factory registered, |
52 // the default RenderViewHosts will be created. | 54 // the default RenderViewHosts will be created. |
53 static void UnregisterFactory(); | 55 static void UnregisterFactory(); |
54 | 56 |
55 private: | 57 private: |
56 // The current globally registered factory. This is NULL when we should | 58 // The current globally registered factory. This is NULL when we should |
57 // create the default RenderViewHosts. | 59 // create the default RenderViewHosts. |
58 static RenderViewHostFactory* factory_; | 60 static RenderViewHostFactory* factory_; |
59 | 61 |
60 DISALLOW_COPY_AND_ASSIGN(RenderViewHostFactory); | 62 DISALLOW_COPY_AND_ASSIGN(RenderViewHostFactory); |
61 }; | 63 }; |
62 | 64 |
63 | 65 |
64 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ | 66 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_ |
OLD | NEW |