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

Side by Side Diff: content/browser/renderer_host/render_view_host_manager_browsertest.cc

Issue 8676032: Move RenderViewHostObserver to content/public/browser/ and put it into the content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add render_view_host.h to DEPS file Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/test/base/in_process_browser_test.h" 9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/browser/renderer_host/render_view_host.h" 11 #include "content/browser/renderer_host/render_view_host.h"
12 #include "content/browser/renderer_host/render_view_host_observer.h"
13 #include "content/browser/site_instance.h" 12 #include "content/browser/site_instance.h"
14 #include "content/browser/tab_contents/tab_contents.h" 13 #include "content/browser/tab_contents/tab_contents.h"
15 #include "content/public/browser/notification_details.h" 14 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.h"
18 #include "content/public/browser/notification_types.h" 17 #include "content/public/browser/notification_types.h"
18 #include "content/public/browser/render_view_host_observer.h"
19 #include "content/public/common/url_constants.h" 19 #include "content/public/common/url_constants.h"
20 #include "net/base/net_util.h" 20 #include "net/base/net_util.h"
21 #include "net/test/test_server.h" 21 #include "net/test/test_server.h"
22 22
23 class RenderViewHostManagerTest : public InProcessBrowserTest { 23 class RenderViewHostManagerTest : public InProcessBrowserTest {
24 public: 24 public:
25 RenderViewHostManagerTest() { 25 RenderViewHostManagerTest() {
26 EnableDOMAutomation(); 26 EnableDOMAutomation();
27 } 27 }
28 28
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 263 }
264 } 264 }
265 void AddObserverToRVH(RenderViewHost* rvh) { 265 void AddObserverToRVH(RenderViewHost* rvh) {
266 observers_.push_back(new RVHObserver(this, rvh)); 266 observers_.push_back(new RVHObserver(this, rvh));
267 } 267 }
268 size_t GetNumObservers() const { 268 size_t GetNumObservers() const {
269 return observers_.size(); 269 return observers_.size();
270 } 270 }
271 private: 271 private:
272 friend class RVHObserver; 272 friend class RVHObserver;
273 class RVHObserver : public RenderViewHostObserver { 273 class RVHObserver : public content::RenderViewHostObserver {
274 public: 274 public:
275 RVHObserver(RenderViewHostObserverArray* parent, RenderViewHost* rvh) 275 RVHObserver(RenderViewHostObserverArray* parent, RenderViewHost* rvh)
276 : RenderViewHostObserver(rvh), 276 : content::RenderViewHostObserver(rvh),
277 parent_(parent) { 277 parent_(parent) {
278 } 278 }
279 virtual void RenderViewHostDestroyed(RenderViewHost* rvh) OVERRIDE { 279 virtual void RenderViewHostDestroyed(RenderViewHost* rvh) OVERRIDE {
280 if (parent_) 280 if (parent_)
281 parent_->RemoveObserver(this); 281 parent_->RemoveObserver(this);
282 RenderViewHostObserver::RenderViewHostDestroyed(rvh); 282 content::RenderViewHostObserver::RenderViewHostDestroyed(rvh);
283 }; 283 };
284 void ClearParent() { 284 void ClearParent() {
285 parent_ = NULL; 285 parent_ = NULL;
286 } 286 }
287 private: 287 private:
288 RenderViewHostObserverArray* parent_; 288 RenderViewHostObserverArray* parent_;
289 }; 289 };
290 290
291 void RemoveObserver(RVHObserver* observer) { 291 void RemoveObserver(RVHObserver* observer) {
292 observers_.remove(observer); 292 observers_.remove(observer);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 // Now navigate to a different instance so that we swap out again. 328 // Now navigate to a different instance so that we swap out again.
329 ui_test_utils::NavigateToURL(browser(), 329 ui_test_utils::NavigateToURL(browser(),
330 https_server.GetURL("files/title2.html")); 330 https_server.GetURL("files/title2.html"));
331 rvh_observers.AddObserverToRVH(browser()->GetSelectedTabContents()-> 331 rvh_observers.AddObserverToRVH(browser()->GetSelectedTabContents()->
332 render_view_host()); 332 render_view_host());
333 333
334 // This used to leak a render view host. 334 // This used to leak a render view host.
335 browser()->CloseTabContents(browser()->GetSelectedTabContents()); 335 browser()->CloseTabContents(browser()->GetSelectedTabContents());
336 EXPECT_EQ(0U, rvh_observers.GetNumObservers()); 336 EXPECT_EQ(0U, rvh_observers.GetNumObservers());
337 } 337 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host.cc ('k') | content/browser/renderer_host/render_view_host_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698