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

Side by Side Diff: content/browser/streams/stream_context.cc

Issue 12335087: Implement the Stream registry in content (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: COde review fixes Created 7 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/streams/stream_context.h"
6
7 #include "base/bind.h"
8 #include "content/browser/streams/stream_registry.h"
9 #include "content/public/browser/browser_context.h"
10
11 using base::UserDataAdapter;
12
13 namespace content {
14
15 static const char* kStreamContextKeyName = "content_stream_context";
16
17 StreamContext::StreamContext() {}
18
19 StreamContext* StreamContext::GetFor(BrowserContext* context) {
20 if (!context->GetUserData(kStreamContextKeyName)) {
21 scoped_refptr<StreamContext> stream = new StreamContext();
22 context->SetUserData(kStreamContextKeyName,
23 new UserDataAdapter<StreamContext>(stream));
24 // Check first to avoid memory leak in unittests.
25 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
26 BrowserThread::PostTask(
27 BrowserThread::IO, FROM_HERE,
28 base::Bind(&StreamContext::InitializeOnIOThread, stream));
29 }
30 }
31
32 return UserDataAdapter<StreamContext>::Get(context, kStreamContextKeyName);
33 }
34
35 void StreamContext::InitializeOnIOThread() {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
37 registry_.reset(new StreamRegistry());
38 }
39
40 StreamContext::~StreamContext() {}
41
42 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698