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

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

Issue 1269813002: Add a NavigationThrottle to the public content/ interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation-api
Patch Set: Removed TestNavigationHandle + pointer to WebContents Created 5 years, 3 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
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/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/browser/frame_host/render_frame_host_impl.h"
9 #include "content/common/frame_messages.h" 9 #include "content/common/frame_messages.h"
10 #include "content/public/browser/navigation_handle.h" 10 #include "content/public/browser/navigation_handle.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 122 }
123 123
124 void WebContentsObserverSanityChecker::DidStartNavigation( 124 void WebContentsObserverSanityChecker::DidStartNavigation(
125 NavigationHandle* navigation_handle) { 125 NavigationHandle* navigation_handle) {
126 CHECK(!NavigationIsOngoing(navigation_handle)); 126 CHECK(!NavigationIsOngoing(navigation_handle));
127 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle)); 127 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle));
128 128
129 CHECK(navigation_handle->GetNetErrorCode() == net::OK); 129 CHECK(navigation_handle->GetNetErrorCode() == net::OK);
130 CHECK(!navigation_handle->HasCommittedDocument()); 130 CHECK(!navigation_handle->HasCommittedDocument());
131 CHECK(!navigation_handle->HasCommittedErrorPage()); 131 CHECK(!navigation_handle->HasCommittedErrorPage());
132 CHECK_EQ(navigation_handle->GetWebContents(), web_contents());
132 133
133 ongoing_navigations_.insert(navigation_handle); 134 ongoing_navigations_.insert(navigation_handle);
134 } 135 }
135 136
136 void WebContentsObserverSanityChecker::DidRedirectNavigation( 137 void WebContentsObserverSanityChecker::DidRedirectNavigation(
137 NavigationHandle* navigation_handle) { 138 NavigationHandle* navigation_handle) {
138 CHECK(NavigationIsOngoing(navigation_handle)); 139 CHECK(NavigationIsOngoing(navigation_handle));
139 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle)); 140 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle));
140 141
141 CHECK(navigation_handle->GetNetErrorCode() == net::OK); 142 CHECK(navigation_handle->GetNetErrorCode() == net::OK);
142 CHECK(!navigation_handle->HasCommittedDocument()); 143 CHECK(!navigation_handle->HasCommittedDocument());
143 CHECK(!navigation_handle->HasCommittedErrorPage()); 144 CHECK(!navigation_handle->HasCommittedErrorPage());
145 CHECK_EQ(navigation_handle->GetWebContents(), web_contents());
144 } 146 }
145 147
146 void WebContentsObserverSanityChecker::DidCommitNavigation( 148 void WebContentsObserverSanityChecker::DidCommitNavigation(
147 NavigationHandle* navigation_handle) { 149 NavigationHandle* navigation_handle) {
148 CHECK(NavigationIsOngoing(navigation_handle)); 150 CHECK(NavigationIsOngoing(navigation_handle));
149 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle)); 151 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle));
150 152
151 CHECK_NE(navigation_handle->HasCommittedDocument(), 153 CHECK_NE(navigation_handle->HasCommittedDocument(),
152 navigation_handle->HasCommittedErrorPage()); 154 navigation_handle->HasCommittedErrorPage());
153 CHECK_IMPLIES(navigation_handle->HasCommittedDocument(), 155 CHECK_IMPLIES(navigation_handle->HasCommittedDocument(),
154 navigation_handle->GetNetErrorCode() == net::OK); 156 navigation_handle->GetNetErrorCode() == net::OK);
155 CHECK_IMPLIES(navigation_handle->HasCommittedErrorPage(), 157 CHECK_IMPLIES(navigation_handle->HasCommittedErrorPage(),
156 navigation_handle->GetNetErrorCode() != net::OK); 158 navigation_handle->GetNetErrorCode() != net::OK);
159 CHECK_EQ(navigation_handle->GetWebContents(), web_contents());
157 160
158 ongoing_committed_navigations_.insert(navigation_handle); 161 ongoing_committed_navigations_.insert(navigation_handle);
159 } 162 }
160 163
161 void WebContentsObserverSanityChecker::DidFinishNavigation( 164 void WebContentsObserverSanityChecker::DidFinishNavigation(
162 NavigationHandle* navigation_handle) { 165 NavigationHandle* navigation_handle) {
163 CHECK(NavigationIsOngoing(navigation_handle)); 166 CHECK(NavigationIsOngoing(navigation_handle));
164 167
165 CHECK_IMPLIES(NavigationIsOngoingAndCommitted(navigation_handle), 168 CHECK_IMPLIES(NavigationIsOngoingAndCommitted(navigation_handle),
166 navigation_handle->HasCommittedDocument() != 169 navigation_handle->HasCommittedDocument() !=
167 navigation_handle->HasCommittedErrorPage()); 170 navigation_handle->HasCommittedErrorPage());
168 CHECK_IMPLIES(navigation_handle->HasCommittedDocument(), 171 CHECK_IMPLIES(navigation_handle->HasCommittedDocument(),
169 navigation_handle->GetNetErrorCode() == net::OK); 172 navigation_handle->GetNetErrorCode() == net::OK);
170 CHECK_IMPLIES(navigation_handle->HasCommittedErrorPage(), 173 CHECK_IMPLIES(navigation_handle->HasCommittedErrorPage(),
171 navigation_handle->GetNetErrorCode() != net::OK); 174 navigation_handle->GetNetErrorCode() != net::OK);
175 CHECK_EQ(navigation_handle->GetWebContents(), web_contents());
172 176
173 if (NavigationIsOngoingAndCommitted(navigation_handle)) 177 if (NavigationIsOngoingAndCommitted(navigation_handle))
174 ongoing_committed_navigations_.erase(navigation_handle); 178 ongoing_committed_navigations_.erase(navigation_handle);
175 179
176 ongoing_navigations_.erase(navigation_handle); 180 ongoing_navigations_.erase(navigation_handle);
177 } 181 }
178 182
179 void WebContentsObserverSanityChecker::DidStartProvisionalLoadForFrame( 183 void WebContentsObserverSanityChecker::DidStartProvisionalLoadForFrame(
180 RenderFrameHost* render_frame_host, 184 RenderFrameHost* render_frame_host,
181 const GURL& validated_url, 185 const GURL& validated_url,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 return it != ongoing_navigations_.end(); 335 return it != ongoing_navigations_.end();
332 } 336 }
333 337
334 bool WebContentsObserverSanityChecker::NavigationIsOngoingAndCommitted( 338 bool WebContentsObserverSanityChecker::NavigationIsOngoingAndCommitted(
335 NavigationHandle* navigation_handle) { 339 NavigationHandle* navigation_handle) {
336 auto it = ongoing_committed_navigations_.find(navigation_handle); 340 auto it = ongoing_committed_navigations_.find(navigation_handle);
337 return it != ongoing_committed_navigations_.end(); 341 return it != ongoing_committed_navigations_.end();
338 } 342 }
339 343
340 } // namespace content 344 } // namespace content
OLDNEW
« content/public/browser/navigation_handle.cc ('K') | « content/public/browser/navigation_throttle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698