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 "content/browser/streams/stream.h" | |
| 8 | |
| 9 namespace content { | |
| 10 | |
| 11 StreamRegistry::StreamRegistry() { | |
| 12 } | |
| 13 | |
| 14 StreamRegistry::~StreamRegistry() { | |
| 15 } | |
| 16 | |
| 17 void StreamRegistry::RegisterStream(scoped_refptr<Stream> stream) { | |
| 18 DCHECK(CalledOnValidThread()); | |
|
kinuko
2013/03/08 10:16:52
nit: DCHECK(stream) also here maybe
Zachary Kuznia
2013/03/11 01:32:44
Done.
| |
| 19 DCHECK(!stream->url().is_empty()); | |
| 20 streams_[stream->url()] = stream; | |
| 21 } | |
| 22 | |
| 23 scoped_refptr<Stream> StreamRegistry::GetStream(const GURL& url) { | |
| 24 DCHECK(CalledOnValidThread()); | |
| 25 std::map<GURL, scoped_refptr<Stream> >::iterator stream = streams_.find(url); | |
|
darin (slow to review)
2013/03/09 00:43:05
nit: use a const_iterator since you don't need to
Zachary Kuznia
2013/03/11 01:32:44
Done.
| |
| 26 if (stream != streams_.end()) | |
| 27 return stream->second; | |
| 28 | |
| 29 return NULL; | |
| 30 } | |
| 31 | |
| 32 bool StreamRegistry::CloneStream(const GURL& url, const GURL& src_url) { | |
| 33 DCHECK(CalledOnValidThread()); | |
| 34 scoped_refptr<Stream> stream(GetStream(src_url)); | |
| 35 if (stream) { | |
| 36 streams_[url] = stream; | |
| 37 return true; | |
| 38 } else { | |
|
darin (slow to review)
2013/03/09 00:43:05
nit: no need for else after return
Zachary Kuznia
2013/03/11 01:32:44
Done.
| |
| 39 return false; | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 void StreamRegistry::UnregisterStream(const GURL& url) { | |
| 44 DCHECK(CalledOnValidThread()); | |
| 45 streams_.erase(url); | |
| 46 } | |
| 47 | |
| 48 } // namespace content | |
| OLD | NEW |