| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_BROADCAST_CHANNEL_BROADCAST_CHANNEL_PROVIDER_H_ | 5 #ifndef CONTENT_BROWSER_BROADCAST_CHANNEL_BROADCAST_CHANNEL_PROVIDER_H_ |
| 6 #define CONTENT_BROWSER_BROADCAST_CHANNEL_BROADCAST_CHANNEL_PROVIDER_H_ | 6 #define CONTENT_BROWSER_BROADCAST_CHANNEL_BROADCAST_CHANNEL_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "mojo/public/cpp/bindings/binding_set.h" | 11 #include "mojo/public/cpp/bindings/binding_set.h" |
| 12 #include "third_party/WebKit/public/platform/modules/broadcastchannel/broadcast_
channel.mojom.h" | 12 #include "third_party/WebKit/public/platform/modules/broadcastchannel/broadcast_
channel.mojom.h" |
| 13 #include "url/origin.h" | 13 #include "url/origin.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 class BroadcastChannelProvider | 17 class BroadcastChannelProvider |
| 18 : public base::RefCountedThreadSafe<BroadcastChannelProvider>, | 18 : public base::RefCountedThreadSafe<BroadcastChannelProvider>, |
| 19 public blink::mojom::BroadcastChannelProvider { | 19 public blink::mojom::BroadcastChannelProvider { |
| 20 public: | 20 public: |
| 21 BroadcastChannelProvider(); | 21 BroadcastChannelProvider(); |
| 22 void Connect( | 22 void Connect( |
| 23 mojo::InterfaceRequest<blink::mojom::BroadcastChannelProvider> request); | 23 mojo::InterfaceRequest<blink::mojom::BroadcastChannelProvider> request); |
| 24 | 24 |
| 25 void ConnectToChannel( | 25 void ConnectToChannel( |
| 26 const url::Origin& origin, | 26 const url::Origin& origin, |
| 27 const mojo::String& name, | 27 const std::string& name, |
| 28 blink::mojom::BroadcastChannelClientAssociatedPtrInfo client, | 28 blink::mojom::BroadcastChannelClientAssociatedPtrInfo client, |
| 29 blink::mojom::BroadcastChannelClientAssociatedRequest connection) | 29 blink::mojom::BroadcastChannelClientAssociatedRequest connection) |
| 30 override; | 30 override; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 friend class base::RefCountedThreadSafe<BroadcastChannelProvider>; | 33 friend class base::RefCountedThreadSafe<BroadcastChannelProvider>; |
| 34 class Connection; | 34 class Connection; |
| 35 | 35 |
| 36 ~BroadcastChannelProvider() override; | 36 ~BroadcastChannelProvider() override; |
| 37 | 37 |
| 38 void UnregisterConnection(Connection*); | 38 void UnregisterConnection(Connection*); |
| 39 void ReceivedMessageOnConnection(Connection*, mojo::Array<uint8_t> message); | 39 void ReceivedMessageOnConnection(Connection*, |
| 40 const std::vector<uint8_t>& message); |
| 40 | 41 |
| 41 mojo::BindingSet<blink::mojom::BroadcastChannelProvider> bindings_; | 42 mojo::BindingSet<blink::mojom::BroadcastChannelProvider> bindings_; |
| 42 std::map<url::Origin, std::multimap<std::string, std::unique_ptr<Connection>>> | 43 std::map<url::Origin, std::multimap<std::string, std::unique_ptr<Connection>>> |
| 43 connections_; | 44 connections_; |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 } // namespace content | 47 } // namespace content |
| 47 | 48 |
| 48 #endif // CONTENT_BROWSER_BROADCAST_CHANNEL_BROADCAST_CHANNEL_PROVIDER_H_ | 49 #endif // CONTENT_BROWSER_BROADCAST_CHANNEL_BROADCAST_CHANNEL_PROVIDER_H_ |
| OLD | NEW |