OLD | NEW |
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 class TempFileWriter { | 107 class TempFileWriter { |
108 public: | 108 public: |
109 TempFileWriter( | 109 TempFileWriter( |
110 URLFetcherImpl::Core* core, | 110 URLFetcherImpl::Core* core, |
111 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy); | 111 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy); |
112 | 112 |
113 ~TempFileWriter(); | 113 ~TempFileWriter(); |
114 void CreateTempFile(); | 114 void CreateTempFile(); |
115 void DidCreateTempFile(base::PlatformFileError error_code, | 115 void DidCreateTempFile(base::PlatformFileError error_code, |
116 base::PassPlatformFile file_handle, | 116 base::PassPlatformFile file_handle, |
117 FilePath file_path); | 117 const FilePath& file_path); |
118 | 118 |
119 // Record |num_bytes_| response bytes in |core_->buffer_| to the file. | 119 // Record |num_bytes_| response bytes in |core_->buffer_| to the file. |
120 void WriteBuffer(int num_bytes); | 120 void WriteBuffer(int num_bytes); |
121 | 121 |
122 // Called when a write has been done. Continues writing if there are | 122 // Called when a write has been done. Continues writing if there are |
123 // any more bytes to write. Otherwise, initiates a read in core_. | 123 // any more bytes to write. Otherwise, initiates a read in core_. |
124 void ContinueWrite(base::PlatformFileError error_code, | 124 void ContinueWrite(base::PlatformFileError error_code, |
125 int bytes_written); | 125 int bytes_written); |
126 | 126 |
127 // Drop ownership of the file at path |temp_file_|. This class | 127 // Drop ownership of the file at path |temp_file_|. This class |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 base::FileUtilProxy::CreateTemporary( | 338 base::FileUtilProxy::CreateTemporary( |
339 file_message_loop_proxy_, | 339 file_message_loop_proxy_, |
340 0, // No additional file flags. | 340 0, // No additional file flags. |
341 base::Bind(&URLFetcherImpl::Core::TempFileWriter::DidCreateTempFile, | 341 base::Bind(&URLFetcherImpl::Core::TempFileWriter::DidCreateTempFile, |
342 weak_factory_.GetWeakPtr())); | 342 weak_factory_.GetWeakPtr())); |
343 } | 343 } |
344 | 344 |
345 void URLFetcherImpl::Core::TempFileWriter::DidCreateTempFile( | 345 void URLFetcherImpl::Core::TempFileWriter::DidCreateTempFile( |
346 base::PlatformFileError error_code, | 346 base::PlatformFileError error_code, |
347 base::PassPlatformFile file_handle, | 347 base::PassPlatformFile file_handle, |
348 FilePath file_path) { | 348 const FilePath& file_path) { |
349 DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); | 349 DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); |
350 | 350 |
351 if (base::PLATFORM_FILE_OK != error_code) { | 351 if (base::PLATFORM_FILE_OK != error_code) { |
352 error_code_ = error_code; | 352 error_code_ = error_code; |
353 RemoveTempFile(); | 353 RemoveTempFile(); |
354 core_->delegate_loop_proxy_->PostTask( | 354 core_->delegate_loop_proxy_->PostTask( |
355 FROM_HERE, base::Bind(&Core::InformDelegateFetchIsComplete, core_)); | 355 FROM_HERE, base::Bind(&Core::InformDelegateFetchIsComplete, core_)); |
356 return; | 356 return; |
357 } | 357 } |
358 | 358 |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 | 1125 |
1126 // static | 1126 // static |
1127 content::URLFetcherFactory* URLFetcherImpl::factory() { | 1127 content::URLFetcherFactory* URLFetcherImpl::factory() { |
1128 return g_factory; | 1128 return g_factory; |
1129 } | 1129 } |
1130 | 1130 |
1131 // static | 1131 // static |
1132 void URLFetcherImpl::set_factory(content::URLFetcherFactory* factory) { | 1132 void URLFetcherImpl::set_factory(content::URLFetcherFactory* factory) { |
1133 g_factory = factory; | 1133 g_factory = factory; |
1134 } | 1134 } |
OLD | NEW |