summaryrefslogtreecommitdiffstats
path: root/content/browser/loader/temporary_file_stream.h
diff options
context:
space:
mode:
authordavidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-14 17:56:48 +0000
committerdavidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-14 17:56:48 +0000
commit52c41b478ddaa2353c1a9fdb834557c51209dbf3 (patch)
treea9d55ff3e6b5641d18f128e0602cea1736def212 /content/browser/loader/temporary_file_stream.h
parent296556cfa9dcef7ad152bad87caf23ae795a1d39 (diff)
downloadchromium_src-52c41b478ddaa2353c1a9fdb834557c51209dbf3.zip
chromium_src-52c41b478ddaa2353c1a9fdb834557c51209dbf3.tar.gz
chromium_src-52c41b478ddaa2353c1a9fdb834557c51209dbf3.tar.bz2
Reland "Fix various issues in RedirectToFileResourceHandler."
It got reverted due to ASan issues. Fix child_id registration in ResourceDispatcherHostTests so that they happen on ForwardingFilter creation, rather than ad-hoc on a per-request basis. Original description: > - 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. Original Review URL: https://codereview.chromium.org/82273002 BUG=316634,347663 TEST=ResourceDispatcherHostTest.DownloadToFile ResourceDispatcherHostTest.RegisterDownloadedTempFile ResourceLoaderRedirectToFileTest.* TemporaryFileStreamTest.Basic Review URL: https://codereview.chromium.org/199453002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257147 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/loader/temporary_file_stream.h')
-rw-r--r--content/browser/loader/temporary_file_stream.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/content/browser/loader/temporary_file_stream.h b/content/browser/loader/temporary_file_stream.h
new file mode 100644
index 0000000..51d524d
--- /dev/null
+++ b/content/browser/loader/temporary_file_stream.h
@@ -0,0 +1,46 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_LOADER_TEMPORARY_FILE_STREAM_H_
+#define CONTENT_BROWSER_LOADER_TEMPORARY_FILE_STREAM_H_
+
+#include "base/callback_forward.h"
+#include "base/files/file.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/platform_file.h"
+#include "content/common/content_export.h"
+
+namespace net {
+class FileStream;
+}
+
+namespace webkit_blob {
+class ShareableFileReference;
+}
+
+namespace content {
+
+typedef base::Callback<void(base::File::Error,
+ scoped_ptr<net::FileStream>,
+ webkit_blob::ShareableFileReference*)>
+ CreateTemporaryFileStreamCallback;
+
+// Creates a temporary file and asynchronously calls |callback| with a
+// net::FileStream and webkit_blob::ShareableFileReference. The file is deleted
+// when the webkit_blob::ShareableFileReference is deleted. Note it is the
+// consumer's responsibility to ensure the webkit_blob::ShareableFileReference
+// stays in scope until net::FileStream has finished closing the file. On error,
+// |callback| is called with an error in the first parameter.
+//
+// This function may only be called on the IO thread.
+//
+// TODO(davidben): Juggling the net::FileStream and
+// webkit_blob::ShareableFileReference lifetimes is a nuisance. The two should
+// be tied together so the consumer need not deal with it.
+CONTENT_EXPORT void CreateTemporaryFileStream(
+ const CreateTemporaryFileStreamCallback& callback);
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_LOADER_TEMPORARY_FILE_STREAM_H_