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..f0e17dac573d425d945edece8467b1f7385ece2e |
--- /dev/null |
+++ b/content/browser/streams/stream_registry.cc |
@@ -0,0 +1,61 @@ |
+// 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" |
+ |
+#include <string> |
+ |
+#include "base/guid.h" |
+#include "base/stl_util.h" |
+#include "base/string_number_conversions.h" |
+#include "content/browser/streams/stream.h" |
+#include "content/public/common/url_constants.h" |
+ |
+namespace content { |
+ |
+StreamRegistry::StreamRegistry() { |
+} |
+ |
+StreamRegistry::~StreamRegistry() { |
+ DCHECK(CalledOnValidThread()); |
+} |
+ |
+void StreamRegistry::RegisterStream(scoped_refptr<Stream> stream) { |
+ DCHECK(CalledOnValidThread()); |
+ if (stream->stream_url().is_empty()) { |
+ 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
|
+ stream->security_origin().spec() + |
+ base::GenerateGUID()); |
+ stream->SetStreamUrl(url); |
+ } |
+ streams_[stream->stream_url()] = stream; |
+} |
+ |
+scoped_refptr<Stream> StreamRegistry::GetStream(const GURL& url) { |
+ std::map<GURL, scoped_refptr<Stream> >::iterator stream = streams_.find(url); |
+ if (stream != streams_.end()) { |
+ return stream->second; |
+ } 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.
|
+ return NULL; |
+ } |
+} |
+ |
+void StreamRegistry::CloneStream(const GURL& url, const GURL& src_url) { |
+ DCHECK(CalledOnValidThread()); |
+ scoped_refptr<Stream> stream(GetStream(src_url)); |
+ if (stream) |
+ streams_[url] = stream; |
+} |
+ |
+void StreamRegistry::UnregisterStream(const GURL& url) { |
+ DCHECK(CalledOnValidThread()); |
+ streams_.erase(url); |
+} |
+ |
+void StreamRegistry::OnStreamConsumed(Stream* stream) { |
+ DCHECK(CalledOnValidThread()); |
+ streams_.erase(stream->stream_url()); |
+} |
+ |
+} // namespace content |