OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/blob_storage/chrome_blob_storage_context.h" | 5 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
11 #include "base/files/file.h" | 11 #include "base/files/file.h" |
12 #include "base/files/file_enumerator.h" | 12 #include "base/files/file_enumerator.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/guid.h" | 14 #include "base/guid.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/supports_user_data.h" | 18 #include "base/supports_user_data.h" |
19 #include "base/task_runner.h" | 19 #include "base/task_runner.h" |
20 #include "base/task_scheduler/post_task.h" | 20 #include "base/task_scheduler/post_task.h" |
21 #include "content/browser/resource_context_impl.h" | 21 #include "content/browser/resource_context_impl.h" |
22 #include "content/common/resource_request_body_impl.h" | |
23 #include "content/public/browser/blob_handle.h" | 22 #include "content/public/browser/blob_handle.h" |
24 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
25 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/common/content_features.h" | 25 #include "content/public/common/content_features.h" |
| 26 #include "content/public/common/resource_request_body.h" |
27 #include "storage/browser/blob/blob_data_builder.h" | 27 #include "storage/browser/blob/blob_data_builder.h" |
28 #include "storage/browser/blob/blob_memory_controller.h" | 28 #include "storage/browser/blob/blob_memory_controller.h" |
29 #include "storage/browser/blob/blob_registry_impl.h" | 29 #include "storage/browser/blob/blob_registry_impl.h" |
30 #include "storage/browser/blob/blob_storage_context.h" | 30 #include "storage/browser/blob/blob_storage_context.h" |
31 | 31 |
32 using base::FilePath; | 32 using base::FilePath; |
33 using base::UserDataAdapter; | 33 using base::UserDataAdapter; |
34 using storage::BlobStorageContext; | 34 using storage::BlobStorageContext; |
35 | 35 |
36 namespace content { | 36 namespace content { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 delete this; | 203 delete this; |
204 } | 204 } |
205 | 205 |
206 storage::BlobStorageContext* GetBlobStorageContext( | 206 storage::BlobStorageContext* GetBlobStorageContext( |
207 ChromeBlobStorageContext* blob_storage_context) { | 207 ChromeBlobStorageContext* blob_storage_context) { |
208 if (!blob_storage_context) | 208 if (!blob_storage_context) |
209 return NULL; | 209 return NULL; |
210 return blob_storage_context->context(); | 210 return blob_storage_context->context(); |
211 } | 211 } |
212 | 212 |
213 bool GetBodyBlobDataHandles(ResourceRequestBodyImpl* body, | 213 bool GetBodyBlobDataHandles(ResourceRequestBody* body, |
214 ResourceContext* resource_context, | 214 ResourceContext* resource_context, |
215 BlobHandles* blob_handles) { | 215 BlobHandles* blob_handles) { |
216 blob_handles->clear(); | 216 blob_handles->clear(); |
217 | 217 |
218 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | 218 storage::BlobStorageContext* blob_context = GetBlobStorageContext( |
219 GetChromeBlobStorageContextForResourceContext(resource_context)); | 219 GetChromeBlobStorageContextForResourceContext(resource_context)); |
220 | 220 |
221 DCHECK(blob_context); | 221 DCHECK(blob_context); |
222 for (size_t i = 0; i < body->elements()->size(); ++i) { | 222 for (size_t i = 0; i < body->elements()->size(); ++i) { |
223 const ResourceRequestBodyImpl::Element& element = (*body->elements())[i]; | 223 const ResourceRequestBody::Element& element = (*body->elements())[i]; |
224 if (element.type() != ResourceRequestBodyImpl::Element::TYPE_BLOB) | 224 if (element.type() != ResourceRequestBody::Element::TYPE_BLOB) |
225 continue; | 225 continue; |
226 std::unique_ptr<storage::BlobDataHandle> handle = | 226 std::unique_ptr<storage::BlobDataHandle> handle = |
227 blob_context->GetBlobDataFromUUID(element.blob_uuid()); | 227 blob_context->GetBlobDataFromUUID(element.blob_uuid()); |
228 if (!handle) | 228 if (!handle) |
229 return false; | 229 return false; |
230 blob_handles->push_back(std::move(handle)); | 230 blob_handles->push_back(std::move(handle)); |
231 } | 231 } |
232 return true; | 232 return true; |
233 } | 233 } |
234 | 234 |
235 } // namespace content | 235 } // namespace content |
OLD | NEW |