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

Side by Side Diff: components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc

Issue 1043013002: favor DCHECK_CURRENTLY_ON for better logs in components/ (part 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: content namespace needed after all Created 5 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "components/navigation_interception/intercept_navigation_resource_throt tle.h" 10 #include "components/navigation_interception/intercept_navigation_resource_throt tle.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 int render_process_id, 112 int render_process_id,
113 int render_frame_id, 113 int render_frame_id,
114 const std::string& request_method, 114 const std::string& request_method,
115 RedirectMode redirect_mode, 115 RedirectMode redirect_mode,
116 MockInterceptCallbackReceiver* callback_receiver) 116 MockInterceptCallbackReceiver* callback_receiver)
117 : resource_context_(&test_url_request_context_), 117 : resource_context_(&test_url_request_context_),
118 request_(resource_context_.GetRequestContext()->CreateRequest( 118 request_(resource_context_.GetRequestContext()->CreateRequest(
119 url, 119 url,
120 net::DEFAULT_PRIORITY, 120 net::DEFAULT_PRIORITY,
121 NULL /* delegate */)) { 121 NULL /* delegate */)) {
122 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 122 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
123 if (render_process_id != MSG_ROUTING_NONE && 123 if (render_process_id != MSG_ROUTING_NONE &&
124 render_frame_id != MSG_ROUTING_NONE) { 124 render_frame_id != MSG_ROUTING_NONE) {
125 content::ResourceRequestInfo::AllocateForTesting( 125 content::ResourceRequestInfo::AllocateForTesting(
126 request_.get(), 126 request_.get(),
127 content::RESOURCE_TYPE_MAIN_FRAME, 127 content::RESOURCE_TYPE_MAIN_FRAME,
128 &resource_context_, 128 &resource_context_,
129 render_process_id, 129 render_process_id,
130 MSG_ROUTING_NONE, 130 MSG_ROUTING_NONE,
131 render_frame_id, 131 render_frame_id,
132 true, // is_main_frame 132 true, // is_main_frame
(...skipping 10 matching lines...) Expand all
143 143
144 if (redirect_mode == REDIRECT_MODE_302) { 144 if (redirect_mode == REDIRECT_MODE_302) {
145 net::HttpResponseInfo& response_info = 145 net::HttpResponseInfo& response_info =
146 const_cast<net::HttpResponseInfo&>(request_->response_info()); 146 const_cast<net::HttpResponseInfo&>(request_->response_info());
147 response_info.headers = new net::HttpResponseHeaders( 147 response_info.headers = new net::HttpResponseHeaders(
148 "Status: 302 Found\0\0"); 148 "Status: 302 Found\0\0");
149 } 149 }
150 } 150 }
151 151
152 void ThrottleWillStartRequest(bool* defer) { 152 void ThrottleWillStartRequest(bool* defer) {
153 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 153 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
154 throttle_->WillStartRequest(defer); 154 throttle_->WillStartRequest(defer);
155 } 155 }
156 156
157 void ThrottleWillRedirectRequest(const net::RedirectInfo& redirect_info, 157 void ThrottleWillRedirectRequest(const net::RedirectInfo& redirect_info,
158 bool* defer) { 158 bool* defer) {
159 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 159 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
160 throttle_->WillRedirectRequest(redirect_info, defer); 160 throttle_->WillRedirectRequest(redirect_info, defer);
161 } 161 }
162 162
163 bool request_resumed() const { 163 bool request_resumed() const {
164 return throttle_controller_.status() == 164 return throttle_controller_.status() ==
165 MockResourceController::RESUMED; 165 MockResourceController::RESUMED;
166 } 166 }
167 167
168 bool request_cancelled() const { 168 bool request_cancelled() const {
169 return throttle_controller_.status() == 169 return throttle_controller_.status() ==
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 io_thread_state_ = io_thread_state; 204 io_thread_state_ = io_thread_state;
205 } 205 }
206 206
207 void RunThrottleWillStartRequestOnIOThread( 207 void RunThrottleWillStartRequestOnIOThread(
208 const GURL& url, 208 const GURL& url,
209 const std::string& request_method, 209 const std::string& request_method,
210 RedirectMode redirect_mode, 210 RedirectMode redirect_mode,
211 int render_process_id, 211 int render_process_id,
212 int render_frame_id, 212 int render_frame_id,
213 bool* defer) { 213 bool* defer) {
214 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 214 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
215 TestIOThreadState* io_thread_state = 215 TestIOThreadState* io_thread_state =
216 new TestIOThreadState(url, render_process_id, render_frame_id, 216 new TestIOThreadState(url, render_process_id, render_frame_id,
217 request_method, redirect_mode, 217 request_method, redirect_mode,
218 mock_callback_receiver_.get()); 218 mock_callback_receiver_.get());
219 219
220 SetIOThreadState(io_thread_state); 220 SetIOThreadState(io_thread_state);
221 221
222 if (redirect_mode == REDIRECT_MODE_NO_REDIRECT) { 222 if (redirect_mode == REDIRECT_MODE_NO_REDIRECT) {
223 io_thread_state->ThrottleWillStartRequest(defer); 223 io_thread_state->ThrottleWillStartRequest(defer);
224 } else { 224 } else {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 REDIRECT_MODE_302, 472 REDIRECT_MODE_302,
473 web_contents()->GetRenderViewHost()->GetProcess()->GetID(), 473 web_contents()->GetRenderViewHost()->GetProcess()->GetID(),
474 web_contents()->GetMainFrame()->GetRoutingID(), 474 web_contents()->GetMainFrame()->GetRoutingID(),
475 base::Unretained(&defer))); 475 base::Unretained(&defer)));
476 476
477 // Wait for the request to finish processing. 477 // Wait for the request to finish processing.
478 base::RunLoop().RunUntilIdle(); 478 base::RunLoop().RunUntilIdle();
479 } 479 }
480 480
481 } // namespace navigation_interception 481 } // namespace navigation_interception
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_browser.cc ('k') | components/storage_monitor/image_capture_device.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698