Chromium Code Reviews| 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/child/web_url_loader_impl.h" | 5 #include "content/child/web_url_loader_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 client_(NULL), | 366 client_(NULL), |
| 367 resource_dispatcher_(resource_dispatcher), | 367 resource_dispatcher_(resource_dispatcher), |
| 368 task_runner_(task_runner), | 368 task_runner_(task_runner), |
| 369 referrer_policy_(blink::WebReferrerPolicyDefault), | 369 referrer_policy_(blink::WebReferrerPolicyDefault), |
| 370 got_all_stream_body_data_(false), | 370 got_all_stream_body_data_(false), |
| 371 defers_loading_(NOT_DEFERRING), | 371 defers_loading_(NOT_DEFERRING), |
| 372 request_id_(-1) { | 372 request_id_(-1) { |
| 373 } | 373 } |
| 374 | 374 |
| 375 void WebURLLoaderImpl::Context::Cancel() { | 375 void WebURLLoaderImpl::Context::Cancel() { |
| 376 if (resource_dispatcher_) // NULL in unittest. | 376 if (resource_dispatcher_ && // NULL in unittest. |
| 377 request_id_ != -1) { | |
| 377 resource_dispatcher_->Cancel(request_id_); | 378 resource_dispatcher_->Cancel(request_id_); |
|
Ken Russell (switch to Gerrit)
2015/02/20 17:52:51
Is it OK that we'll potentially send a -1 request_
jam
2015/02/20 17:56:29
How could that happen? This if statement is guarde
Ken Russell (switch to Gerrit)
2015/02/20 17:57:30
Ah, sorry, I read the diffs backward and thought y
| |
| 379 request_id_ = -1; | |
| 380 } | |
| 378 | 381 |
| 379 // Ensure that we do not notify the multipart delegate anymore as it has | 382 // Ensure that we do not notify the multipart delegate anymore as it has |
| 380 // its own pointer to the client. | 383 // its own pointer to the client. |
| 381 if (multipart_delegate_) | 384 if (multipart_delegate_) |
| 382 multipart_delegate_->Cancel(); | 385 multipart_delegate_->Cancel(); |
| 383 // Ditto for the ftp delegate. | 386 // Ditto for the ftp delegate. |
| 384 if (ftp_listing_delegate_) | 387 if (ftp_listing_delegate_) |
| 385 ftp_listing_delegate_->Cancel(); | 388 ftp_listing_delegate_->Cancel(); |
| 386 | 389 |
| 387 // Do not make any further calls to the client. | 390 // Do not make any further calls to the client. |
| 388 client_ = NULL; | 391 client_ = NULL; |
| 389 loader_ = NULL; | 392 loader_ = NULL; |
| 390 } | 393 } |
| 391 | 394 |
| 392 void WebURLLoaderImpl::Context::SetDefersLoading(bool value) { | 395 void WebURLLoaderImpl::Context::SetDefersLoading(bool value) { |
| 393 resource_dispatcher_->SetDefersLoading(request_id_, value); | 396 if (request_id_ != -1) |
| 397 resource_dispatcher_->SetDefersLoading(request_id_, value); | |
| 394 if (value && defers_loading_ == NOT_DEFERRING) { | 398 if (value && defers_loading_ == NOT_DEFERRING) { |
| 395 defers_loading_ = SHOULD_DEFER; | 399 defers_loading_ = SHOULD_DEFER; |
| 396 } else if (!value && defers_loading_ != NOT_DEFERRING) { | 400 } else if (!value && defers_loading_ != NOT_DEFERRING) { |
| 397 if (defers_loading_ == DEFERRED_DATA) { | 401 if (defers_loading_ == DEFERRED_DATA) { |
| 398 task_runner_->PostTask(FROM_HERE, | 402 task_runner_->PostTask(FROM_HERE, |
| 399 base::Bind(&Context::HandleDataURL, this)); | 403 base::Bind(&Context::HandleDataURL, this)); |
| 400 } | 404 } |
| 401 defers_loading_ = NOT_DEFERRING; | 405 defers_loading_ = NOT_DEFERRING; |
| 402 } | 406 } |
| 403 } | 407 } |
| 404 | 408 |
| 405 void WebURLLoaderImpl::Context::DidChangePriority( | 409 void WebURLLoaderImpl::Context::DidChangePriority( |
| 406 WebURLRequest::Priority new_priority, int intra_priority_value) { | 410 WebURLRequest::Priority new_priority, int intra_priority_value) { |
| 407 resource_dispatcher_->DidChangePriority( | 411 if (request_id_ != -1) { |
| 408 request_id_, | 412 resource_dispatcher_->DidChangePriority( |
| 409 ConvertWebKitPriorityToNetPriority(new_priority), | 413 request_id_, |
| 410 intra_priority_value); | 414 ConvertWebKitPriorityToNetPriority(new_priority), |
| 415 intra_priority_value); | |
| 416 } | |
| 411 } | 417 } |
| 412 | 418 |
| 413 bool WebURLLoaderImpl::Context::AttachThreadedDataReceiver( | 419 bool WebURLLoaderImpl::Context::AttachThreadedDataReceiver( |
| 414 blink::WebThreadedDataReceiver* threaded_data_receiver) { | 420 blink::WebThreadedDataReceiver* threaded_data_receiver) { |
| 415 resource_dispatcher_->AttachThreadedDataReceiver( | 421 if (request_id_ != -1) { |
| 416 request_id_, threaded_data_receiver); | 422 resource_dispatcher_->AttachThreadedDataReceiver( |
| 423 request_id_, threaded_data_receiver); | |
| 424 } | |
| 417 | 425 |
| 418 return false; | 426 return false; |
| 419 } | 427 } |
| 420 | 428 |
| 421 void WebURLLoaderImpl::Context::Start(const WebURLRequest& request, | 429 void WebURLLoaderImpl::Context::Start(const WebURLRequest& request, |
| 422 SyncLoadResponse* sync_load_response) { | 430 SyncLoadResponse* sync_load_response) { |
| 431 DCHECK(request_id_ == -1); | |
| 423 request_ = request; // Save the request. | 432 request_ = request; // Save the request. |
| 424 if (request.extraData()) { | 433 if (request.extraData()) { |
| 425 RequestExtraData* extra_data = | 434 RequestExtraData* extra_data = |
| 426 static_cast<RequestExtraData*>(request.extraData()); | 435 static_cast<RequestExtraData*>(request.extraData()); |
| 427 stream_override_ = extra_data->TakeStreamOverrideOwnership(); | 436 stream_override_ = extra_data->TakeStreamOverrideOwnership(); |
| 428 } | 437 } |
| 429 | 438 |
| 430 GURL url = request.url(); | 439 GURL url = request.url(); |
| 431 | 440 |
| 432 // PlzNavigate: during navigation, the renderer should request a stream which | 441 // PlzNavigate: during navigation, the renderer should request a stream which |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1135 int intra_priority_value) { | 1144 int intra_priority_value) { |
| 1136 context_->DidChangePriority(new_priority, intra_priority_value); | 1145 context_->DidChangePriority(new_priority, intra_priority_value); |
| 1137 } | 1146 } |
| 1138 | 1147 |
| 1139 bool WebURLLoaderImpl::attachThreadedDataReceiver( | 1148 bool WebURLLoaderImpl::attachThreadedDataReceiver( |
| 1140 blink::WebThreadedDataReceiver* threaded_data_receiver) { | 1149 blink::WebThreadedDataReceiver* threaded_data_receiver) { |
| 1141 return context_->AttachThreadedDataReceiver(threaded_data_receiver); | 1150 return context_->AttachThreadedDataReceiver(threaded_data_receiver); |
| 1142 } | 1151 } |
| 1143 | 1152 |
| 1144 } // namespace content | 1153 } // namespace content |
| OLD | NEW |