OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 #ifndef COMPONENTS_WEBMESSAGING_BROADCAST_CHANNEL_PROVIDER_H_ |
| 6 #define COMPONENTS_WEBMESSAGING_BROADCAST_CHANNEL_PROVIDER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "components/webmessaging/public/interfaces/broadcast_channel.mojom.h" |
| 12 #include "mojo/public/cpp/bindings/binding_set.h" |
| 13 #include "url/origin.h" |
| 14 |
| 15 namespace webmessaging { |
| 16 |
| 17 class BroadcastChannelProvider |
| 18 : public base::RefCountedThreadSafe<BroadcastChannelProvider>, |
| 19 public mojom::BroadcastChannelProvider { |
| 20 public: |
| 21 BroadcastChannelProvider(); |
| 22 void Connect(mojo::InterfaceRequest<mojom::BroadcastChannelProvider> request); |
| 23 |
| 24 void ConnectToChannel( |
| 25 const url::Origin& origin, |
| 26 const mojo::String& name, |
| 27 mojom::BroadcastChannelClientAssociatedPtrInfo client, |
| 28 mojom::BroadcastChannelClientAssociatedRequest connection) override; |
| 29 |
| 30 private: |
| 31 friend class base::RefCountedThreadSafe<BroadcastChannelProvider>; |
| 32 class Connection; |
| 33 |
| 34 ~BroadcastChannelProvider() override; |
| 35 |
| 36 void UnregisterConnection(Connection*); |
| 37 void ReceivedMessageOnConnection(Connection*, const mojo::String& message); |
| 38 |
| 39 mojo::BindingSet<mojom::BroadcastChannelProvider> bindings_; |
| 40 std::map<url::Origin, std::multimap<std::string, std::unique_ptr<Connection>>> |
| 41 connections_; |
| 42 }; |
| 43 |
| 44 } // namespace webmessaging |
| 45 |
| 46 #endif // COMPONENTS_WEBMESSAGING_BROADCAST_CHANNEL_PROVIDER_H_ |
OLD | NEW |