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/memory/ptr_util.h" |
7 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
8 #include "build/build_config.h" | 9 #include "build/build_config.h" |
9 #include "content/browser/frame_host/render_frame_host_impl.h" | 10 #include "content/browser/frame_host/render_frame_host_impl.h" |
10 #include "content/common/frame_messages.h" | 11 #include "content/common/frame_messages.h" |
11 #include "content/public/browser/navigation_handle.h" | 12 #include "content/public/browser/navigation_handle.h" |
12 #include "content/public/browser/render_frame_host.h" | 13 #include "content/public/browser/render_frame_host.h" |
13 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
14 #include "content/public/browser/site_instance.h" | 15 #include "content/public/browser/site_instance.h" |
15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
16 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
(...skipping 11 matching lines...) Expand all Loading... |
28 return GlobalRoutingID(0, 0); | 29 return GlobalRoutingID(0, 0); |
29 return GlobalRoutingID(host->GetProcess()->GetID(), host->GetRoutingID()); | 30 return GlobalRoutingID(host->GetProcess()->GetID(), host->GetRoutingID()); |
30 } | 31 } |
31 | 32 |
32 } // namespace | 33 } // namespace |
33 | 34 |
34 // static | 35 // static |
35 void WebContentsObserverSanityChecker::Enable(WebContents* web_contents) { | 36 void WebContentsObserverSanityChecker::Enable(WebContents* web_contents) { |
36 if (web_contents->GetUserData(&kWebContentsObserverSanityCheckerKey)) | 37 if (web_contents->GetUserData(&kWebContentsObserverSanityCheckerKey)) |
37 return; | 38 return; |
38 web_contents->SetUserData(&kWebContentsObserverSanityCheckerKey, | 39 web_contents->SetUserData( |
39 new WebContentsObserverSanityChecker(web_contents)); | 40 &kWebContentsObserverSanityCheckerKey, |
| 41 base::WrapUnique(new WebContentsObserverSanityChecker(web_contents))); |
40 } | 42 } |
41 | 43 |
42 void WebContentsObserverSanityChecker::RenderFrameCreated( | 44 void WebContentsObserverSanityChecker::RenderFrameCreated( |
43 RenderFrameHost* render_frame_host) { | 45 RenderFrameHost* render_frame_host) { |
44 CHECK(!web_contents_destroyed_); | 46 CHECK(!web_contents_destroyed_); |
45 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); | 47 GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); |
46 bool frame_exists = !live_routes_.insert(routing_pair).second; | 48 bool frame_exists = !live_routes_.insert(routing_pair).second; |
47 deleted_routes_.erase(routing_pair); | 49 deleted_routes_.erase(routing_pair); |
48 | 50 |
49 if (frame_exists) { | 51 if (frame_exists) { |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 if (live_routes_.count(entry.first)) | 374 if (live_routes_.count(entry.first)) |
373 return true; | 375 return true; |
374 if (current_hosts_.count(entry.first)) | 376 if (current_hosts_.count(entry.first)) |
375 return true; | 377 return true; |
376 } | 378 } |
377 } | 379 } |
378 return false; | 380 return false; |
379 } | 381 } |
380 | 382 |
381 } // namespace content | 383 } // namespace content |
OLD | NEW |