Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2247)

Unified Diff: content/browser/streams/stream_registry.cc

Issue 12335087: Implement the Stream registry in content (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix unittests Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3d463211605d9556f5a53030fee6ff812be2df97
--- /dev/null
+++ b/content/browser/streams/stream_registry.cc
@@ -0,0 +1,48 @@
+// 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 "content/browser/streams/stream.h"
+
+namespace content {
+
+StreamRegistry::StreamRegistry() {
+}
+
+StreamRegistry::~StreamRegistry() {
+}
+
+void StreamRegistry::RegisterStream(scoped_refptr<Stream> stream) {
+ DCHECK(CalledOnValidThread());
kinuko 2013/03/08 10:16:52 nit: DCHECK(stream) also here maybe
Zachary Kuznia 2013/03/11 01:32:44 Done.
+ 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);
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.
+ 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 {
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.
+ return false;
+ }
+}
+
+void StreamRegistry::UnregisterStream(const GURL& url) {
+ DCHECK(CalledOnValidThread());
+ streams_.erase(url);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698