summaryrefslogtreecommitdiff
path: root/Source/WebCore/fileapi/AsyncFileStream.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/fileapi/AsyncFileStream.h')
-rw-r--r--Source/WebCore/fileapi/AsyncFileStream.h50
1 files changed, 11 insertions, 39 deletions
diff --git a/Source/WebCore/fileapi/AsyncFileStream.h b/Source/WebCore/fileapi/AsyncFileStream.h
index 849ea2bc9..2098ee3f4 100644
--- a/Source/WebCore/fileapi/AsyncFileStream.h
+++ b/Source/WebCore/fileapi/AsyncFileStream.h
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- * Copyright (C) 2010, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2010, 2012, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -29,14 +29,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef AsyncFileStream_h
-#define AsyncFileStream_h
-
-#if ENABLE(BLOB)
+#pragma once
+#include <functional>
#include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
+#include <wtf/Function.h>
namespace WebCore {
@@ -44,47 +41,22 @@ class FileStreamClient;
class FileStream;
class URL;
-class AsyncFileStream : public RefCounted<AsyncFileStream> {
+class WEBCORE_EXPORT AsyncFileStream {
public:
- static PassRefPtr<AsyncFileStream> create(FileStreamClient*);
+ explicit AsyncFileStream(FileStreamClient&);
~AsyncFileStream();
void getSize(const String& path, double expectedModificationTime);
void openForRead(const String& path, long long offset, long long length);
- void openForWrite(const String& path);
void close();
void read(char* buffer, int length);
- void write(const URL& blobURL, long long position, int length);
- void truncate(long long position);
-
- // Stops the proxy and schedules it to be destructed. All the pending tasks will be aborted and the file stream will be closed.
- // Note: the caller should deref the instance immediately after calling stop().
- void stop();
-
- FileStreamClient* client() const { return m_client; }
- void setClient(FileStreamClient* client) { m_client = client; }
private:
- AsyncFileStream(FileStreamClient*);
-
- // Called on File thread.
- void startOnFileThread();
- void stopOnFileThread();
- void getSizeOnFileThread(const String& path, double expectedModificationTime);
- void openForReadOnFileThread(const String& path, long long offset, long long length);
- void openForWriteOnFileThread(const String& path);
- void closeOnFileThread();
- void readOnFileThread(char* buffer, int length);
- void writeOnFileThread(const URL& blobURL, long long position, int length);
- void truncateOnFileThread(long long position);
+ void start();
+ void perform(Function<std::function<void(FileStreamClient&)>(FileStream&)>&&);
- RefPtr<FileStream> m_stream;
-
- FileStreamClient* m_client;
+ struct Internals;
+ std::unique_ptr<Internals> m_internals;
};
} // namespace WebCore
-
-#endif // ENABLE(BLOB)
-
-#endif // AsyncFileStream_h