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 #include <string> |
| 8 |
| 9 #include "base/guid.h" |
| 10 #include "base/stl_util.h" |
| 11 #include "base/string_number_conversions.h" |
| 12 #include "content/browser/streams/stream.h" |
| 13 #include "content/public/common/url_constants.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 StreamRegistry::StreamRegistry() { |
| 18 } |
| 19 |
| 20 StreamRegistry::~StreamRegistry() { |
| 21 } |
| 22 |
| 23 void StreamRegistry::RegisterStream(scoped_refptr<Stream> stream) { |
| 24 if (stream->stream_url().is_empty()) { |
| 25 GURL url(std::string(chrome::kBlobScheme) + ":" + |
| 26 stream->security_origin().spec() + |
| 27 base::GenerateGUID()); |
| 28 stream->SetStreamUrl(url); |
| 29 } |
| 30 streams_[stream->stream_url()] = stream; |
| 31 } |
| 32 |
| 33 scoped_refptr<Stream> StreamRegistry::GetStream(const GURL& url) { |
| 34 std::map<GURL, scoped_refptr<Stream> >::iterator stream = streams_.find(url); |
| 35 if (stream != streams_.end()) { |
| 36 return stream->second; |
| 37 } else { |
| 38 return NULL; |
| 39 } |
| 40 } |
| 41 |
| 42 void StreamRegistry::CloneStream(const GURL& url, const GURL& src_url) { |
| 43 scoped_refptr<Stream> stream(GetStream(src_url)); |
| 44 if (stream) |
| 45 streams_[url] = stream; |
| 46 } |
| 47 |
| 48 void StreamRegistry::UnregisterStream(const GURL& url) { |
| 49 streams_.erase(url); |
| 50 } |
| 51 |
| 52 void StreamRegistry::OnStreamConsumed(Stream* stream) { |
| 53 streams_.erase(stream->stream_url()); |
| 54 } |
| 55 |
| 56 } // namespace content |
OLD | NEW |