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

Side by Side Diff: content/browser/loader/mojo_async_resource_handler.cc

Issue 2484933002: MojoAsyncResourceHandler: Ignore Resume/OnWritable calls after error. (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | content/browser/loader/mojo_async_resource_handler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/browser/loader/mojo_async_resource_handler.h" 5 #include "content/browser/loader/mojo_async_resource_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 340 }
341 if (result != MOJO_RESULT_OK) 341 if (result != MOJO_RESULT_OK)
342 return false; 342 return false;
343 *buf = new WriterIOBuffer(shared_writer_, data, available); 343 *buf = new WriterIOBuffer(shared_writer_, data, available);
344 return true; 344 return true;
345 } 345 }
346 346
347 void MojoAsyncResourceHandler::Resume() { 347 void MojoAsyncResourceHandler::Resume() {
348 if (!did_defer_) 348 if (!did_defer_)
349 return; 349 return;
350 bool defer = false; 350 did_defer_ = false;
351
351 if (is_using_io_buffer_not_from_writer_) { 352 if (is_using_io_buffer_not_from_writer_) {
352 // |buffer_| is set to a net::IOBufferWithSize. Write the buffer contents 353 // |buffer_| is set to a net::IOBufferWithSize. Write the buffer contents
353 // to the data pipe. 354 // to the data pipe.
354 DCHECK_GT(buffer_bytes_read_, 0u); 355 DCHECK_GT(buffer_bytes_read_, 0u);
355 if (!CopyReadDataToDataPipe(&defer)) { 356 if (!CopyReadDataToDataPipe(&did_defer_)) {
356 controller()->CancelWithError(net::ERR_FAILED); 357 controller()->CancelWithError(net::ERR_FAILED);
357 return; 358 return;
358 } 359 }
359 } else { 360 } else {
360 // Allocate a buffer for the next OnWillRead call here. 361 // Allocate a buffer for the next OnWillRead call here.
361 if (!AllocateWriterIOBuffer(&buffer_, &defer)) { 362 if (!AllocateWriterIOBuffer(&buffer_, &did_defer_)) {
362 controller()->CancelWithError(net::ERR_FAILED); 363 controller()->CancelWithError(net::ERR_FAILED);
363 return; 364 return;
364 } 365 }
365 } 366 }
366 367
367 if (defer) { 368 if (did_defer_) {
368 // Continue waiting. 369 // Continue waiting.
369 return; 370 return;
370 } 371 }
371 did_defer_ = false;
372 request()->LogUnblocked(); 372 request()->LogUnblocked();
373 controller()->Resume(); 373 controller()->Resume();
374 } 374 }
375 375
376 void MojoAsyncResourceHandler::OnDefer() { 376 void MojoAsyncResourceHandler::OnDefer() {
377 request()->LogBlockedBy("MojoAsyncResourceHandler"); 377 request()->LogBlockedBy("MojoAsyncResourceHandler");
378 did_defer_ = true; 378 did_defer_ = true;
379 } 379 }
380 380
381 bool MojoAsyncResourceHandler::CheckForSufficientResource() { 381 bool MojoAsyncResourceHandler::CheckForSufficientResource() {
382 if (has_checked_for_sufficient_resources_) 382 if (has_checked_for_sufficient_resources_)
383 return true; 383 return true;
384 has_checked_for_sufficient_resources_ = true; 384 has_checked_for_sufficient_resources_ = true;
385 385
386 if (rdh_->HasSufficientResourcesForRequest(request())) 386 if (rdh_->HasSufficientResourcesForRequest(request()))
387 return true; 387 return true;
388 388
389 controller()->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); 389 controller()->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES);
390 return false; 390 return false;
391 } 391 }
392 392
393 void MojoAsyncResourceHandler::OnWritable(MojoResult unused) { 393 void MojoAsyncResourceHandler::OnWritable(MojoResult unused) {
394 Resume(); 394 Resume();
395 } 395 }
396 396
397 } // namespace content 397 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/loader/mojo_async_resource_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698