Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: content/public/test/mock_render_process_host.h

Issue 13533007: Test extension reloading behavior. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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) : factory_(factory) {
123 factory->AddObserver(this);
Paweł Hajdan Jr. 2013/04/04 21:30:05 nit: Why this code doesn't move the implementation
Jeffrey Yasskin 2013/04/05 13:14:01 Done.
124 }
125 virtual ~Observer();
126 virtual void OnRenderProcessHostCreated(MockRenderProcessHost*) {}
127 virtual void OnRenderProcessHostDestroyed(MockRenderProcessHost*) {}
128 private:
129 MockRenderProcessHostFactory* factory_;
130 };
131
132 void AddObserver(Observer* obs) {
133 observer_list_.AddObserver(obs);
134 }
135 void RemoveObserver(Observer* obs) {
136 observer_list_.RemoveObserver(obs);
137 }
138
120 private: 139 private:
121 // A list of MockRenderProcessHosts created by this object. This list is used 140 // 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 141 // for deleting all MockRenderProcessHosts that have not deleted by a test in
123 // the destructor and prevent them from being leaked. 142 // the destructor and prevent them from being leaked.
124 mutable ScopedVector<MockRenderProcessHost> processes_; 143 mutable ScopedVector<MockRenderProcessHost> processes_;
125 144
145 mutable ObserverList<Observer> observer_list_;
146
126 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); 147 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory);
127 }; 148 };
128 149
129 } // namespace content 150 } // namespace content
130 151
131 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ 152 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698