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

Unified Diff: content/common/url_fetcher.cc

Issue 7066067: Support creating temporary files for sync file operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/common/url_fetcher.cc
diff --git a/content/common/url_fetcher.cc b/content/common/url_fetcher.cc
index 9706a9d318d75a4899adac2bc52aff7a0494c070..e200f56c2ea20fd6ec93fbadfa301c02edd9d2b3 100644
--- a/content/common/url_fetcher.cc
+++ b/content/common/url_fetcher.cc
@@ -109,10 +109,6 @@ class URLFetcher::Core
void DidCreateTempFile(base::PlatformFileError error_code,
base::PassPlatformFile file_handle,
FilePath file_path);
- void DidCloseTempFile(base::PlatformFileError error_code);
- void DidReopenTempFile(base::PlatformFileError error_code,
- base::PassPlatformFile file_handle,
- bool created);
// Record |num_bytes_| response bytes in |core_->buffer_| to the file.
void WriteBuffer(int num_bytes);
@@ -317,6 +313,7 @@ void URLFetcher::Core::TempFileWriter::CreateTempFile() {
CHECK(file_message_loop_proxy_.get());
base::FileUtilProxy::CreateTemporary(
file_message_loop_proxy_,
+ false /* open file for synchronous file operations */,
Sam Kerner (Chrome) 2011/06/03 01:08:37 Prefer // to /* */
callback_factory_.NewCallback(
&URLFetcher::Core::TempFileWriter::DidCreateTempFile));
}
@@ -330,52 +327,7 @@ void URLFetcher::Core::TempFileWriter::DidCreateTempFile(
core_->InformDelegateFetchIsComplete();
return;
}
-
temp_file_ = file_path;
-
- // The file was opened with async writes enabled. FileUtilProxy::Write()
- // treats a write that returns IO_PENDING as an error, and does not inform
- // the caller. We need to close and reopen the file with asyncronus writes
- // disabled.
- // TODO(skerner): Make FileUtilProxy::Write() play nice with async IO.
- base::FileUtilProxy::Close(
- file_message_loop_proxy_,
- file_handle.ReleaseValue(),
- callback_factory_.NewCallback(
- &URLFetcher::Core::TempFileWriter::DidCloseTempFile));
-}
-
-void URLFetcher::Core::TempFileWriter::DidCloseTempFile(
- base::PlatformFileError error_code) {
- if (base::PLATFORM_FILE_OK != error_code) {
- error_code_ = error_code;
- core_->InformDelegateFetchIsComplete();
- return;
- }
-
- int file_flags =
- base::PLATFORM_FILE_CREATE_ALWAYS |
- base::PLATFORM_FILE_WRITE |
- base::PLATFORM_FILE_TEMPORARY;
-
- base::FileUtilProxy::CreateOrOpen(
- file_message_loop_proxy_,
- temp_file_,
- file_flags,
- callback_factory_.NewCallback(
- &URLFetcher::Core::TempFileWriter::DidReopenTempFile));
-}
-
-void URLFetcher::Core::TempFileWriter::DidReopenTempFile(
- base::PlatformFileError error_code,
- base::PassPlatformFile file_handle,
- bool created) {
- if (base::PLATFORM_FILE_OK != error_code) {
- error_code_ = error_code;
- core_->InformDelegateFetchIsComplete();
- return;
- }
-
temp_file_handle_ = file_handle.ReleaseValue();
total_bytes_written_ = 0;
« base/file_util_proxy.h ('K') | « content/browser/renderer_host/redirect_to_file_resource_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698