OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * |
| 3 * Copyright 2015-2016, Google Inc. |
| 4 * All rights reserved. |
3 * | 5 * |
4 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
6 * met: | 8 * met: |
7 * | 9 * |
8 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 11 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 12 * * Redistributions in binary form must reproduce the above |
11 * copyright notice, this list of conditions and the following disclaimer | 13 * copyright notice, this list of conditions and the following disclaimer |
12 * in the documentation and/or other materials provided with the | 14 * in the documentation and/or other materials provided with the |
13 * distribution. | 15 * distribution. |
14 * * Neither the name of Google Inc. nor the names of its | 16 * * Neither the name of Google Inc. nor the names of its |
15 * contributors may be used to endorse or promote products derived from | 17 * contributors may be used to endorse or promote products derived from |
16 * this software without specific prior written permission. | 18 * this software without specific prior written permission. |
17 * | 19 * |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 * |
29 */ | 32 */ |
30 | 33 |
31 #include "modules/mediasource/MediaSourceRegistry.h" | 34 #ifndef GRPCXX_CREATE_CHANNEL_H |
| 35 #define GRPCXX_CREATE_CHANNEL_H |
32 | 36 |
33 #include "modules/mediasource/MediaSource.h" | 37 #include <memory> |
34 #include "platform/weborigin/KURL.h" | |
35 | 38 |
36 namespace blink { | 39 #include <grpc++/channel.h> |
| 40 #include <grpc++/security/credentials.h> |
| 41 #include <grpc++/support/channel_arguments.h> |
| 42 #include <grpc++/support/config.h> |
37 | 43 |
38 MediaSourceRegistry& MediaSourceRegistry::registry() | 44 namespace grpc { |
39 { | |
40 ASSERT(isMainThread()); | |
41 DEFINE_STATIC_LOCAL(MediaSourceRegistry, instance, ()); | |
42 return instance; | |
43 } | |
44 | 45 |
45 void MediaSourceRegistry::registerURL(SecurityOrigin*, const KURL& url, URLRegis
trable* registrable) | 46 /// Create a new \a Channel pointing to \a target |
46 { | 47 /// |
47 ASSERT(®istrable->registry() == this); | 48 /// \param target The URI of the endpoint to connect to. |
48 ASSERT(isMainThread()); | 49 /// \param creds Credentials to use for the created channel. If it does not hold |
| 50 /// an object or is invalid, a lame channel is returned. |
| 51 /// \param args Options for channel creation. |
| 52 std::shared_ptr<Channel> CreateChannel( |
| 53 const grpc::string& target, |
| 54 const std::shared_ptr<ChannelCredentials>& creds); |
49 | 55 |
50 MediaSource* source = static_cast<MediaSource*>(registrable); | 56 /// Create a new \em custom \a Channel pointing to \a target |
51 source->addedToRegistry(); | 57 /// |
52 m_mediaSources.set(url.getString(), source); | 58 /// \warning For advanced use and testing ONLY. Override default channel |
53 } | 59 /// arguments only if necessary. |
| 60 /// |
| 61 /// \param target The URI of the endpoint to connect to. |
| 62 /// \param creds Credentials to use for the created channel. If it does not hold |
| 63 /// an object or is invalid, a lame channel is returned. |
| 64 /// \param args Options for channel creation. |
| 65 std::shared_ptr<Channel> CreateCustomChannel( |
| 66 const grpc::string& target, |
| 67 const std::shared_ptr<ChannelCredentials>& creds, |
| 68 const ChannelArguments& args); |
54 | 69 |
55 void MediaSourceRegistry::unregisterURL(const KURL& url) | 70 } // namespace grpc |
56 { | |
57 ASSERT(isMainThread()); | |
58 PersistentHeapHashMap<String, Member<MediaSource>>::iterator iter = m_mediaS
ources.find(url.getString()); | |
59 if (iter == m_mediaSources.end()) | |
60 return; | |
61 | 71 |
62 MediaSource* source = iter->value; | 72 #endif // GRPCXX_CREATE_CHANNEL_H |
63 m_mediaSources.remove(iter); | |
64 source->removedFromRegistry(); | |
65 } | |
66 | |
67 URLRegistrable* MediaSourceRegistry::lookup(const String& url) | |
68 { | |
69 ASSERT(isMainThread()); | |
70 return m_mediaSources.get(url); | |
71 } | |
72 | |
73 MediaSourceRegistry::MediaSourceRegistry() | |
74 { | |
75 HTMLMediaSource::setRegistry(this); | |
76 } | |
77 | |
78 } // namespace blink | |
OLD | NEW |