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/files/file.h" | 10 #include "base/files/file.h" |
11 #include "base/files/file_enumerator.h" | 11 #include "base/files/file_enumerator.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/guid.h" | 13 #include "base/guid.h" |
14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/task_runner.h" | 16 #include "base/task_runner.h" |
17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/task_scheduler/post_task.h" |
18 #include "content/browser/resource_context_impl.h" | 18 #include "content/browser/resource_context_impl.h" |
19 #include "content/common/resource_request_body_impl.h" | 19 #include "content/common/resource_request_body_impl.h" |
20 #include "content/public/browser/blob_handle.h" | 20 #include "content/public/browser/blob_handle.h" |
21 #include "content/public/browser/browser_context.h" | 21 #include "content/public/browser/browser_context.h" |
22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
23 #include "storage/browser/blob/blob_data_builder.h" | 23 #include "storage/browser/blob/blob_data_builder.h" |
24 #include "storage/browser/blob/blob_data_handle.h" | 24 #include "storage/browser/blob/blob_data_handle.h" |
25 #include "storage/browser/blob/blob_memory_controller.h" | 25 #include "storage/browser/blob/blob_memory_controller.h" |
26 #include "storage/browser/blob/blob_storage_context.h" | 26 #include "storage/browser/blob/blob_storage_context.h" |
27 | 27 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 FilePath blob_storage_dir = blob_storage_parent.Append( | 93 FilePath blob_storage_dir = blob_storage_parent.Append( |
94 FilePath::FromUTF8Unsafe(base::GenerateGUID())); | 94 FilePath::FromUTF8Unsafe(base::GenerateGUID())); |
95 | 95 |
96 // Only populate the task runner if we're not off the record. This enables | 96 // Only populate the task runner if we're not off the record. This enables |
97 // paging/saving blob data to disk. | 97 // paging/saving blob data to disk. |
98 scoped_refptr<base::TaskRunner> file_task_runner; | 98 scoped_refptr<base::TaskRunner> file_task_runner; |
99 | 99 |
100 // If we're not incognito mode, schedule all of our file tasks to enable | 100 // If we're not incognito mode, schedule all of our file tasks to enable |
101 // disk on the storage context. | 101 // disk on the storage context. |
102 if (!context->IsOffTheRecord() && io_thread_valid) { | 102 if (!context->IsOffTheRecord() && io_thread_valid) { |
103 file_task_runner = | 103 file_task_runner = base::CreateTaskRunnerWithTraits( |
104 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 104 base::TaskTraits() |
105 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 105 .MayBlock() |
| 106 .WithPriority(base::TaskPriority::BACKGROUND) |
| 107 .WithShutdownBehavior( |
| 108 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN)); |
106 // Removes our old blob directories if they exist. | 109 // Removes our old blob directories if they exist. |
107 BrowserThread::PostAfterStartupTask( | 110 BrowserThread::PostAfterStartupTask( |
108 FROM_HERE, file_task_runner, | 111 FROM_HERE, file_task_runner, |
109 base::Bind(&RemoveOldBlobStorageDirectories, | 112 base::Bind(&RemoveOldBlobStorageDirectories, |
110 base::Passed(&blob_storage_parent), blob_storage_dir)); | 113 base::Passed(&blob_storage_parent), blob_storage_dir)); |
111 } | 114 } |
112 | 115 |
113 if (io_thread_valid) { | 116 if (io_thread_valid) { |
114 BrowserThread::PostTask( | 117 BrowserThread::PostTask( |
115 BrowserThread::IO, FROM_HERE, | 118 BrowserThread::IO, FROM_HERE, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 if (!handle) | 214 if (!handle) |
212 continue; | 215 continue; |
213 // Ensure the blob and any attached shareable files survive until | 216 // Ensure the blob and any attached shareable files survive until |
214 // upload completion. The |body| takes ownership of |handle|. | 217 // upload completion. The |body| takes ownership of |handle|. |
215 const void* key = handle.get(); | 218 const void* key = handle.get(); |
216 body->SetUserData(key, handle.release()); | 219 body->SetUserData(key, handle.release()); |
217 } | 220 } |
218 } | 221 } |
219 | 222 |
220 } // namespace content | 223 } // namespace content |
OLD | NEW |