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

Side by Side Diff: content/public/test/web_contents_observer_sanity_checker.cc

Issue 950223006: Fix RenderFrameHostChanged WebContentsObserver methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes based on Charlie's review. Created 5 years, 9 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
« no previous file with comments | « content/public/test/web_contents_observer_sanity_checker.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/public/test/web_contents_observer_sanity_checker.h" 5 #include "content/public/test/web_contents_observer_sanity_checker.h"
6 6
7 #include "base/debug/stack_trace.h"
8 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
9 #include "content/common/frame_messages.h" 8 #include "content/common/frame_messages.h"
10 #include "content/public/browser/render_frame_host.h" 9 #include "content/public/browser/render_frame_host.h"
11 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
12 #include "content/public/browser/site_instance.h" 11 #include "content/public/browser/site_instance.h"
13 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
14 #include "content/public/browser/web_contents_observer.h" 13 #include "content/public/browser/web_contents_observer.h"
15 14
16 namespace content { 15 namespace content {
17 16
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 RenderFrameHost* render_frame_host) { 72 RenderFrameHost* render_frame_host) {
74 // TODO(nick): Record this. 73 // TODO(nick): Record this.
75 } 74 }
76 75
77 void WebContentsObserverSanityChecker::RenderFrameHostChanged( 76 void WebContentsObserverSanityChecker::RenderFrameHostChanged(
78 RenderFrameHost* old_host, 77 RenderFrameHost* old_host,
79 RenderFrameHost* new_host) { 78 RenderFrameHost* new_host) {
80 CHECK(new_host); 79 CHECK(new_host);
81 CHECK_NE(new_host, old_host); 80 CHECK_NE(new_host, old_host);
82 81
83 // TODO(nasko): Implement consistency checking for RenderFrameHostChanged 82 if (old_host) {
84 // in follow up CL. 83 std::pair<int, int> routing_pair =
84 std::make_pair(old_host->GetProcess()->GetID(),
85 old_host->GetRoutingID());
86 bool old_did_exist = !!current_hosts_.erase(routing_pair);
87 if (!old_did_exist) {
88 CHECK(false)
89 << "RenderFrameHostChanged called with old host that did not exist:"
90 << Format(old_host);
91 }
92 }
93
94 std::pair<int, int> routing_pair =
95 std::make_pair(new_host->GetProcess()->GetID(),
96 new_host->GetRoutingID());
97 bool host_exists = !current_hosts_.insert(routing_pair).second;
98 if (host_exists) {
99 CHECK(false)
100 << "RenderFrameHostChanged called more than once for routing pair:"
101 << Format(new_host);
102 }
85 } 103 }
86 104
87 void WebContentsObserverSanityChecker::FrameDeleted( 105 void WebContentsObserverSanityChecker::FrameDeleted(
88 RenderFrameHost* render_frame_host) { 106 RenderFrameHost* render_frame_host) {
89 // A frame can be deleted before RenderFrame in the renderer process is 107 // A frame can be deleted before RenderFrame in the renderer process is
90 // created, so there is not much that can be enforced here. 108 // created, so there is not much that can be enforced here.
91 CHECK(!web_contents_destroyed_); 109 CHECK(!web_contents_destroyed_);
92 } 110 }
93 111
94 void WebContentsObserverSanityChecker::DidStartProvisionalLoadForFrame( 112 void WebContentsObserverSanityChecker::DidStartProvisionalLoadForFrame(
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 248
231 std::string WebContentsObserverSanityChecker::Format( 249 std::string WebContentsObserverSanityChecker::Format(
232 RenderFrameHost* render_frame_host) { 250 RenderFrameHost* render_frame_host) {
233 return base::StringPrintf( 251 return base::StringPrintf(
234 "(%d, %d -> %s)", render_frame_host->GetProcess()->GetID(), 252 "(%d, %d -> %s)", render_frame_host->GetProcess()->GetID(),
235 render_frame_host->GetRoutingID(), 253 render_frame_host->GetRoutingID(),
236 render_frame_host->GetSiteInstance()->GetSiteURL().spec().c_str()); 254 render_frame_host->GetSiteInstance()->GetSiteURL().spec().c_str());
237 } 255 }
238 256
239 } // namespace content 257 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/web_contents_observer_sanity_checker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698