| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_ |
| 6 #define CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_ | 6 #define CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 namespace IPC { | 25 namespace IPC { |
| 26 class Sender; | 26 class Sender; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace storage { | 29 namespace storage { |
| 30 class DataElement; | 30 class DataElement; |
| 31 class BlobDataBuilder; | 31 class BlobDataBuilder; |
| 32 struct BlobItemBytesRequest; | 32 struct BlobItemBytesRequest; |
| 33 struct BlobItemBytesResponse; | 33 struct BlobItemBytesResponse; |
| 34 class BlobStorageContext; | 34 class BlobStorageContext; |
| 35 class FileSystemContext; |
| 35 } | 36 } |
| 36 | 37 |
| 37 namespace content { | 38 namespace content { |
| 38 class ChromeBlobStorageContext; | 39 class ChromeBlobStorageContext; |
| 39 | 40 |
| 40 // This class's responsibility is to listen for and dispatch blob storage | 41 // This class's responsibility is to listen for and dispatch blob storage |
| 41 // messages and handle logistics of blob storage for a single child process. | 42 // messages and handle logistics of blob storage for a single child process. |
| 42 // When the child process terminates all blob references attributable to | 43 // When the child process terminates all blob references attributable to |
| 43 // that process go away upon destruction of the instance. | 44 // that process go away upon destruction of the instance. |
| 44 // This lives in the browser process, is single threaded (IO thread), and there | 45 // This lives in the browser process, is single threaded (IO thread), and there |
| 45 // is one per child process. | 46 // is one per child process. |
| 46 class CONTENT_EXPORT BlobDispatcherHost : public BrowserMessageFilter { | 47 class CONTENT_EXPORT BlobDispatcherHost : public BrowserMessageFilter { |
| 47 public: | 48 public: |
| 48 explicit BlobDispatcherHost(ChromeBlobStorageContext* blob_storage_context); | 49 BlobDispatcherHost( |
| 50 int process_id, |
| 51 scoped_refptr<ChromeBlobStorageContext> blob_storage_context, |
| 52 scoped_refptr<storage::FileSystemContext> file_system_context); |
| 49 | 53 |
| 50 // BrowserMessageFilter implementation. | 54 // BrowserMessageFilter implementation. |
| 51 void OnChannelClosing() override; | 55 void OnChannelClosing() override; |
| 52 bool OnMessageReceived(const IPC::Message& message) override; | 56 bool OnMessageReceived(const IPC::Message& message) override; |
| 53 | 57 |
| 54 protected: | 58 protected: |
| 55 ~BlobDispatcherHost() override; | 59 ~BlobDispatcherHost() override; |
| 56 | 60 |
| 57 // For testing use only. | 61 // For testing use only. |
| 58 void SetMemoryConstantsForTesting(size_t max_ipc_memory_size, | 62 void SetMemoryConstantsForTesting(size_t max_ipc_memory_size, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // Send the appropriate IPC response to the renderer for the given result. | 129 // Send the appropriate IPC response to the renderer for the given result. |
| 126 void SendIPCResponse(const std::string& uuid, | 130 void SendIPCResponse(const std::string& uuid, |
| 127 storage::BlobTransportResult result); | 131 storage::BlobTransportResult result); |
| 128 | 132 |
| 129 bool IsInUseInHost(const std::string& uuid); | 133 bool IsInUseInHost(const std::string& uuid); |
| 130 bool IsUrlRegisteredInHost(const GURL& blob_url); | 134 bool IsUrlRegisteredInHost(const GURL& blob_url); |
| 131 | 135 |
| 132 // Unregisters all blobs and urls that were registered in this host. | 136 // Unregisters all blobs and urls that were registered in this host. |
| 133 void ClearHostFromBlobStorageContext(); | 137 void ClearHostFromBlobStorageContext(); |
| 134 | 138 |
| 139 const int process_id_; |
| 140 scoped_refptr<storage::FileSystemContext> file_system_context_; |
| 141 |
| 135 // Collection of blob ids and a count of how many usages | 142 // Collection of blob ids and a count of how many usages |
| 136 // of that id are attributable to this consumer. | 143 // of that id are attributable to this consumer. |
| 137 BlobReferenceMap blobs_inuse_map_; | 144 BlobReferenceMap blobs_inuse_map_; |
| 138 | 145 |
| 139 // The set of public blob urls coined by this consumer. | 146 // The set of public blob urls coined by this consumer. |
| 140 std::set<GURL> public_blob_urls_; | 147 std::set<GURL> public_blob_urls_; |
| 141 | 148 |
| 142 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; | 149 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; |
| 143 storage::BlobAsyncBuilderHost async_builder_; | 150 storage::BlobAsyncBuilderHost async_builder_; |
| 144 | 151 |
| 145 DISALLOW_COPY_AND_ASSIGN(BlobDispatcherHost); | 152 DISALLOW_COPY_AND_ASSIGN(BlobDispatcherHost); |
| 146 }; | 153 }; |
| 147 } // namespace content | 154 } // namespace content |
| 148 #endif // CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_ | 155 #endif // CONTENT_BROWSER_BLOB_STORAGE_BLOB_DISPATCHER_HOST_H_ |
| OLD | NEW |