OLD | NEW |
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/test/web_contents_observer_sanity_checker.h" | 5 #include "content/test/web_contents_observer_sanity_checker.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "content/browser/frame_host/render_frame_host_impl.h" |
8 #include "content/common/frame_messages.h" | 9 #include "content/common/frame_messages.h" |
9 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
10 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
11 #include "content/public/browser/site_instance.h" | 12 #include "content/public/browser/site_instance.h" |
12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
13 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 namespace { | 18 namespace { |
(...skipping 17 matching lines...) Expand all Loading... |
35 std::pair<int, int> routing_pair = | 36 std::pair<int, int> routing_pair = |
36 std::make_pair(render_frame_host->GetProcess()->GetID(), | 37 std::make_pair(render_frame_host->GetProcess()->GetID(), |
37 render_frame_host->GetRoutingID()); | 38 render_frame_host->GetRoutingID()); |
38 bool frame_exists = !live_routes_.insert(routing_pair).second; | 39 bool frame_exists = !live_routes_.insert(routing_pair).second; |
39 deleted_routes_.erase(routing_pair); | 40 deleted_routes_.erase(routing_pair); |
40 | 41 |
41 if (frame_exists) { | 42 if (frame_exists) { |
42 CHECK(false) << "RenderFrameCreated called more than once for routing pair:" | 43 CHECK(false) << "RenderFrameCreated called more than once for routing pair:" |
43 << Format(render_frame_host); | 44 << Format(render_frame_host); |
44 } | 45 } |
| 46 |
| 47 CHECK(render_frame_host->GetProcess()->HasConnection()) |
| 48 << "RenderFrameCreated was called for a RenderFrameHost whose render " |
| 49 "process is not currently live, so there's no way for the RenderFrame " |
| 50 "to have been created."; |
| 51 CHECK( |
| 52 static_cast<RenderFrameHostImpl*>(render_frame_host)->IsRenderFrameLive()) |
| 53 << "RenderFrameCreated called on for a RenderFrameHost that thinks it is " |
| 54 "not alive."; |
45 } | 55 } |
46 | 56 |
47 void WebContentsObserverSanityChecker::RenderFrameDeleted( | 57 void WebContentsObserverSanityChecker::RenderFrameDeleted( |
48 RenderFrameHost* render_frame_host) { | 58 RenderFrameHost* render_frame_host) { |
49 CHECK(!web_contents_destroyed_); | 59 CHECK(!web_contents_destroyed_); |
50 std::pair<int, int> routing_pair = | 60 std::pair<int, int> routing_pair = |
51 std::make_pair(render_frame_host->GetProcess()->GetID(), | 61 std::make_pair(render_frame_host->GetProcess()->GetID(), |
52 render_frame_host->GetRoutingID()); | 62 render_frame_host->GetRoutingID()); |
53 bool was_live = !!live_routes_.erase(routing_pair); | 63 bool was_live = !!live_routes_.erase(routing_pair); |
54 bool was_dead_already = !deleted_routes_.insert(routing_pair).second; | 64 bool was_dead_already = !deleted_routes_.insert(routing_pair).second; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 258 |
249 std::string WebContentsObserverSanityChecker::Format( | 259 std::string WebContentsObserverSanityChecker::Format( |
250 RenderFrameHost* render_frame_host) { | 260 RenderFrameHost* render_frame_host) { |
251 return base::StringPrintf( | 261 return base::StringPrintf( |
252 "(%d, %d -> %s)", render_frame_host->GetProcess()->GetID(), | 262 "(%d, %d -> %s)", render_frame_host->GetProcess()->GetID(), |
253 render_frame_host->GetRoutingID(), | 263 render_frame_host->GetRoutingID(), |
254 render_frame_host->GetSiteInstance()->GetSiteURL().spec().c_str()); | 264 render_frame_host->GetSiteInstance()->GetSiteURL().spec().c_str()); |
255 } | 265 } |
256 | 266 |
257 } // namespace content | 267 } // namespace content |
OLD | NEW |