Chromium Code Reviews| OLD | NEW |
|---|---|
| (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" | |
|
kinuko
2013/03/07 08:35:40
Some of the includes look unnecessary
Zachary Kuznia
2013/03/07 08:57:55
Removed.
| |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 StreamRegistry::StreamRegistry() { | |
| 18 } | |
| 19 | |
| 20 StreamRegistry::~StreamRegistry() { | |
| 21 DCHECK(CalledOnValidThread()); | |
|
kinuko
2013/03/07 08:35:40
nit: the dtor of NonThreadSafe will check this
Zachary Kuznia
2013/03/07 08:57:55
Done.
| |
| 22 } | |
| 23 | |
| 24 void StreamRegistry::RegisterStream(scoped_refptr<Stream> stream) { | |
| 25 DCHECK(CalledOnValidThread()); | |
| 26 DCHECK(!stream->url().is_empty()); | |
| 27 streams_[stream->url()] = stream; | |
| 28 } | |
| 29 | |
| 30 scoped_refptr<Stream> StreamRegistry::GetStream(const GURL& url) { | |
|
kinuko
2013/03/07 08:35:40
nit: DCHECK(CalledOnValidThread()); ?
Zachary Kuznia
2013/03/07 08:57:55
Done.
| |
| 31 std::map<GURL, scoped_refptr<Stream> >::iterator stream = streams_.find(url); | |
| 32 if (stream != streams_.end()) { | |
| 33 return stream->second; | |
| 34 } | |
|
kinuko
2013/03/07 08:35:40
style-nit: no need of { } for one-line body
Zachary Kuznia
2013/03/07 08:57:55
Done.
| |
| 35 | |
| 36 return NULL; | |
| 37 } | |
| 38 | |
| 39 void StreamRegistry::CloneStream(const GURL& url, const GURL& src_url) { | |
| 40 DCHECK(CalledOnValidThread()); | |
| 41 scoped_refptr<Stream> stream(GetStream(src_url)); | |
| 42 if (stream) | |
| 43 streams_[url] = stream; | |
|
kinuko
2013/03/07 08:35:40
Is this ok not to indicate any errors if (!stream)
Zachary Kuznia
2013/03/07 08:57:55
Added a return value.
| |
| 44 } | |
| 45 | |
| 46 void StreamRegistry::UnregisterStream(const GURL& url) { | |
| 47 DCHECK(CalledOnValidThread()); | |
| 48 streams_.erase(url); | |
| 49 } | |
| 50 | |
| 51 } // namespace content | |
| OLD | NEW |