Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(661)

Side by Side Diff: content/browser/blob_storage/chrome_blob_storage_context.cc

Issue 2552153002: [BlobStorage] Enabling disk paging and direct storage. (Closed)
Patch Set: Added an early-exit clause so files don't get created unnecessarily Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/threading/sequenced_worker_pool.h"
18 #include "content/public/browser/blob_handle.h" 18 #include "content/public/browser/blob_handle.h"
19 #include "content/public/browser/browser_context.h" 19 #include "content/public/browser/browser_context.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "storage/browser/blob/blob_data_builder.h" 21 #include "storage/browser/blob/blob_data_builder.h"
22 #include "storage/browser/blob/blob_data_handle.h" 22 #include "storage/browser/blob/blob_data_handle.h"
23 #include "storage/browser/blob/blob_memory_controller.h"
23 #include "storage/browser/blob/blob_storage_context.h" 24 #include "storage/browser/blob/blob_storage_context.h"
24 25
25 using base::FilePath; 26 using base::FilePath;
26 using base::UserDataAdapter; 27 using base::UserDataAdapter;
27 using storage::BlobStorageContext; 28 using storage::BlobStorageContext;
28 29
29 namespace content { 30 namespace content {
30 31
31 namespace { 32 namespace {
32 const FilePath::CharType kBlobStorageContextKeyName[] = 33 const FilePath::CharType kBlobStorageContextKeyName[] =
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return UserDataAdapter<ChromeBlobStorageContext>::Get( 117 return UserDataAdapter<ChromeBlobStorageContext>::Get(
117 context, kBlobStorageContextKeyName); 118 context, kBlobStorageContextKeyName);
118 } 119 }
119 120
120 void ChromeBlobStorageContext::InitializeOnIOThread( 121 void ChromeBlobStorageContext::InitializeOnIOThread(
121 FilePath blob_storage_dir, 122 FilePath blob_storage_dir,
122 scoped_refptr<base::TaskRunner> file_task_runner) { 123 scoped_refptr<base::TaskRunner> file_task_runner) {
123 DCHECK_CURRENTLY_ON(BrowserThread::IO); 124 DCHECK_CURRENTLY_ON(BrowserThread::IO);
124 context_.reset(new BlobStorageContext(std::move(blob_storage_dir), 125 context_.reset(new BlobStorageContext(std::move(blob_storage_dir),
125 std::move(file_task_runner))); 126 std::move(file_task_runner)));
127 // Signal the BlobMemoryController when it's appropriate to calculate its
128 // storage limits.
129 BrowserThread::PostAfterStartupTask(
130 FROM_HERE, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
131 base::Bind(&storage::BlobMemoryController::CalculateBlobStorageLimits,
132 context_->mutable_memory_controller()->GetWeakPtr()));
126 } 133 }
127 134
128 std::unique_ptr<BlobHandle> ChromeBlobStorageContext::CreateMemoryBackedBlob( 135 std::unique_ptr<BlobHandle> ChromeBlobStorageContext::CreateMemoryBackedBlob(
129 const char* data, 136 const char* data,
130 size_t length) { 137 size_t length) {
131 DCHECK_CURRENTLY_ON(BrowserThread::IO); 138 DCHECK_CURRENTLY_ON(BrowserThread::IO);
132 139
133 std::string uuid(base::GenerateGUID()); 140 std::string uuid(base::GenerateGUID());
134 storage::BlobDataBuilder blob_data_builder(uuid); 141 storage::BlobDataBuilder blob_data_builder(uuid);
135 blob_data_builder.AppendData(data, length); 142 blob_data_builder.AppendData(data, length);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 void ChromeBlobStorageContext::DeleteOnCorrectThread() const { 177 void ChromeBlobStorageContext::DeleteOnCorrectThread() const {
171 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && 178 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) &&
172 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { 179 !BrowserThread::CurrentlyOn(BrowserThread::IO)) {
173 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); 180 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this);
174 return; 181 return;
175 } 182 }
176 delete this; 183 delete this;
177 } 184 }
178 185
179 } // namespace content 186 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698