Chromium Code Reviews| Index: content/browser/fileapi/fileapi_message_filter.h |
| diff --git a/content/browser/fileapi/fileapi_message_filter.h b/content/browser/fileapi/fileapi_message_filter.h |
| index 9d7f8bb86c3549ece0467ae537e0bf6326e5acd8..bd39f78cde9e9ddde91c12760fcfc8cf2a89d6a3 100644 |
| --- a/content/browser/fileapi/fileapi_message_filter.h |
| +++ b/content/browser/fileapi/fileapi_message_filter.h |
| @@ -13,8 +13,11 @@ |
| #include "base/containers/hash_tables.h" |
| #include "base/files/file_util_proxy.h" |
| #include "base/id_map.h" |
| +#include "base/memory/ref_counted.h" |
| #include "base/memory/shared_memory.h" |
| #include "base/platform_file.h" |
| +#include "content/browser/streams/stream.h" |
| +#include "content/browser/streams/stream_context.h" |
| #include "content/common/content_export.h" |
| #include "content/public/browser/browser_message_filter.h" |
| #include "webkit/browser/fileapi/file_system_operation_runner.h" |
| @@ -47,6 +50,10 @@ class ShareableFileReference; |
| namespace content { |
| class ChromeBlobStorageContext; |
| +// TODO(tyoshino): Make FileAPIMessageFilter thinner by factoring out most of |
| +// code into separate classes and leaving only minimum IPC gluing code here. |
| +// We can now split code for BlobHostMsg_ family IPCs and one for |
| +// FileSystemHostMsg_ family IPCs into separate classes. |
|
kinuko
2013/07/23 13:57:23
nit: would be nicer to file a bug and put a shorte
tyoshino (SeeGerritForStatus)
2013/07/24 12:14:20
Done.
|
| class CONTENT_EXPORT FileAPIMessageFilter : public BrowserMessageFilter { |
| public: |
| // Used by the renderer process host on the UI thread. |
| @@ -54,13 +61,15 @@ class CONTENT_EXPORT FileAPIMessageFilter : public BrowserMessageFilter { |
| int process_id, |
| net::URLRequestContextGetter* request_context_getter, |
| fileapi::FileSystemContext* file_system_context, |
| - ChromeBlobStorageContext* blob_storage_context); |
| + ChromeBlobStorageContext* blob_storage_context, |
| + StreamContext* stream_context); |
| // Used by the worker process host on the IO thread. |
| FileAPIMessageFilter( |
| int process_id, |
| net::URLRequestContext* request_context, |
| fileapi::FileSystemContext* file_system_context, |
| - ChromeBlobStorageContext* blob_storage_context); |
| + ChromeBlobStorageContext* blob_storage_context, |
| + StreamContext* stream_context); |
| // BrowserMessageFilter implementation. |
| virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
| @@ -121,14 +130,24 @@ class CONTENT_EXPORT FileAPIMessageFilter : public BrowserMessageFilter { |
| const GURL& path); |
| void OnDidReceiveSnapshotFile(int request_id); |
| + // Handlers for BlobHostMsg_ family messages. |
| + // |
| + // Methods with "BlobOrStream" in their names are used for both Blobs and |
| + // Streams. If there's a Stream in |stream_context_| for |url|, it's handled |
| + // as an IPC for Stream. Otherwise, it's handled as one for Blob. |
| + // |
| + // TODO(tyoshino): Consider renaming BlobData to more generic one as it's now |
| + // used for Stream. |
| void OnStartBuildingBlob(const GURL& url); |
| - void OnAppendBlobDataItem(const GURL& url, |
| - const webkit_blob::BlobData::Item& item); |
| - void OnAppendSharedMemory(const GURL& url, base::SharedMemoryHandle handle, |
| - size_t buffer_size); |
| + void OnStartBuildingStream(const GURL& url, const std::string& content_type); |
| + void OnAppendBlobDataItemToBlobOrStream( |
| + const GURL& url, const webkit_blob::BlobData::Item& item); |
| + void OnAppendSharedMemoryToBlobOrStream( |
| + const GURL& url, base::SharedMemoryHandle handle, size_t buffer_size); |
| void OnFinishBuildingBlob(const GURL& url, const std::string& content_type); |
| - void OnCloneBlob(const GURL& url, const GURL& src_url); |
| - void OnRemoveBlob(const GURL& url); |
| + void OnFinishBuildingStream(const GURL& url); |
| + void OnCloneBlobOrStream(const GURL& url, const GURL& src_url); |
| + void OnRemoveBlobOrStream(const GURL& url); |
| // Callback functions to be used when each file operation is finished. |
| void DidFinish(int request_id, base::PlatformFileError result); |
| @@ -169,6 +188,9 @@ class CONTENT_EXPORT FileAPIMessageFilter : public BrowserMessageFilter { |
| int permissions, |
| base::PlatformFileError* error); |
| + // Retrieves the Stream object for |url| from |stream_context_|. |
| + scoped_refptr<Stream> GetStreamForURL(const GURL& url); |
| + |
| fileapi::FileSystemOperationRunner* operation_runner(); |
| int process_id_; |
| @@ -186,9 +208,11 @@ class CONTENT_EXPORT FileAPIMessageFilter : public BrowserMessageFilter { |
| net::URLRequestContext* request_context_; |
| scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; |
| + scoped_refptr<StreamContext> stream_context_; |
| // Keep track of blob URLs registered in this process. Need to unregister |
| - // all of them when the renderer process dies. |
| + // all of them when the renderer process dies. Used for both Blobs and |
| + // Streams. |
| base::hash_set<std::string> blob_urls_; |
| // Used to keep snapshot files alive while a DidCreateSnapshot |