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

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

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
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/fileapi/chrome_blob_storage_context.h" 5 #include "content/browser/fileapi/chrome_blob_storage_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/public/browser/browser_context.h" 8 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "webkit/browser/blob/blob_storage_controller.h" 10 #include "webkit/browser/blob/blob_storage_controller.h"
11 11
12 using base::UserDataAdapter; 12 using base::UserDataAdapter;
13 using webkit_blob::BlobStorageController; 13 using webkit_blob::BlobStorageController;
14 14
15 namespace content { 15 namespace content {
16 16
17 static const char* kBlobStorageContextKeyName = "content_blob_storage_context"; 17 static const char* kBlobStorageContextKeyName = "content_blob_storage_context";
18 18
19 ChromeBlobStorageContext::ChromeBlobStorageContext() {} 19 ChromeBlobStorageContext::ChromeBlobStorageContext() {}
20 20
21 ChromeBlobStorageContext* ChromeBlobStorageContext::GetFor( 21 ChromeBlobStorageContext* ChromeBlobStorageContext::GetFor(
22 BrowserContext* context) { 22 BrowserContext* context) {
23 if (!context->GetUserData(kBlobStorageContextKeyName)) { 23 if (!context->GetUserData(kBlobStorageContextKeyName)) {
24 scoped_refptr<ChromeBlobStorageContext> blob = 24 scoped_refptr<ChromeBlobStorageContext> blob =
25 new ChromeBlobStorageContext(); 25 new ChromeBlobStorageContext();
26 context->SetUserData(kBlobStorageContextKeyName, 26 context->SetUserData(
27 new UserDataAdapter<ChromeBlobStorageContext>(blob)); 27 kBlobStorageContextKeyName,
28 new UserDataAdapter<ChromeBlobStorageContext>(blob.get()));
28 // Check first to avoid memory leak in unittests. 29 // Check first to avoid memory leak in unittests.
29 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { 30 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
30 BrowserThread::PostTask( 31 BrowserThread::PostTask(
31 BrowserThread::IO, FROM_HERE, 32 BrowserThread::IO, FROM_HERE,
32 base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread, blob)); 33 base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread, blob));
33 } 34 }
34 } 35 }
35 36
36 return UserDataAdapter<ChromeBlobStorageContext>::Get( 37 return UserDataAdapter<ChromeBlobStorageContext>::Get(
37 context, kBlobStorageContextKeyName); 38 context, kBlobStorageContextKeyName);
38 } 39 }
39 40
40 void ChromeBlobStorageContext::InitializeOnIOThread() { 41 void ChromeBlobStorageContext::InitializeOnIOThread() {
41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
42 controller_.reset(new BlobStorageController()); 43 controller_.reset(new BlobStorageController());
43 } 44 }
44 45
45 ChromeBlobStorageContext::~ChromeBlobStorageContext() {} 46 ChromeBlobStorageContext::~ChromeBlobStorageContext() {}
46 47
47 void ChromeBlobStorageContext::DeleteOnCorrectThread() const { 48 void ChromeBlobStorageContext::DeleteOnCorrectThread() const {
48 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && 49 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) &&
49 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { 50 !BrowserThread::CurrentlyOn(BrowserThread::IO)) {
50 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); 51 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this);
51 return; 52 return;
52 } 53 }
53 delete this; 54 delete this;
54 } 55 }
55 56
56 } // namespace content 57 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/save_file_resource_handler.cc ('k') | content/browser/fileapi/fileapi_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698