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