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 namespace content { |
| 8 |
| 9 StreamRegistry::StreamRegistry() { |
| 10 } |
| 11 |
| 12 StreamRegistry::~StreamRegistry() { |
| 13 } |
| 14 |
| 15 void StreamRegistry::RegisterStream(scoped_refptr<Stream> stream) { |
| 16 DCHECK(CalledOnValidThread()); |
| 17 DCHECK(!stream->url().is_empty()); |
| 18 streams_[stream->url()] = stream; |
| 19 } |
| 20 |
| 21 scoped_refptr<Stream> StreamRegistry::GetStream(const GURL& url) { |
| 22 DCHECK(CalledOnValidThread()); |
| 23 std::map<GURL, scoped_refptr<Stream> >::iterator stream = streams_.find(url); |
| 24 if (stream != streams_.end()) |
| 25 return stream->second; |
| 26 |
| 27 return NULL; |
| 28 } |
| 29 |
| 30 bool StreamRegistry::CloneStream(const GURL& url, const GURL& src_url) { |
| 31 DCHECK(CalledOnValidThread()); |
| 32 scoped_refptr<Stream> stream(GetStream(src_url)); |
| 33 if (stream) { |
| 34 streams_[url] = stream; |
| 35 return true; |
| 36 } else { |
| 37 return false; |
| 38 } |
| 39 } |
| 40 |
| 41 void StreamRegistry::UnregisterStream(const GURL& url) { |
| 42 DCHECK(CalledOnValidThread()); |
| 43 streams_.erase(url); |
| 44 } |
| 45 |
| 46 } // namespace content |
OLD | NEW |