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

Side by Side Diff: content/browser/streams/stream_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
« no previous file with comments | « content/browser/streams/stream.cc ('k') | content/browser/streams/stream_registry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/streams/stream_context.h" 5 #include "content/browser/streams/stream_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/streams/stream_registry.h" 8 #include "content/browser/streams/stream_registry.h"
9 #include "content/public/browser/browser_context.h" 9 #include "content/public/browser/browser_context.h"
10 10
11 using base::UserDataAdapter; 11 using base::UserDataAdapter;
12 12
13 namespace { 13 namespace {
14 const char* kStreamContextKeyName = "content_stream_context"; 14 const char* kStreamContextKeyName = "content_stream_context";
15 } 15 }
16 16
17 namespace content { 17 namespace content {
18 18
19 StreamContext::StreamContext() {} 19 StreamContext::StreamContext() {}
20 20
21 StreamContext* StreamContext::GetFor(BrowserContext* context) { 21 StreamContext* StreamContext::GetFor(BrowserContext* context) {
22 if (!context->GetUserData(kStreamContextKeyName)) { 22 if (!context->GetUserData(kStreamContextKeyName)) {
23 scoped_refptr<StreamContext> stream = new StreamContext(); 23 scoped_refptr<StreamContext> stream = new StreamContext();
24 context->SetUserData(kStreamContextKeyName, 24 context->SetUserData(kStreamContextKeyName,
25 new UserDataAdapter<StreamContext>(stream)); 25 new UserDataAdapter<StreamContext>(stream.get()));
26 // Check first to avoid memory leak in unittests. 26 // Check first to avoid memory leak in unittests.
27 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { 27 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
28 BrowserThread::PostTask( 28 BrowserThread::PostTask(
29 BrowserThread::IO, FROM_HERE, 29 BrowserThread::IO, FROM_HERE,
30 base::Bind(&StreamContext::InitializeOnIOThread, stream)); 30 base::Bind(&StreamContext::InitializeOnIOThread, stream));
31 } 31 }
32 } 32 }
33 33
34 return UserDataAdapter<StreamContext>::Get(context, kStreamContextKeyName); 34 return UserDataAdapter<StreamContext>::Get(context, kStreamContextKeyName);
35 } 35 }
(...skipping 12 matching lines...) Expand all
48 // tests. 48 // tests.
49 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && 49 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) &&
50 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { 50 !BrowserThread::CurrentlyOn(BrowserThread::IO)) {
51 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); 51 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this);
52 return; 52 return;
53 } 53 }
54 delete this; 54 delete this;
55 } 55 }
56 56
57 } // namespace content 57 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/streams/stream.cc ('k') | content/browser/streams/stream_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698