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

Side by Side Diff: content/common/net/url_fetcher_impl.cc

Issue 8523003: URLFetcher should not act on writes to closed temp files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/common/net/url_fetcher_impl.h" 5 #include "content/common/net/url_fetcher_impl.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 pending_bytes_ = num_bytes; 373 pending_bytes_ = num_bytes;
374 buffer_offset_ = 0; 374 buffer_offset_ = 0;
375 ContinueWrite(base::PLATFORM_FILE_OK, 0); 375 ContinueWrite(base::PLATFORM_FILE_OK, 0);
376 } 376 }
377 377
378 void URLFetcherImpl::Core::TempFileWriter::ContinueWrite( 378 void URLFetcherImpl::Core::TempFileWriter::ContinueWrite(
379 base::PlatformFileError error_code, 379 base::PlatformFileError error_code,
380 int bytes_written) { 380 int bytes_written) {
381 DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); 381 DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread());
382 382
383 if (temp_file_handle_ == base::kInvalidPlatformFileValue) {
384 // While a write was being done on the file thread, a request
385 // to close or disown the file occured on the IO thread. At
386 // this point a request to close the file is pending on the
387 // file thread.
388 return;
389 }
390
391 // Every code path that resets |core_->request_| should reset
392 // |core->temp_file_writer_| or cause the temp file writer to
393 // disown the temp file. In the former case, this callback can
394 // not be called, because the weak pointer to |this| will be NULL.
395 // In the latter case, the check of |temp_file_handle_| at the start
396 // of this method ensures that we can not reach this point.
397 CHECK(core_->request_.get());
398
383 if (base::PLATFORM_FILE_OK != error_code) { 399 if (base::PLATFORM_FILE_OK != error_code) {
384 error_code_ = error_code; 400 error_code_ = error_code;
385 RemoveTempFile(); 401 RemoveTempFile();
386 core_->delegate_loop_proxy_->PostTask( 402 core_->delegate_loop_proxy_->PostTask(
387 FROM_HERE, base::Bind(&Core::InformDelegateFetchIsComplete, core_)); 403 FROM_HERE, base::Bind(&Core::InformDelegateFetchIsComplete, core_));
388 return; 404 return;
389 } 405 }
390 406
391 total_bytes_written_ += bytes_written; 407 total_bytes_written_ += bytes_written;
392 buffer_offset_ += bytes_written; 408 buffer_offset_ += bytes_written;
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 1121
1106 // static 1122 // static
1107 content::URLFetcherFactory* URLFetcherImpl::factory() { 1123 content::URLFetcherFactory* URLFetcherImpl::factory() {
1108 return g_factory; 1124 return g_factory;
1109 } 1125 }
1110 1126
1111 // static 1127 // static
1112 void URLFetcherImpl::set_factory(content::URLFetcherFactory* factory) { 1128 void URLFetcherImpl::set_factory(content::URLFetcherFactory* factory) {
1113 g_factory = factory; 1129 g_factory = factory;
1114 } 1130 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698