| 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 "base/optional.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 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // asynchronously. Use CancelAllBlobTransfers to stop usage of the |sender|. | 81 // asynchronously. Use CancelAllBlobTransfers to stop usage of the |sender|. |
| 81 // We close the file handles once we're done writing to them. | 82 // We close the file handles once we're done writing to them. |
| 82 void OnMemoryRequest( | 83 void OnMemoryRequest( |
| 83 const std::string& uuid, | 84 const std::string& uuid, |
| 84 const std::vector<storage::BlobItemBytesRequest>& requests, | 85 const std::vector<storage::BlobItemBytesRequest>& requests, |
| 85 std::vector<base::SharedMemoryHandle>* memory_handles, | 86 std::vector<base::SharedMemoryHandle>* memory_handles, |
| 86 const std::vector<IPC::PlatformFileForTransit>& file_handles, | 87 const std::vector<IPC::PlatformFileForTransit>& file_handles, |
| 87 base::TaskRunner* file_runner, | 88 base::TaskRunner* file_runner, |
| 88 IPC::Sender* sender); | 89 IPC::Sender* sender); |
| 89 | 90 |
| 90 void OnCancel(const std::string& uuid, | 91 void OnBlobFinalStatus(const std::string& uuid, storage::BlobStatus code); |
| 91 storage::IPCBlobCreationCancelCode code); | |
| 92 | |
| 93 void OnDone(const std::string& uuid); | |
| 94 | 92 |
| 95 bool IsTransporting(const std::string& uuid) { | 93 bool IsTransporting(const std::string& uuid) { |
| 96 return blob_storage_.find(uuid) != blob_storage_.end(); | 94 return blob_storage_.find(uuid) != blob_storage_.end(); |
| 97 } | 95 } |
| 98 | 96 |
| 99 // Invalidates all asynchronously running memory request handlers and clears | 97 // Invalidates all asynchronously running memory request handlers and clears |
| 100 // the internal state. If our map wasn't previously empty, then we call | 98 // the internal state. If our map wasn't previously empty, then we call |
| 101 // ChildProcess::ReleaseProcess to release our previous reference. | 99 // ChildProcess::ReleaseProcess to release our previous reference. |
| 102 void CancelAllBlobTransfers(); | 100 void CancelAllBlobTransfers(); |
| 103 | 101 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 120 static void GetDescriptions(BlobConsolidation* consolidation, | 118 static void GetDescriptions(BlobConsolidation* consolidation, |
| 121 size_t max_data_population, | 119 size_t max_data_population, |
| 122 std::vector<storage::DataElement>* out); | 120 std::vector<storage::DataElement>* out); |
| 123 | 121 |
| 124 BlobTransportController(); | 122 BlobTransportController(); |
| 125 ~BlobTransportController(); | 123 ~BlobTransportController(); |
| 126 | 124 |
| 127 void OnFileWriteComplete( | 125 void OnFileWriteComplete( |
| 128 IPC::Sender* sender, | 126 IPC::Sender* sender, |
| 129 const std::string& uuid, | 127 const std::string& uuid, |
| 130 const std::pair<std::vector<storage::BlobItemBytesResponse>, | 128 const base::Optional<std::vector<storage::BlobItemBytesResponse>>& |
| 131 storage::IPCBlobCreationCancelCode>& result); | 129 result); |
| 132 | 130 |
| 133 void StoreBlobDataForRequests( | 131 void StoreBlobDataForRequests( |
| 134 const std::string& uuid, | 132 const std::string& uuid, |
| 135 scoped_refptr<BlobConsolidation> consolidation, | 133 scoped_refptr<BlobConsolidation> consolidation, |
| 136 scoped_refptr<base::SingleThreadTaskRunner> main_runner); | 134 scoped_refptr<base::SingleThreadTaskRunner> main_runner); |
| 137 | 135 |
| 138 // Deletes the consolidation and calls ChildProcess::ReleaseProcess. | 136 // Deletes the consolidation and calls ChildProcess::ReleaseProcess. |
| 139 void ReleaseBlobConsolidation(const std::string& uuid); | 137 void ReleaseBlobConsolidation(const std::string& uuid); |
| 140 | 138 |
| 141 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner_; | 139 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner_; |
| 142 std::map<std::string, scoped_refptr<BlobConsolidation>> blob_storage_; | 140 std::map<std::string, scoped_refptr<BlobConsolidation>> blob_storage_; |
| 143 base::WeakPtrFactory<BlobTransportController> weak_factory_; | 141 base::WeakPtrFactory<BlobTransportController> weak_factory_; |
| 144 | 142 |
| 145 DISALLOW_COPY_AND_ASSIGN(BlobTransportController); | 143 DISALLOW_COPY_AND_ASSIGN(BlobTransportController); |
| 146 }; | 144 }; |
| 147 | 145 |
| 148 } // namespace content | 146 } // namespace content |
| 149 #endif // CONTENT_CHILD_BLOB_STORAGE_BLOB_TRANSPORT_CONTROLLER_H_ | 147 #endif // CONTENT_CHILD_BLOB_STORAGE_BLOB_TRANSPORT_CONTROLLER_H_ |
| OLD | NEW |