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 GURL url(std::string(chrome::kBlobScheme) + ":" + |
| 25 stream->security_origin().spec() + |
| 26 base::GenerateGUID()); |
| 27 stream->SetStreamUrl(url); |
| 28 streams_[url] = stream; |
| 29 } |
| 30 |
| 31 scoped_refptr<Stream> StreamRegistry::GetStream(const GURL& url) { |
| 32 std::map<GURL, scoped_refptr<Stream> >::iterator stream = streams_.find(url); |
| 33 if (stream != streams_.end()) { |
| 34 return stream->second; |
| 35 } else { |
| 36 return NULL; |
| 37 } |
| 38 } |
| 39 |
| 40 void StreamRegistry::OnStreamConsumed(Stream* stream) { |
| 41 streams_.erase(stream->stream_url()); |
| 42 } |
| 43 |
| 44 } // namespace content |
OLD | NEW |