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 <limits> |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 scoped_refptr<ThreadSafeSender> sender, | 164 scoped_refptr<ThreadSafeSender> sender, |
165 base::SingleThreadTaskRunner* io_runner, | 165 base::SingleThreadTaskRunner* io_runner, |
166 scoped_refptr<base::SingleThreadTaskRunner> main_runner) { | 166 scoped_refptr<base::SingleThreadTaskRunner> main_runner) { |
167 if (main_runner->BelongsToCurrentThread()) { | 167 if (main_runner->BelongsToCurrentThread()) { |
168 IncChildProcessRefCount(); | 168 IncChildProcessRefCount(); |
169 } else { | 169 } else { |
170 main_runner->PostTask(FROM_HERE, base::Bind(&IncChildProcessRefCount)); | 170 main_runner->PostTask(FROM_HERE, base::Bind(&IncChildProcessRefCount)); |
171 } | 171 } |
172 | 172 |
173 std::vector<storage::DataElement> descriptions; | 173 std::vector<storage::DataElement> descriptions; |
174 std::set<std::string> referenced_blobs = consolidation->referenced_blobs(); | |
175 BlobTransportController::GetDescriptions( | 174 BlobTransportController::GetDescriptions( |
176 consolidation.get(), kBlobStorageIPCThresholdBytes, &descriptions); | 175 consolidation.get(), kBlobStorageIPCThresholdBytes, &descriptions); |
177 // I post the task first to make sure that we store our consolidation before | 176 // I post the task first to make sure that we store our consolidation before |
178 // we get a request back from the browser. | 177 // we get a request back from the browser. |
179 io_runner->PostTask( | 178 io_runner->PostTask( |
180 FROM_HERE, | 179 FROM_HERE, |
181 base::Bind(&BlobTransportController::StoreBlobDataForRequests, | 180 base::Bind(&BlobTransportController::StoreBlobDataForRequests, |
182 base::Unretained(BlobTransportController::GetInstance()), uuid, | 181 base::Unretained(BlobTransportController::GetInstance()), uuid, |
183 base::Passed(std::move(consolidation)), | 182 base::Passed(std::move(consolidation)), |
184 base::Passed(std::move(main_runner)))); | 183 base::Passed(std::move(main_runner)))); |
185 // TODO(dmurph): Merge register and start messages. | 184 sender->Send( |
186 sender->Send(new BlobStorageMsg_RegisterBlobUUID(uuid, content_type, "", | 185 new BlobStorageMsg_RegisterBlob(uuid, content_type, "", descriptions)); |
187 referenced_blobs)); | |
188 sender->Send(new BlobStorageMsg_StartBuildingBlob(uuid, descriptions)); | |
189 } | 186 } |
190 | 187 |
191 void BlobTransportController::OnMemoryRequest( | 188 void BlobTransportController::OnMemoryRequest( |
192 const std::string& uuid, | 189 const std::string& uuid, |
193 const std::vector<storage::BlobItemBytesRequest>& requests, | 190 const std::vector<storage::BlobItemBytesRequest>& requests, |
194 std::vector<base::SharedMemoryHandle>* memory_handles, | 191 std::vector<base::SharedMemoryHandle>* memory_handles, |
195 const std::vector<IPC::PlatformFileForTransit>& file_handles, | 192 const std::vector<IPC::PlatformFileForTransit>& file_handles, |
196 base::TaskRunner* file_runner, | 193 base::TaskRunner* file_runner, |
197 IPC::Sender* sender) { | 194 IPC::Sender* sender) { |
198 std::vector<BlobItemBytesResponse> responses; | 195 std::vector<BlobItemBytesResponse> responses; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 394 |
398 void BlobTransportController::ReleaseBlobConsolidation( | 395 void BlobTransportController::ReleaseBlobConsolidation( |
399 const std::string& uuid) { | 396 const std::string& uuid) { |
400 if (blob_storage_.erase(uuid)) { | 397 if (blob_storage_.erase(uuid)) { |
401 main_thread_runner_->PostTask(FROM_HERE, | 398 main_thread_runner_->PostTask(FROM_HERE, |
402 base::Bind(&DecChildProcessRefCount)); | 399 base::Bind(&DecChildProcessRefCount)); |
403 } | 400 } |
404 } | 401 } |
405 | 402 |
406 } // namespace content | 403 } // namespace content |
OLD | NEW |