Index: content/browser/streams/stream_registry.cc |
diff --git a/content/browser/streams/stream_registry.cc b/content/browser/streams/stream_registry.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f0b649d660cb6082b87cead29c08b6a42534bbe3 |
--- /dev/null |
+++ b/content/browser/streams/stream_registry.cc |
@@ -0,0 +1,46 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/streams/stream_registry.h" |
+ |
+namespace content { |
+ |
+StreamRegistry::StreamRegistry() { |
+} |
+ |
+StreamRegistry::~StreamRegistry() { |
+} |
+ |
+void StreamRegistry::RegisterStream(scoped_refptr<Stream> stream) { |
+ DCHECK(CalledOnValidThread()); |
+ DCHECK(!stream->url().is_empty()); |
+ streams_[stream->url()] = stream; |
+} |
+ |
+scoped_refptr<Stream> StreamRegistry::GetStream(const GURL& url) { |
+ DCHECK(CalledOnValidThread()); |
+ std::map<GURL, scoped_refptr<Stream> >::iterator stream = streams_.find(url); |
+ if (stream != streams_.end()) |
+ return stream->second; |
+ |
+ return NULL; |
+} |
+ |
+bool StreamRegistry::CloneStream(const GURL& url, const GURL& src_url) { |
+ DCHECK(CalledOnValidThread()); |
+ scoped_refptr<Stream> stream(GetStream(src_url)); |
+ if (stream) { |
+ streams_[url] = stream; |
+ return true; |
+ } else { |
+ return false; |
+ } |
+} |
+ |
+void StreamRegistry::UnregisterStream(const GURL& url) { |
+ DCHECK(CalledOnValidThread()); |
+ streams_.erase(url); |
+} |
+ |
+} // namespace content |