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

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

Issue 2815913005: Switch to using scoped_ptr with UserData (Closed)
Patch Set: rebase Created 3 years, 7 months 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/memory/ptr_util.h"
14 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
15 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
16 #include "base/task_runner.h" 17 #include "base/task_runner.h"
17 #include "base/task_scheduler/post_task.h" 18 #include "base/task_scheduler/post_task.h"
18 #include "content/browser/resource_context_impl.h" 19 #include "content/browser/resource_context_impl.h"
19 #include "content/common/resource_request_body_impl.h" 20 #include "content/common/resource_request_body_impl.h"
20 #include "content/public/browser/blob_handle.h" 21 #include "content/public/browser/blob_handle.h"
21 #include "content/public/browser/browser_context.h" 22 #include "content/public/browser/browser_context.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 #include "storage/browser/blob/blob_data_builder.h" 24 #include "storage/browser/blob/blob_data_builder.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 76
76 ChromeBlobStorageContext::ChromeBlobStorageContext() {} 77 ChromeBlobStorageContext::ChromeBlobStorageContext() {}
77 78
78 ChromeBlobStorageContext* ChromeBlobStorageContext::GetFor( 79 ChromeBlobStorageContext* ChromeBlobStorageContext::GetFor(
79 BrowserContext* context) { 80 BrowserContext* context) {
80 if (!context->GetUserData(kBlobStorageContextKeyName)) { 81 if (!context->GetUserData(kBlobStorageContextKeyName)) {
81 scoped_refptr<ChromeBlobStorageContext> blob = 82 scoped_refptr<ChromeBlobStorageContext> blob =
82 new ChromeBlobStorageContext(); 83 new ChromeBlobStorageContext();
83 context->SetUserData( 84 context->SetUserData(
84 kBlobStorageContextKeyName, 85 kBlobStorageContextKeyName,
85 new UserDataAdapter<ChromeBlobStorageContext>(blob.get())); 86 base::MakeUnique<UserDataAdapter<ChromeBlobStorageContext>>(
87 blob.get()));
86 88
87 // Check first to avoid memory leak in unittests. 89 // Check first to avoid memory leak in unittests.
88 bool io_thread_valid = BrowserThread::IsMessageLoopValid(BrowserThread::IO); 90 bool io_thread_valid = BrowserThread::IsMessageLoopValid(BrowserThread::IO);
89 91
90 // Resolve our storage directories. 92 // Resolve our storage directories.
91 FilePath blob_storage_parent = 93 FilePath blob_storage_parent =
92 context->GetPath().Append(kBlobStorageParentDirectory); 94 context->GetPath().Append(kBlobStorageParentDirectory);
93 FilePath blob_storage_dir = blob_storage_parent.Append( 95 FilePath blob_storage_dir = blob_storage_parent.Append(
94 FilePath::FromUTF8Unsafe(base::GenerateGUID())); 96 FilePath::FromUTF8Unsafe(base::GenerateGUID()));
95 97
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 if (!handle) 216 if (!handle)
215 continue; 217 continue;
216 // Ensure the blob and any attached shareable files survive until 218 // Ensure the blob and any attached shareable files survive until
217 // upload completion. The |body| takes ownership of |handle|. 219 // upload completion. The |body| takes ownership of |handle|.
218 const void* key = handle.get(); 220 const void* key = handle.get();
219 body->SetUserData(key, handle.release()); 221 body->SetUserData(key, handle.release());
220 } 222 }
221 } 223 }
222 224
223 } // namespace content 225 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/background_fetch/background_fetch_test_base.cc ('k') | content/browser/browser_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698