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

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: Rebase on https://codereview.chromium.org/1312213010/ Created 5 years, 2 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/browser/navigation_throttle.cc ('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/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::ReadyToCommitNavigation( 148 void WebContentsObserverSanityChecker::ReadyToCommitNavigation(
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(!navigation_handle->HasCommittedDocument()); 153 CHECK(!navigation_handle->HasCommittedDocument());
152 CHECK(!navigation_handle->HasCommittedErrorPage()); 154 CHECK(!navigation_handle->HasCommittedErrorPage());
153 } 155 }
154 156
155 void WebContentsObserverSanityChecker::DidCommitNavigation( 157 void WebContentsObserverSanityChecker::DidCommitNavigation(
156 NavigationHandle* navigation_handle) { 158 NavigationHandle* navigation_handle) {
157 CHECK(NavigationIsOngoing(navigation_handle)); 159 CHECK(NavigationIsOngoing(navigation_handle));
158 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle)); 160 CHECK(!NavigationIsOngoingAndCommitted(navigation_handle));
159 161
160 CHECK_NE(navigation_handle->HasCommittedDocument(), 162 CHECK_NE(navigation_handle->HasCommittedDocument(),
161 navigation_handle->HasCommittedErrorPage()); 163 navigation_handle->HasCommittedErrorPage());
162 CHECK_IMPLIES(navigation_handle->HasCommittedDocument(), 164 CHECK_IMPLIES(navigation_handle->HasCommittedDocument(),
163 navigation_handle->GetNetErrorCode() == net::OK); 165 navigation_handle->GetNetErrorCode() == net::OK);
164 CHECK_IMPLIES(navigation_handle->HasCommittedErrorPage(), 166 CHECK_IMPLIES(navigation_handle->HasCommittedErrorPage(),
165 navigation_handle->GetNetErrorCode() != net::OK); 167 navigation_handle->GetNetErrorCode() != net::OK);
168 CHECK_EQ(navigation_handle->GetWebContents(), web_contents());
166 169
167 ongoing_committed_navigations_.insert(navigation_handle); 170 ongoing_committed_navigations_.insert(navigation_handle);
168 } 171 }
169 172
170 void WebContentsObserverSanityChecker::DidFinishNavigation( 173 void WebContentsObserverSanityChecker::DidFinishNavigation(
171 NavigationHandle* navigation_handle) { 174 NavigationHandle* navigation_handle) {
172 CHECK(NavigationIsOngoing(navigation_handle)); 175 CHECK(NavigationIsOngoing(navigation_handle));
173 176
174 CHECK_IMPLIES(NavigationIsOngoingAndCommitted(navigation_handle), 177 CHECK_IMPLIES(NavigationIsOngoingAndCommitted(navigation_handle),
175 navigation_handle->HasCommittedDocument() != 178 navigation_handle->HasCommittedDocument() !=
176 navigation_handle->HasCommittedErrorPage()); 179 navigation_handle->HasCommittedErrorPage());
177 CHECK_IMPLIES(navigation_handle->HasCommittedDocument(), 180 CHECK_IMPLIES(navigation_handle->HasCommittedDocument(),
178 navigation_handle->GetNetErrorCode() == net::OK); 181 navigation_handle->GetNetErrorCode() == net::OK);
179 CHECK_IMPLIES(navigation_handle->HasCommittedErrorPage(), 182 CHECK_IMPLIES(navigation_handle->HasCommittedErrorPage(),
180 navigation_handle->GetNetErrorCode() != net::OK); 183 navigation_handle->GetNetErrorCode() != net::OK);
184 CHECK_EQ(navigation_handle->GetWebContents(), web_contents());
181 185
182 if (NavigationIsOngoingAndCommitted(navigation_handle)) 186 if (NavigationIsOngoingAndCommitted(navigation_handle))
183 ongoing_committed_navigations_.erase(navigation_handle); 187 ongoing_committed_navigations_.erase(navigation_handle);
184 188
185 ongoing_navigations_.erase(navigation_handle); 189 ongoing_navigations_.erase(navigation_handle);
186 } 190 }
187 191
188 void WebContentsObserverSanityChecker::DidStartProvisionalLoadForFrame( 192 void WebContentsObserverSanityChecker::DidStartProvisionalLoadForFrame(
189 RenderFrameHost* render_frame_host, 193 RenderFrameHost* render_frame_host,
190 const GURL& validated_url, 194 const GURL& validated_url,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 return it != ongoing_navigations_.end(); 344 return it != ongoing_navigations_.end();
341 } 345 }
342 346
343 bool WebContentsObserverSanityChecker::NavigationIsOngoingAndCommitted( 347 bool WebContentsObserverSanityChecker::NavigationIsOngoingAndCommitted(
344 NavigationHandle* navigation_handle) { 348 NavigationHandle* navigation_handle) {
345 auto it = ongoing_committed_navigations_.find(navigation_handle); 349 auto it = ongoing_committed_navigations_.find(navigation_handle);
346 return it != ongoing_committed_navigations_.end(); 350 return it != ongoing_committed_navigations_.end();
347 } 351 }
348 352
349 } // namespace content 353 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/navigation_throttle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698