Chromium Code Reviews| 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..36a63082063855625fc7131357d5e8fe63e91b74 |
| --- /dev/null |
| +++ b/content/browser/streams/stream_registry.cc |
| @@ -0,0 +1,51 @@ |
| +// 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" |
|
kinuko
2013/03/07 08:35:40
Some of the includes look unnecessary
Zachary Kuznia
2013/03/07 08:57:55
Removed.
|
| + |
| +namespace content { |
| + |
| +StreamRegistry::StreamRegistry() { |
| +} |
| + |
| +StreamRegistry::~StreamRegistry() { |
| + DCHECK(CalledOnValidThread()); |
|
kinuko
2013/03/07 08:35:40
nit: the dtor of NonThreadSafe will check this
Zachary Kuznia
2013/03/07 08:57:55
Done.
|
| +} |
| + |
| +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) { |
|
kinuko
2013/03/07 08:35:40
nit: DCHECK(CalledOnValidThread()); ?
Zachary Kuznia
2013/03/07 08:57:55
Done.
|
| + std::map<GURL, scoped_refptr<Stream> >::iterator stream = streams_.find(url); |
| + if (stream != streams_.end()) { |
| + return stream->second; |
| + } |
|
kinuko
2013/03/07 08:35:40
style-nit: no need of { } for one-line body
Zachary Kuznia
2013/03/07 08:57:55
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; |
|
kinuko
2013/03/07 08:35:40
Is this ok not to indicate any errors if (!stream)
Zachary Kuznia
2013/03/07 08:57:55
Added a return value.
|
| +} |
| + |
| +void StreamRegistry::UnregisterStream(const GURL& url) { |
| + DCHECK(CalledOnValidThread()); |
| + streams_.erase(url); |
| +} |
| + |
| +} // namespace content |