| 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_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ |
| 6 #define CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ | 6 #define CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 virtual ~MockRenderProcessHostFactory(); | 110 virtual ~MockRenderProcessHostFactory(); |
| 111 | 111 |
| 112 virtual RenderProcessHost* CreateRenderProcessHost( | 112 virtual RenderProcessHost* CreateRenderProcessHost( |
| 113 BrowserContext* browser_context) const OVERRIDE; | 113 BrowserContext* browser_context) const OVERRIDE; |
| 114 | 114 |
| 115 // Removes the given MockRenderProcessHost from the MockRenderProcessHost list | 115 // Removes the given MockRenderProcessHost from the MockRenderProcessHost list |
| 116 // without deleting it. When a test deletes a MockRenderProcessHost, we need | 116 // without deleting it. When a test deletes a MockRenderProcessHost, we need |
| 117 // to remove it from |processes_| to prevent it from being deleted twice. | 117 // to remove it from |processes_| to prevent it from being deleted twice. |
| 118 void Remove(MockRenderProcessHost* host) const; | 118 void Remove(MockRenderProcessHost* host) const; |
| 119 | 119 |
| 120 class Observer { |
| 121 public: |
| 122 Observer(MockRenderProcessHostFactory* factory); |
| 123 virtual ~Observer(); |
| 124 virtual void OnRenderProcessHostCreated(MockRenderProcessHost*) {} |
| 125 virtual void OnRenderProcessHostDestroyed(MockRenderProcessHost*) {} |
| 126 private: |
| 127 MockRenderProcessHostFactory* factory_; |
| 128 }; |
| 129 |
| 130 void AddObserver(Observer* obs) { |
| 131 observer_list_.AddObserver(obs); |
| 132 } |
| 133 void RemoveObserver(Observer* obs) { |
| 134 observer_list_.RemoveObserver(obs); |
| 135 } |
| 136 |
| 120 private: | 137 private: |
| 121 // A list of MockRenderProcessHosts created by this object. This list is used | 138 // A list of MockRenderProcessHosts created by this object. This list is used |
| 122 // for deleting all MockRenderProcessHosts that have not deleted by a test in | 139 // for deleting all MockRenderProcessHosts that have not deleted by a test in |
| 123 // the destructor and prevent them from being leaked. | 140 // the destructor and prevent them from being leaked. |
| 124 mutable ScopedVector<MockRenderProcessHost> processes_; | 141 mutable ScopedVector<MockRenderProcessHost> processes_; |
| 125 | 142 |
| 143 mutable ObserverList<Observer> observer_list_; |
| 144 |
| 126 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); | 145 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); |
| 127 }; | 146 }; |
| 128 | 147 |
| 129 } // namespace content | 148 } // namespace content |
| 130 | 149 |
| 131 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ | 150 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ |
| OLD | NEW |