Index: components/webmessaging/broadcast_channel_service.h |
diff --git a/components/webmessaging/broadcast_channel_service.h b/components/webmessaging/broadcast_channel_service.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f29d50a0a975560b3a17439f943de53561dd463f |
--- /dev/null |
+++ b/components/webmessaging/broadcast_channel_service.h |
@@ -0,0 +1,52 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_WEBMESSAGING_BROADCAST_CHANNEL_SERVICE_H_ |
+#define COMPONENTS_WEBMESSAGING_BROADCAST_CHANNEL_SERVICE_H_ |
+ |
+#include <map> |
+ |
+#include "base/memory/ref_counted.h" |
+#include "components/webmessaging/broadcast_channel.mojom.h" |
+#include "mojo/public/cpp/bindings/binding_set.h" |
+#include "url/origin.h" |
+ |
+namespace webmessaging { |
+ |
+class BroadcastChannelService |
+ : public base::RefCountedThreadSafe<BroadcastChannelService>, |
+ public mojom::BroadcastChannelService { |
+ public: |
+ BroadcastChannelService(); |
+ |
+ void ConnectProcess( |
+ mojo::InterfaceRequest<mojom::BroadcastChannelService> request); |
+ |
+ void ConnectToChannel( |
+ const mojo::String& origin, |
+ const mojo::String& name, |
+ mojom::BroadcastChannelClientAssociatedPtrInfo client, |
+ mojom::BroadcastChannelClientAssociatedRequest connection) override; |
+ |
+ private: |
+ friend class base::RefCountedThreadSafe<BroadcastChannelService>; |
+ |
+ class Connection; |
+ friend class Connection; |
+ |
+ ~BroadcastChannelService() override; |
+ |
+ void RegisterConnection(Connection*); |
+ void UnregisterConnection(Connection*); |
+ void ReceivedMessageOnConnection(Connection*, const mojo::String& message); |
+ |
+ mojo::BindingSet<mojom::BroadcastChannelService> bindings_; |
+ std::multimap<url::Origin, Connection*> connections_; |
+ |
+ base::WeakPtrFactory<BroadcastChannelService> weak_factory_; |
+}; |
+ |
+} // namespace webmessaging |
+ |
+#endif // COMPONENTS_WEBMESSAGING_CHANNEL_SERVICE_H_ |