Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.cpp

Issue 2158913006: Move BroadcastChannel browser code from components/ to content/browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "modules/broadcastchannel/BroadcastChannel.h" 5 #include "modules/broadcastchannel/BroadcastChannel.h"
6 6
7 #include "bindings/core/v8/SerializedScriptValue.h" 7 #include "bindings/core/v8/SerializedScriptValue.h"
8 #include "core/dom/ExceptionCode.h" 8 #include "core/dom/ExceptionCode.h"
9 #include "core/events/EventQueue.h" 9 #include "core/events/EventQueue.h"
10 #include "core/events/MessageEvent.h" 10 #include "core/events/MessageEvent.h"
11 #include "platform/mojo/MojoHelper.h" 11 #include "platform/mojo/MojoHelper.h"
12 #include "public/platform/Platform.h" 12 #include "public/platform/Platform.h"
13 #include "public/platform/ServiceRegistry.h" 13 #include "public/platform/ServiceRegistry.h"
14 #include "wtf/Functional.h" 14 #include "wtf/Functional.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 namespace { 18 namespace {
19 19
20 // To ensure proper ordering of messages send to/from multiple BroadcastChannel 20 // To ensure proper ordering of messages send to/from multiple BroadcastChannel
21 // instances in the same thread this uses one BroadcastChannelService 21 // instances in the same thread this uses one BroadcastChannelService
22 // connection as basis for all connections to channels from the same thread. The 22 // connection as basis for all connections to channels from the same thread. The
23 // actual connections used to send/receive messages are then created using 23 // actual connections used to send/receive messages are then created using
24 // associated interfaces, ensuring proper message ordering. 24 // associated interfaces, ensuring proper message ordering.
25 webmessaging::mojom::blink::BroadcastChannelProviderPtr& getThreadSpecificProvid er() 25 mojom::blink::BroadcastChannelProviderPtr& getThreadSpecificProvider()
26 { 26 {
27 DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<webmessaging::mojom::blink::B roadcastChannelProviderPtr>, provider, new ThreadSpecific<webmessaging::mojom::b link::BroadcastChannelProviderPtr>); 27 DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<mojom::blink::BroadcastChanne lProviderPtr>, provider, new ThreadSpecific<mojom::blink::BroadcastChannelProvid erPtr>);
28 if (!provider.isSet()) { 28 if (!provider.isSet()) {
29 Platform::current()->serviceRegistry()->connectToRemoteService(mojo::Get Proxy(&*provider)); 29 Platform::current()->serviceRegistry()->connectToRemoteService(mojo::Get Proxy(&*provider));
30 } 30 }
31 return *provider; 31 return *provider;
32 } 32 }
33 33
34 } // namespace 34 } // namespace
35 35
36 // static 36 // static
37 BroadcastChannel* BroadcastChannel::create(ExecutionContext* executionContext, c onst String& name, ExceptionState& exceptionState) 37 BroadcastChannel* BroadcastChannel::create(ExecutionContext* executionContext, c onst String& name, ExceptionState& exceptionState)
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 close(); 111 close();
112 } 112 }
113 113
114 BroadcastChannel::BroadcastChannel(ExecutionContext* executionContext, const Str ing& name) 114 BroadcastChannel::BroadcastChannel(ExecutionContext* executionContext, const Str ing& name)
115 : ActiveScriptWrappable(this) 115 : ActiveScriptWrappable(this)
116 , ContextLifecycleObserver(executionContext) 116 , ContextLifecycleObserver(executionContext)
117 , m_origin(executionContext->getSecurityOrigin()) 117 , m_origin(executionContext->getSecurityOrigin())
118 , m_name(name) 118 , m_name(name)
119 , m_binding(this) 119 , m_binding(this)
120 { 120 {
121 webmessaging::mojom::blink::BroadcastChannelProviderPtr& provider = getThrea dSpecificProvider(); 121 mojom::blink::BroadcastChannelProviderPtr& provider = getThreadSpecificProvi der();
122 122
123 // Local BroadcastChannelClient for messages send from the browser to this c hannel. 123 // Local BroadcastChannelClient for messages send from the browser to this c hannel.
124 webmessaging::mojom::blink::BroadcastChannelClientAssociatedPtrInfo localCli entInfo; 124 mojom::blink::BroadcastChannelClientAssociatedPtrInfo localClientInfo;
125 m_binding.Bind(&localClientInfo, provider.associated_group()); 125 m_binding.Bind(&localClientInfo, provider.associated_group());
126 m_binding.set_connection_error_handler(convertToBaseCallback(WTF::bind(&Broa dcastChannel::onError, wrapWeakPersistent(this)))); 126 m_binding.set_connection_error_handler(convertToBaseCallback(WTF::bind(&Broa dcastChannel::onError, wrapWeakPersistent(this))));
127 127
128 // Remote BroadcastChannelClient for messages send from this channel to the browser. 128 // Remote BroadcastChannelClient for messages send from this channel to the browser.
129 webmessaging::mojom::blink::BroadcastChannelClientAssociatedPtrInfo remoteCl ientInfo; 129 mojom::blink::BroadcastChannelClientAssociatedPtrInfo remoteClientInfo;
130 mojo::AssociatedInterfaceRequest<webmessaging::mojom::blink::BroadcastChanne lClient> remoteCientRequest; 130 mojo::AssociatedInterfaceRequest<mojom::blink::BroadcastChannelClient> remot eCientRequest;
131 provider.associated_group()->CreateAssociatedInterface(mojo::AssociatedGroup ::WILL_PASS_REQUEST, &remoteClientInfo, &remoteCientRequest); 131 provider.associated_group()->CreateAssociatedInterface(mojo::AssociatedGroup ::WILL_PASS_REQUEST, &remoteClientInfo, &remoteCientRequest);
132 m_remoteClient.Bind(std::move(remoteClientInfo)); 132 m_remoteClient.Bind(std::move(remoteClientInfo));
133 m_remoteClient.set_connection_error_handler(convertToBaseCallback(WTF::bind( &BroadcastChannel::onError, wrapWeakPersistent(this)))); 133 m_remoteClient.set_connection_error_handler(convertToBaseCallback(WTF::bind( &BroadcastChannel::onError, wrapWeakPersistent(this))));
134 134
135 provider->ConnectToChannel(m_origin, m_name, std::move(localClientInfo), std ::move(remoteCientRequest)); 135 provider->ConnectToChannel(m_origin, m_name, std::move(localClientInfo), std ::move(remoteCientRequest));
136 } 136 }
137 137
138 } // namespace blink 138 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/broadcastchannel/BroadcastChannel.h ('k') | third_party/WebKit/Source/modules/modules.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698