Chromium Code Reviews| 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 #include "content/child/blob_storage/blob_transport_controller.h" | 5 #include "content/child/blob_storage/blob_transport_controller.h" |
| 6 | 6 |
| 7 #include <limits> | |
| 7 #include <utility> | 8 #include <utility> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 11 #include "base/bind.h" | |
| 12 #include "base/bind_helpers.h" | |
| 13 #include "base/callback.h" | |
| 14 #include "base/files/file.h" | |
| 10 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 16 #include "base/location.h" | |
| 11 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
| 12 #include "base/memory/shared_memory.h" | 18 #include "base/memory/shared_memory.h" |
| 13 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 14 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
| 21 #include "base/task_runner.h" | |
| 15 #include "content/child/blob_storage/blob_consolidation.h" | 22 #include "content/child/blob_storage/blob_consolidation.h" |
| 16 #include "content/child/child_process.h" | 23 #include "content/child/child_process.h" |
| 17 #include "content/child/thread_safe_sender.h" | 24 #include "content/child/thread_safe_sender.h" |
| 18 #include "content/common/fileapi/webblob_messages.h" | 25 #include "content/common/fileapi/webblob_messages.h" |
| 19 #include "ipc/ipc_sender.h" | 26 #include "ipc/ipc_sender.h" |
| 20 #include "storage/common/blob_storage/blob_item_bytes_request.h" | 27 #include "storage/common/blob_storage/blob_item_bytes_request.h" |
| 21 #include "storage/common/blob_storage/blob_item_bytes_response.h" | 28 #include "storage/common/blob_storage/blob_item_bytes_response.h" |
| 22 #include "storage/common/data_element.h" | 29 #include "storage/common/data_element.h" |
| 23 #include "third_party/WebKit/public/platform/Platform.h" | 30 #include "third_party/WebKit/public/platform/Platform.h" |
| 24 | 31 |
| 32 using base::File; | |
| 25 using base::SharedMemory; | 33 using base::SharedMemory; |
| 26 using base::SharedMemoryHandle; | 34 using base::SharedMemoryHandle; |
| 27 using storage::BlobItemBytesRequest; | 35 using storage::BlobItemBytesRequest; |
| 28 using storage::BlobItemBytesResponse; | 36 using storage::BlobItemBytesResponse; |
| 29 using storage::IPCBlobItemRequestStrategy; | 37 using storage::IPCBlobItemRequestStrategy; |
| 30 using storage::DataElement; | 38 using storage::DataElement; |
| 31 using storage::kBlobStorageIPCThresholdBytes; | 39 using storage::kBlobStorageIPCThresholdBytes; |
| 32 | 40 |
| 41 using storage::BlobItemBytesResponse; | |
| 42 using storage::BlobItemBytesRequest; | |
| 43 using storage::IPCBlobCreationCancelCode; | |
| 44 | |
| 33 namespace content { | 45 namespace content { |
| 34 | 46 |
| 35 using storage::IPCBlobCreationCancelCode; | |
| 36 | |
| 37 using ConsolidatedItem = BlobConsolidation::ConsolidatedItem; | 47 using ConsolidatedItem = BlobConsolidation::ConsolidatedItem; |
| 38 using ReadStatus = BlobConsolidation::ReadStatus; | 48 using ReadStatus = BlobConsolidation::ReadStatus; |
| 39 | 49 |
| 40 namespace { | 50 namespace { |
| 41 static base::LazyInstance<BlobTransportController>::Leaky g_controller = | 51 static base::LazyInstance<BlobTransportController>::Leaky g_controller = |
| 42 LAZY_INSTANCE_INITIALIZER; | 52 LAZY_INSTANCE_INITIALIZER; |
| 43 | 53 |
| 44 // This keeps the process alive while blobs are being transferred. | 54 // This keeps the process alive while blobs are being transferred. |
| 45 // These need to be called on the main thread. | 55 // These need to be called on the main thread. |
| 46 void IncChildProcessRefCount() { | 56 void IncChildProcessRefCount() { |
| 47 blink::Platform::current()->suddenTerminationChanged(false); | 57 blink::Platform::current()->suddenTerminationChanged(false); |
| 48 ChildProcess::current()->AddRefProcess(); | 58 ChildProcess::current()->AddRefProcess(); |
| 49 } | 59 } |
| 50 | 60 |
| 51 void DecChildProcessRefCount() { | 61 void DecChildProcessRefCount() { |
| 52 blink::Platform::current()->suddenTerminationChanged(true); | 62 blink::Platform::current()->suddenTerminationChanged(true); |
| 53 ChildProcess::current()->ReleaseProcess(); | 63 ChildProcess::current()->ReleaseProcess(); |
| 54 } | 64 } |
| 65 | |
| 66 bool WriteSingleChunk(base::File* file, | |
| 67 size_t total_read, | |
| 68 const char* memory, | |
| 69 size_t size) { | |
| 70 size_t written = 0; | |
| 71 size_t max_int = static_cast<size_t>(std::numeric_limits<int>::max()); | |
| 72 while (written < size) { | |
| 73 size_t writing_size = std::min(max_int, size - written); | |
| 74 int actual_written = | |
| 75 file->WriteAtCurrentPos(memory, static_cast<int>(writing_size)); | |
| 76 if (actual_written < 0) { | |
| 77 LOG(ERROR) << "Error writing to file " << actual_written; | |
| 78 return false; | |
| 79 } | |
| 80 written += writing_size; | |
| 81 } | |
| 82 return true; | |
| 83 } | |
| 84 | |
| 85 bool WriteSingleRequestToDisk(const BlobConsolidation* consolidation, | |
| 86 const BlobItemBytesRequest& request, | |
| 87 const IPC::PlatformFileForTransit& transit_file) { | |
| 88 File file = IPC::PlatformFileForTransitToFile(transit_file); | |
| 89 if (!file.IsValid()) | |
| 90 return false; | |
| 91 CHECK_LE(request.handle_offset, | |
| 92 static_cast<uint64_t>(std::numeric_limits<int64_t>::max())); | |
| 93 int64_t seek_distance = | |
| 94 file.Seek(File::FROM_BEGIN, static_cast<int64_t>(request.handle_offset)); | |
| 95 if (seek_distance < 0) { | |
| 96 LOG(ERROR) << "Error seeking " << request.handle_offset << " in file, got " | |
| 97 << seek_distance | |
| 98 << ". File error: " << File::ErrorToString(file.error_details()); | |
| 99 return false; | |
| 100 } | |
| 101 BlobConsolidation::ReadStatus status = consolidation->VisitMemory( | |
| 102 request.renderer_item_index, request.renderer_item_offset, request.size, | |
| 103 base::Bind(&WriteSingleChunk, &file)); | |
| 104 // We need to release the file so we don't automatically close the file. | |
| 105 file.TakePlatformFile(); | |
| 106 return status == ReadStatus::OK; | |
| 107 } | |
| 108 | |
| 109 void WriteDiskRequests( | |
| 110 scoped_refptr<BlobConsolidation> consolidation, | |
| 111 std::vector<BlobItemBytesRequest>* requests, | |
| 112 const std::vector<IPC::PlatformFileForTransit>& file_handles, | |
| 113 const BlobTransportController::ResponseCallback& response_callback, | |
| 114 const BlobTransportController::CancelCallback& error_callback, | |
| 115 scoped_refptr<base::TaskRunner> io_task_runner) { | |
| 116 for (const auto& request : *requests) { | |
| 117 bool success = WriteSingleRequestToDisk(consolidation.get(), request, | |
| 118 file_handles[request.handle_index]); | |
| 119 if (!success) { | |
| 120 io_task_runner->PostTask( | |
| 121 FROM_HERE, base::Bind(error_callback, | |
| 122 IPCBlobCreationCancelCode::FILE_WRITE_FAILED)); | |
| 123 return; | |
| 124 } | |
| 125 io_task_runner->PostTask( | |
| 126 FROM_HERE, | |
| 127 base::Bind(response_callback, | |
| 128 std::vector<BlobItemBytesResponse>{ | |
| 129 BlobItemBytesResponse(request.request_number)})); | |
| 130 } | |
| 131 } | |
| 55 } // namespace | 132 } // namespace |
| 56 | 133 |
| 57 BlobTransportController* BlobTransportController::GetInstance() { | 134 BlobTransportController* BlobTransportController::GetInstance() { |
| 58 return g_controller.Pointer(); | 135 return g_controller.Pointer(); |
| 59 } | 136 } |
| 60 | 137 |
| 61 // static | 138 // static |
| 62 void BlobTransportController::InitiateBlobTransfer( | 139 void BlobTransportController::InitiateBlobTransfer( |
| 63 const std::string& uuid, | 140 const std::string& uuid, |
| 64 const std::string& content_type, | 141 const std::string& content_type, |
| 65 std::unique_ptr<BlobConsolidation> consolidation, | 142 scoped_refptr<BlobConsolidation> consolidation, |
| 66 scoped_refptr<ThreadSafeSender> sender, | 143 scoped_refptr<ThreadSafeSender> sender, |
| 67 base::SingleThreadTaskRunner* io_runner, | 144 base::SingleThreadTaskRunner* io_runner, |
| 68 scoped_refptr<base::SingleThreadTaskRunner> main_runner) { | 145 scoped_refptr<base::SingleThreadTaskRunner> main_runner) { |
| 69 if (main_runner->BelongsToCurrentThread()) { | 146 if (main_runner->BelongsToCurrentThread()) { |
| 70 IncChildProcessRefCount(); | 147 IncChildProcessRefCount(); |
| 71 } else { | 148 } else { |
| 72 main_runner->PostTask(FROM_HERE, base::Bind(&IncChildProcessRefCount)); | 149 main_runner->PostTask(FROM_HERE, base::Bind(&IncChildProcessRefCount)); |
| 73 } | 150 } |
| 74 | 151 |
| 75 std::vector<storage::DataElement> descriptions; | 152 std::vector<storage::DataElement> descriptions; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 88 sender->Send(new BlobStorageMsg_RegisterBlobUUID(uuid, content_type, "", | 165 sender->Send(new BlobStorageMsg_RegisterBlobUUID(uuid, content_type, "", |
| 89 referenced_blobs)); | 166 referenced_blobs)); |
| 90 sender->Send(new BlobStorageMsg_StartBuildingBlob(uuid, descriptions)); | 167 sender->Send(new BlobStorageMsg_StartBuildingBlob(uuid, descriptions)); |
| 91 } | 168 } |
| 92 | 169 |
| 93 void BlobTransportController::OnMemoryRequest( | 170 void BlobTransportController::OnMemoryRequest( |
| 94 const std::string& uuid, | 171 const std::string& uuid, |
| 95 const std::vector<storage::BlobItemBytesRequest>& requests, | 172 const std::vector<storage::BlobItemBytesRequest>& requests, |
| 96 std::vector<base::SharedMemoryHandle>* memory_handles, | 173 std::vector<base::SharedMemoryHandle>* memory_handles, |
| 97 const std::vector<IPC::PlatformFileForTransit>& file_handles, | 174 const std::vector<IPC::PlatformFileForTransit>& file_handles, |
| 98 IPC::Sender* sender) { | 175 IPC::Sender* sender, |
| 176 scoped_refptr<base::TaskRunner> io_runner, | |
| 177 base::TaskRunner* file_runner, | |
| 178 const ResponseCallback& async_response_callback, | |
| 179 const CancelCallback& async_cancel_callback) { | |
| 99 std::vector<storage::BlobItemBytesResponse> responses; | 180 std::vector<storage::BlobItemBytesResponse> responses; |
| 100 ResponsesStatus status = | 181 ResponsesStatus status = GetResponses( |
| 101 GetResponses(uuid, requests, memory_handles, file_handles, &responses); | 182 uuid, requests, memory_handles, file_handles, &responses, |
| 183 std::move(io_runner), file_runner, async_response_callback, | |
| 184 base::Bind(&BlobTransportController::CancelAsyncBlobTransfer, | |
| 185 base::Unretained(this), async_cancel_callback, uuid)); | |
| 102 | 186 |
| 103 switch (status) { | 187 switch (status) { |
| 104 case ResponsesStatus::BLOB_NOT_FOUND: | 188 case ResponsesStatus::BLOB_NOT_FOUND: |
| 105 // sender->Send(new BlobStorageMsg_CancelBuildingBlob(uuid, | 189 // sender->Send(new BlobStorageMsg_CancelBuildingBlob(uuid, |
| 106 // IPCBlobCreationCancelCode::UNKNOWN)); | 190 // IPCBlobCreationCancelCode::UNKNOWN)); |
| 107 return; | 191 return; |
| 108 case ResponsesStatus::SHARED_MEMORY_MAP_FAILED: | 192 case ResponsesStatus::SHARED_MEMORY_MAP_FAILED: |
| 109 // This would happen if the renderer process doesn't have enough memory | 193 // This would happen if the renderer process doesn't have enough memory |
| 110 // to map the shared memory, which is possible if we don't have much | 194 // to map the shared memory, which is possible if we don't have much |
| 111 // memory. If this scenario happens often, we could delay the response | 195 // memory. If this scenario happens often, we could delay the response |
| 112 // until we have enough memory. For now we just fail. | 196 // until we have enough memory. For now we just fail. |
| 113 CHECK(false) << "Unable to map shared memory to send blob " << uuid | 197 CHECK(false) << "Unable to map shared memory to send blob " << uuid |
| 114 << "."; | 198 << "."; |
| 115 break; | 199 break; |
| 116 case ResponsesStatus::SUCCESS: | 200 case ResponsesStatus::SUCCESS: |
| 201 case ResponsesStatus::PENDING_IO: | |
| 117 break; | 202 break; |
| 118 } | 203 } |
| 119 | 204 |
| 120 sender->Send(new BlobStorageMsg_MemoryItemResponse(uuid, responses)); | 205 if (!responses.empty()) |
| 206 sender->Send(new BlobStorageMsg_MemoryItemResponse(uuid, responses)); | |
| 121 } | 207 } |
| 122 | 208 |
| 123 void BlobTransportController::OnCancel( | 209 void BlobTransportController::OnCancel( |
| 124 const std::string& uuid, | 210 const std::string& uuid, |
| 125 storage::IPCBlobCreationCancelCode code) { | 211 storage::IPCBlobCreationCancelCode code) { |
| 126 DVLOG(1) << "Received blob cancel for blob " << uuid | 212 DVLOG(1) << "Received blob cancel for blob " << uuid |
| 127 << " with code: " << static_cast<int>(code); | 213 << " with code: " << static_cast<int>(code); |
| 128 ReleaseBlobConsolidation(uuid); | 214 ReleaseBlobConsolidation(uuid); |
| 129 } | 215 } |
| 130 | 216 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 BlobTransportController::~BlobTransportController() {} | 277 BlobTransportController::~BlobTransportController() {} |
| 192 | 278 |
| 193 void BlobTransportController::ClearForTesting() { | 279 void BlobTransportController::ClearForTesting() { |
| 194 if (!blob_storage_.empty() && main_thread_runner_) { | 280 if (!blob_storage_.empty() && main_thread_runner_) { |
| 195 main_thread_runner_->PostTask(FROM_HERE, | 281 main_thread_runner_->PostTask(FROM_HERE, |
| 196 base::Bind(&DecChildProcessRefCount)); | 282 base::Bind(&DecChildProcessRefCount)); |
| 197 } | 283 } |
| 198 blob_storage_.clear(); | 284 blob_storage_.clear(); |
| 199 } | 285 } |
| 200 | 286 |
| 287 void BlobTransportController::CancelAsyncBlobTransfer( | |
| 288 const CancelCallback& async_cancel_callback, | |
| 289 const std::string& uuid, | |
| 290 storage::IPCBlobCreationCancelCode code) { | |
| 291 blob_storage_.erase(uuid); | |
| 292 async_cancel_callback.Run(code); | |
| 293 } | |
| 294 | |
| 201 void BlobTransportController::StoreBlobDataForRequests( | 295 void BlobTransportController::StoreBlobDataForRequests( |
| 202 const std::string& uuid, | 296 const std::string& uuid, |
| 203 std::unique_ptr<BlobConsolidation> consolidation, | 297 scoped_refptr<BlobConsolidation> consolidation, |
| 204 scoped_refptr<base::SingleThreadTaskRunner> main_runner) { | 298 scoped_refptr<base::SingleThreadTaskRunner> main_runner) { |
| 205 if (!main_thread_runner_.get()) { | 299 if (!main_thread_runner_.get()) { |
| 206 main_thread_runner_ = std::move(main_runner); | 300 main_thread_runner_ = std::move(main_runner); |
| 207 } | 301 } |
| 208 blob_storage_[uuid] = std::move(consolidation); | 302 blob_storage_[uuid] = std::move(consolidation); |
| 209 } | 303 } |
| 210 | 304 |
| 211 BlobTransportController::ResponsesStatus BlobTransportController::GetResponses( | 305 BlobTransportController::ResponsesStatus BlobTransportController::GetResponses( |
| 212 const std::string& uuid, | 306 const std::string& uuid, |
| 213 const std::vector<BlobItemBytesRequest>& requests, | 307 const std::vector<BlobItemBytesRequest>& requests, |
| 214 std::vector<SharedMemoryHandle>* memory_handles, | 308 std::vector<SharedMemoryHandle>* memory_handles, |
| 215 const std::vector<IPC::PlatformFileForTransit>& file_handles, | 309 const std::vector<IPC::PlatformFileForTransit>& file_handles, |
| 216 std::vector<BlobItemBytesResponse>* out) { | 310 std::vector<BlobItemBytesResponse>* out, |
| 311 scoped_refptr<base::TaskRunner> io_runner, | |
| 312 base::TaskRunner* file_runner, | |
| 313 const ResponseCallback& response_callback, | |
| 314 const CancelCallback& error_callback) { | |
| 217 DCHECK(out->empty()); | 315 DCHECK(out->empty()); |
| 218 auto it = blob_storage_.find(uuid); | 316 auto it = blob_storage_.find(uuid); |
| 219 if (it == blob_storage_.end()) | 317 if (it == blob_storage_.end()) |
| 220 return ResponsesStatus::BLOB_NOT_FOUND; | 318 return ResponsesStatus::BLOB_NOT_FOUND; |
| 221 | 319 |
| 222 BlobConsolidation* consolidation = it->second.get(); | 320 BlobConsolidation* consolidation = it->second.get(); |
| 223 const auto& consolidated_items = consolidation->consolidated_items(); | 321 const auto& consolidated_items = consolidation->consolidated_items(); |
| 224 | 322 |
| 323 scoped_ptr<std::vector<BlobItemBytesRequest>> file_requests( | |
| 324 new std::vector<BlobItemBytesRequest>()); | |
| 325 | |
| 225 // Since we can be writing to the same shared memory handle from multiple | 326 // Since we can be writing to the same shared memory handle from multiple |
| 226 // requests, we keep them in a vector and lazily create them. | 327 // requests, we keep them in a vector and lazily create them. |
| 227 ScopedVector<SharedMemory> opened_memory; | 328 ScopedVector<SharedMemory> opened_memory; |
| 228 opened_memory.resize(memory_handles->size()); | 329 opened_memory.resize(memory_handles->size()); |
| 229 for (const BlobItemBytesRequest& request : requests) { | 330 for (const BlobItemBytesRequest& request : requests) { |
| 230 DCHECK_LT(request.renderer_item_index, consolidated_items.size()) | 331 DCHECK_LT(request.renderer_item_index, consolidated_items.size()) |
| 231 << "Invalid item index"; | 332 << "Invalid item index"; |
| 232 | 333 |
| 233 const ConsolidatedItem& item = | 334 const ConsolidatedItem& item = |
| 234 consolidated_items[request.renderer_item_index]; | 335 consolidated_items[request.renderer_item_index]; |
| 235 DCHECK_LE(request.renderer_item_offset + request.size, item.length) | 336 DCHECK_LE(request.renderer_item_offset + request.size, item.length) |
| 236 << "Invalid data range"; | 337 << "Invalid data range"; |
| 237 DCHECK_EQ(item.type, DataElement::TYPE_BYTES) << "Invalid element type"; | 338 DCHECK_EQ(item.type, DataElement::TYPE_BYTES) << "Invalid element type"; |
| 238 | 339 |
| 239 out->push_back(BlobItemBytesResponse(request.request_number)); | |
| 240 switch (request.transport_strategy) { | 340 switch (request.transport_strategy) { |
| 241 case IPCBlobItemRequestStrategy::IPC: { | 341 case IPCBlobItemRequestStrategy::IPC: { |
| 342 out->push_back(BlobItemBytesResponse(request.request_number)); | |
| 242 BlobItemBytesResponse& response = out->back(); | 343 BlobItemBytesResponse& response = out->back(); |
| 243 ReadStatus status = consolidation->ReadMemory( | 344 ReadStatus status = consolidation->ReadMemory( |
| 244 request.renderer_item_index, request.renderer_item_offset, | 345 request.renderer_item_index, request.renderer_item_offset, |
| 245 request.size, response.allocate_mutable_data(request.size)); | 346 request.size, response.allocate_mutable_data(request.size)); |
| 246 DCHECK(status == ReadStatus::OK) | 347 DCHECK(status == ReadStatus::OK) |
| 247 << "Error reading from consolidated blob: " | 348 << "Error reading from consolidated blob: " |
| 248 << static_cast<int>(status); | 349 << static_cast<int>(status); |
| 249 break; | 350 break; |
| 250 } | 351 } |
| 251 case IPCBlobItemRequestStrategy::SHARED_MEMORY: { | 352 case IPCBlobItemRequestStrategy::SHARED_MEMORY: { |
| 353 out->push_back(BlobItemBytesResponse(request.request_number)); | |
| 252 DCHECK_LT(request.handle_index, memory_handles->size()) | 354 DCHECK_LT(request.handle_index, memory_handles->size()) |
| 253 << "Invalid handle index."; | 355 << "Invalid handle index."; |
| 254 SharedMemory* memory = opened_memory[request.handle_index]; | 356 SharedMemory* memory = opened_memory[request.handle_index]; |
| 255 if (!memory) { | 357 if (!memory) { |
| 256 SharedMemoryHandle& handle = (*memory_handles)[request.handle_index]; | 358 SharedMemoryHandle& handle = (*memory_handles)[request.handle_index]; |
| 257 DCHECK(SharedMemory::IsHandleValid(handle)); | 359 DCHECK(SharedMemory::IsHandleValid(handle)); |
| 258 std::unique_ptr<SharedMemory> shared_memory( | 360 std::unique_ptr<SharedMemory> shared_memory( |
| 259 new SharedMemory(handle, false)); | 361 new SharedMemory(handle, false)); |
| 260 if (!shared_memory->Map(request.size)) | 362 if (!shared_memory->Map(request.size)) |
| 261 return ResponsesStatus::SHARED_MEMORY_MAP_FAILED; | 363 return ResponsesStatus::SHARED_MEMORY_MAP_FAILED; |
| 262 memory = shared_memory.get(); | 364 memory = shared_memory.get(); |
| 263 opened_memory[request.handle_index] = shared_memory.release(); | 365 opened_memory[request.handle_index] = shared_memory.release(); |
| 264 } | 366 } |
| 265 CHECK(memory->memory()) << "Couldn't map memory for blob transfer."; | 367 CHECK(memory->memory()) << "Couldn't map memory for blob transfer."; |
| 266 ReadStatus status = consolidation->ReadMemory( | 368 ReadStatus status = consolidation->ReadMemory( |
| 267 request.renderer_item_index, request.renderer_item_offset, | 369 request.renderer_item_index, request.renderer_item_offset, |
| 268 request.size, | 370 request.size, |
| 269 static_cast<char*>(memory->memory()) + request.handle_offset); | 371 static_cast<char*>(memory->memory()) + request.handle_offset); |
| 270 DCHECK(status == ReadStatus::OK) | 372 DCHECK(status == ReadStatus::OK) |
| 271 << "Error reading from consolidated blob: " | 373 << "Error reading from consolidated blob: " |
| 272 << static_cast<int>(status); | 374 << static_cast<int>(status); |
| 273 break; | 375 break; |
| 274 } | 376 } |
| 275 case IPCBlobItemRequestStrategy::FILE: | 377 case IPCBlobItemRequestStrategy::FILE: |
| 276 NOTREACHED() << "TODO(dmurph): Not implemented."; | 378 DCHECK_LT(request.handle_index, file_handles.size()) |
| 379 << "Invalid handle index."; | |
| 380 file_requests->push_back(request); | |
| 277 break; | 381 break; |
| 278 case IPCBlobItemRequestStrategy::UNKNOWN: | 382 case IPCBlobItemRequestStrategy::UNKNOWN: |
| 279 NOTREACHED(); | 383 NOTREACHED(); |
| 280 break; | 384 break; |
| 281 } | 385 } |
| 282 } | 386 } |
| 283 return ResponsesStatus::SUCCESS; | 387 if (file_requests->empty()) { |
| 388 return ResponsesStatus::SUCCESS; | |
| 389 } | |
| 390 file_runner->PostTask( | |
| 391 FROM_HERE, base::Bind(&WriteDiskRequests, consolidation, | |
| 392 base::Owned(file_requests.release()), file_handles, | |
|
kinuko
2016/04/15 15:02:32
I think base::Passed(&file_requests) would be more
dmurph
2016/04/20 21:15:34
done.
| |
| 393 response_callback, error_callback, | |
| 394 base::Passed(std::move(io_runner)))); | |
| 395 return ResponsesStatus::PENDING_IO; | |
| 284 } | 396 } |
| 285 | 397 |
| 286 void BlobTransportController::ReleaseBlobConsolidation( | 398 void BlobTransportController::ReleaseBlobConsolidation( |
| 287 const std::string& uuid) { | 399 const std::string& uuid) { |
| 288 if (blob_storage_.erase(uuid)) { | 400 if (blob_storage_.erase(uuid)) { |
| 289 main_thread_runner_->PostTask(FROM_HERE, | 401 main_thread_runner_->PostTask(FROM_HERE, |
| 290 base::Bind(&DecChildProcessRefCount)); | 402 base::Bind(&DecChildProcessRefCount)); |
| 291 } | 403 } |
| 292 } | 404 } |
| 293 | 405 |
| 294 } // namespace content | 406 } // namespace content |
| OLD | NEW |