OLD | NEW |
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 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
11 | 11 |
12 using base::UserDataAdapter; | 12 using base::UserDataAdapter; |
13 | 13 |
14 namespace { | 14 namespace { |
15 const char* kStreamContextKeyName = "content_stream_context"; | 15 |
16 } | 16 const char kStreamContextKeyName[] = "content_stream_context"; |
| 17 |
| 18 } // namespace |
17 | 19 |
18 namespace content { | 20 namespace content { |
19 | 21 |
20 StreamContext::StreamContext() {} | 22 StreamContext::StreamContext() {} |
21 | 23 |
22 StreamContext* StreamContext::GetFor(BrowserContext* context) { | 24 StreamContext* StreamContext::GetFor(BrowserContext* context) { |
23 if (!context->GetUserData(kStreamContextKeyName)) { | 25 if (!context->GetUserData(kStreamContextKeyName)) { |
24 scoped_refptr<StreamContext> stream = new StreamContext(); | 26 scoped_refptr<StreamContext> stream = new StreamContext(); |
25 context->SetUserData(kStreamContextKeyName, | 27 context->SetUserData(kStreamContextKeyName, |
26 new UserDataAdapter<StreamContext>(stream.get())); | 28 new UserDataAdapter<StreamContext>(stream.get())); |
(...skipping 22 matching lines...) Expand all Loading... |
49 // tests. | 51 // tests. |
50 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && | 52 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && |
51 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 53 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
52 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 54 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
53 return; | 55 return; |
54 } | 56 } |
55 delete this; | 57 delete this; |
56 } | 58 } |
57 | 59 |
58 } // namespace content | 60 } // namespace content |
OLD | NEW |