Revert 256688 "Fix various issues in RedirectToFileResourceHandler."

The linux asan bot went red

ResourceDispatcherHostTest.DownloadToFile (run #1):
[ RUN      ] ResourceDispatcherHostTest.DownloadToFile
[       OK ] ResourceDispatcherHostTest.DownloadToFile (212 ms)
[----------] 1 test from ResourceDispatcherHostTest (212 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (213 ms total)
[  PASSED  ] 1 test.

  YOU HAVE 5 DISABLED TESTS


=================================================================
==9125==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x49be81 in operator new(unsigned long) /usr/local/google/work/chromium/src/third_party/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:54
    #1 0x23ce695 in content::ResourceDispatcherHostImpl::BeginRequest(int, ResourceHostMsg_Request const&, IPC::Message*, int) content/browser/loader/resource_dispatcher_host_impl.cc:1045
    #2 0x23cba80 in OnRequestResource content/browser/loader/resource_dispatcher_host_impl.cc:879
    #3 0x23cba80 in Dispatch\u003Ccontent::ResourceDispatcherHostImpl, content::ResourceDispatcherHostImpl, int, const ResourceHostMsg_Request &> content/common/resource_messages.h:305
    #4 0x23cba80 in content::ResourceDispatcherHostImpl::OnMessageReceived(IPC::Message const&, content::ResourceMessageFilter*, bool*) content/browser/loader/resource_dispatcher_host_impl.cc:841
    #5 0xe04954 in content::ResourceDispatcherHostTest_DownloadToFile_Test::TestBody() content/browser/loader/resource_dispatcher_host_unittest.cc:2840
    #6 0x2c10c9a in HandleExceptionsInMethodIfSupported\u003Ctesting::Test, void> testing/gtest/src/gtest.cc:2045
    #7 0x2c10c9a in testing::Test::Run() testing/gtest/src/gtest.cc:2061
    #8 0x2c12dea in testing::TestInfo::Run() testing/gtest/src/gtest.cc:2237
    #9 0x2c13bb3 in testing::TestCase::Run() testing/gtest/src/gtest.cc:2344
    #10 0x2c24c6a in testing::internal::UnitTestImpl::RunAllTests() testing/gtest/src/gtest.cc:4065
    #11 0x2c24250 in HandleExceptionsInMethodIfSupported\u003Ctesting::internal::UnitTestImpl, bool> testing/gtest/src/gtest.cc:2045
    #12 0x2c24250 in testing::UnitTest::Run() testing/gtest/src/gtest.cc:3697
    #13 0x2b9ed2c in RUN_ALL_TESTS testing/gtest/include/gtest/gtest.h:2231
    #14 0x2b9ed2c in base::TestSuite::Run() base/test/test_suite.cc:213
    #15 0x2b92bcb in Run base/callback.h:401
    #16 0x2b92bcb in base::(anonymous namespace)::LaunchUnitTestsInternal(int, char**, base::Callback\u003Cint ()> const&, int) base/test/launcher/unit_test_launcher.cc:494
    #17 0x199a83e in main content/test/run_all_unittests.cc:14
    #18 0x7f6e898bf76c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226

SUMMARY: AddressSanitizer: 16 byte(s) leaked in 1 allocation(s).


http://build.chromium.org/p/chromium.memory/builders/Linux%20ASan%2BLSan%20Tests%20%282%29/builds/409



> Fix various issues in RedirectToFileResourceHandler.
> 
> - Handle errors in creating temporary files.
> - Cancel on write failure instead of resuming. This used to work, but got
>   lost in some refactoring in r142108.
> - Fix the OnResponseCompleted resume logic to account for partial writes.
> - Don't lose write errors which occur after OnResponseCompleted is received.
> - WeakPtrFactory goes after other members.
> - OnWillStart was never forwarded to downstream handlers.
> - Make sure the file is closed before deleting it.
> 
> Also add a lot of machinery so we can better unit test this stack.
> 
> BUG=316634,347663
> TEST=ResourceDispatcherHostTest.DownloadToFile
>      ResourceDispatcherHostTest.RegisterDownloadedTempFile
>      ResourceLoaderTest.RedirectToFile*
>      TemporaryFileStreamTest.Basic
> 
> Review URL: https://codereview.chromium.org/82273002

TBR=davidben@chromium.org

Review URL: https://codereview.chromium.org/196533013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256704 0039d316-1c4b-4281-b951-d872f2087c98
SVN changes up to revision 256704