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

Side by Side Diff: content/browser/streams/stream_registry.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_registry.h"
6
7 #include <string>
8
9 #include "base/guid.h"
10 #include "base/stl_util.h"
11 #include "base/string_number_conversions.h"
12 #include "content/browser/streams/stream.h"
13 #include "content/public/common/url_constants.h"
14
15 namespace content {
16
17 StreamRegistry::StreamRegistry() {
18 }
19
20 StreamRegistry::~StreamRegistry() {
21 DCHECK(CalledOnValidThread());
22 }
23
24 void StreamRegistry::RegisterStream(scoped_refptr<Stream> stream) {
25 DCHECK(CalledOnValidThread());
26 if (stream->stream_url().is_empty()) {
27 GURL url(std::string(chrome::kBlobScheme) + ":" +
darin (slow to review) 2013/02/27 06:18:59 nit: it feels like this URL generation should be d
Zachary Kuznia 2013/02/27 07:36:56 I'm going to remove this code from this CL, since
28 stream->security_origin().spec() +
29 base::GenerateGUID());
30 stream->SetStreamUrl(url);
31 }
32 streams_[stream->stream_url()] = stream;
33 }
34
35 scoped_refptr<Stream> StreamRegistry::GetStream(const GURL& url) {
36 std::map<GURL, scoped_refptr<Stream> >::iterator stream = streams_.find(url);
37 if (stream != streams_.end()) {
38 return stream->second;
39 } else {
darin (slow to review) 2013/02/27 06:18:59 nit: no need for else after return
Zachary Kuznia 2013/02/27 07:36:56 Done.
40 return NULL;
41 }
42 }
43
44 void StreamRegistry::CloneStream(const GURL& url, const GURL& src_url) {
45 DCHECK(CalledOnValidThread());
46 scoped_refptr<Stream> stream(GetStream(src_url));
47 if (stream)
48 streams_[url] = stream;
49 }
50
51 void StreamRegistry::UnregisterStream(const GURL& url) {
52 DCHECK(CalledOnValidThread());
53 streams_.erase(url);
54 }
55
56 void StreamRegistry::OnStreamConsumed(Stream* stream) {
57 DCHECK(CalledOnValidThread());
58 streams_.erase(stream->stream_url());
59 }
60
61 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698