OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_CHILD_BLOB_STORAGE_BLOB_TRANSPORT_CONTROLLER_H_ | 5 #ifndef CONTENT_CHILD_BLOB_STORAGE_BLOB_TRANSPORT_CONTROLLER_H_ |
6 #define CONTENT_CHILD_BLOB_STORAGE_BLOB_TRANSPORT_CONTROLLER_H_ | 6 #define CONTENT_CHILD_BLOB_STORAGE_BLOB_TRANSPORT_CONTROLLER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/callback_forward.h" | 16 #include "base/callback_forward.h" |
17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "base/memory/shared_memory_handle.h" | 20 #include "base/memory/shared_memory_handle.h" |
21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "content/common/blob.mojom.h" |
22 #include "content/common/content_export.h" | 23 #include "content/common/content_export.h" |
23 #include "ipc/ipc_platform_file.h" | 24 #include "ipc/ipc_platform_file.h" |
24 #include "storage/common/blob_storage/blob_storage_constants.h" | 25 #include "storage/common/blob_storage/blob_storage_constants.h" |
25 | 26 |
26 namespace base { | 27 namespace base { |
27 template <typename T> | 28 template <typename T> |
28 struct DefaultLazyInstanceTraits; | 29 struct DefaultLazyInstanceTraits; |
29 class SingleThreadTaskRunner; | 30 class SingleThreadTaskRunner; |
30 class TaskRunner; | 31 class TaskRunner; |
31 } | 32 } |
32 | 33 |
33 namespace storage { | 34 namespace storage { |
34 class DataElement; | 35 class DataElement; |
35 struct BlobItemBytesRequest; | 36 struct BlobItemBytesRequest; |
36 struct BlobItemBytesResponse; | 37 struct BlobItemBytesResponse; |
37 } | 38 } |
38 | 39 |
39 namespace IPC { | 40 namespace IPC { |
40 class Message; | 41 class Message; |
41 class Sender; | 42 class Sender; |
| 43 class SyncMessageFilter; |
42 } | 44 } |
43 | 45 |
44 namespace content { | 46 namespace content { |
45 | 47 |
46 class BlobConsolidation; | 48 class BlobConsolidation; |
47 class ThreadSafeSender; | 49 class ThreadSafeSender; |
48 | 50 |
49 // This class is used to manage all the asynchronous transporation of blobs from | 51 // This class is used to manage all the asynchronous transporation of blobs from |
50 // the Renderer to the Browser process, where it's handling the Renderer side. | 52 // the Renderer to the Browser process, where it's handling the Renderer side. |
51 // The function of this class is to: | 53 // The function of this class is to: |
(...skipping 29 matching lines...) Expand all Loading... |
81 // asynchronously. Use CancelAllBlobTransfers to stop usage of the |sender|. | 83 // asynchronously. Use CancelAllBlobTransfers to stop usage of the |sender|. |
82 // We close the file handles once we're done writing to them. | 84 // We close the file handles once we're done writing to them. |
83 void OnMemoryRequest( | 85 void OnMemoryRequest( |
84 const std::string& uuid, | 86 const std::string& uuid, |
85 const std::vector<storage::BlobItemBytesRequest>& requests, | 87 const std::vector<storage::BlobItemBytesRequest>& requests, |
86 std::vector<base::SharedMemoryHandle>* memory_handles, | 88 std::vector<base::SharedMemoryHandle>* memory_handles, |
87 const std::vector<IPC::PlatformFileForTransit>& file_handles, | 89 const std::vector<IPC::PlatformFileForTransit>& file_handles, |
88 base::TaskRunner* file_runner, | 90 base::TaskRunner* file_runner, |
89 IPC::Sender* sender); | 91 IPC::Sender* sender); |
90 | 92 |
91 void OnCancel(const std::string& uuid, | 93 void OnBuildBlobComplete(const std::string& uuid, |
92 storage::IPCBlobCreationCancelCode code); | 94 mojom::BlobAssociatedPtr blob, |
93 | 95 mojom::BlobCreationCancelCode cancel_code); |
94 void OnDone(const std::string& uuid); | |
95 | 96 |
96 bool IsTransporting(const std::string& uuid) { | 97 bool IsTransporting(const std::string& uuid) { |
97 return blob_storage_.find(uuid) != blob_storage_.end(); | 98 return blob_storage_.find(uuid) != blob_storage_.end(); |
98 } | 99 } |
99 | 100 |
100 // Invalidates all asynchronously running memory request handlers and clears | 101 // Invalidates all asynchronously running memory request handlers and clears |
101 // the internal state. If our map wasn't previously empty, then we call | 102 // the internal state. If our map wasn't previously empty, then we call |
102 // ChildProcess::ReleaseProcess to release our previous reference. | 103 // ChildProcess::ReleaseProcess to release our previous reference. |
103 void CancelAllBlobTransfers(); | 104 void CancelAllBlobTransfers(); |
104 | 105 |
(...skipping 21 matching lines...) Expand all Loading... |
126 ~BlobTransportController(); | 127 ~BlobTransportController(); |
127 | 128 |
128 void OnFileWriteComplete( | 129 void OnFileWriteComplete( |
129 IPC::Sender* sender, | 130 IPC::Sender* sender, |
130 const std::string& uuid, | 131 const std::string& uuid, |
131 const std::pair<std::vector<storage::BlobItemBytesResponse>, | 132 const std::pair<std::vector<storage::BlobItemBytesResponse>, |
132 storage::IPCBlobCreationCancelCode>& result); | 133 storage::IPCBlobCreationCancelCode>& result); |
133 | 134 |
134 void StoreBlobDataForRequests( | 135 void StoreBlobDataForRequests( |
135 const std::string& uuid, | 136 const std::string& uuid, |
| 137 const std::string& content_type, |
136 scoped_refptr<BlobConsolidation> consolidation, | 138 scoped_refptr<BlobConsolidation> consolidation, |
| 139 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter, |
137 scoped_refptr<base::SingleThreadTaskRunner> main_runner); | 140 scoped_refptr<base::SingleThreadTaskRunner> main_runner); |
138 | 141 |
139 // Deletes the consolidation and calls ChildProcess::ReleaseProcess. | 142 // Deletes the consolidation and calls ChildProcess::ReleaseProcess. |
140 void ReleaseBlobConsolidation(const std::string& uuid); | 143 void ReleaseBlobConsolidation(const std::string& uuid); |
141 | 144 |
142 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner_; | 145 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner_; |
| 146 mojom::BlobFactoryAssociatedPtr blob_factory_; |
143 std::map<std::string, scoped_refptr<BlobConsolidation>> blob_storage_; | 147 std::map<std::string, scoped_refptr<BlobConsolidation>> blob_storage_; |
| 148 std::map<std::string, mojom::BlobAssociatedPtr> blob_proxies_; |
144 base::WeakPtrFactory<BlobTransportController> weak_factory_; | 149 base::WeakPtrFactory<BlobTransportController> weak_factory_; |
145 | 150 |
146 DISALLOW_COPY_AND_ASSIGN(BlobTransportController); | 151 DISALLOW_COPY_AND_ASSIGN(BlobTransportController); |
147 }; | 152 }; |
148 | 153 |
149 } // namespace content | 154 } // namespace content |
150 #endif // CONTENT_CHILD_BLOB_STORAGE_BLOB_TRANSPORT_CONTROLLER_H_ | 155 #endif // CONTENT_CHILD_BLOB_STORAGE_BLOB_TRANSPORT_CONTROLLER_H_ |
OLD | NEW |