1 // Copyright 2014 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.
5 #ifndef CONTENT_BROWSER_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_DISPATCHER_HOST_H_
8 #include "content/public/browser/browser_message_filter.h"
14 class MessagePortMessageFilter
;
15 class NavigatorConnectContextImpl
;
16 struct NavigatorConnectClient
;
17 struct TransferredMessagePort
;
19 // Receives navigator.connect connection attempts from a child process.
20 // Attempts to find a service that serves the URL the connection is made to
21 // and sets up the actual connection.
22 // Constructed on the UI thread, but all other methods are called on the IO
23 // thread. Typically there is one instance of this class for each renderer
24 // process, and this class lives at least as long as the renderer process is
25 // alive (since this class is refcounted it could outlive the renderer process
26 // if it is still handling a connection attempt).
27 class NavigatorConnectDispatcherHost
: public BrowserMessageFilter
{
29 NavigatorConnectDispatcherHost(
30 const scoped_refptr
<NavigatorConnectContextImpl
>&
31 navigator_connect_context
,
32 MessagePortMessageFilter
* message_port_message_filter
);
35 ~NavigatorConnectDispatcherHost() override
;
37 // BrowserMessageFilter implementation.
38 bool OnMessageReceived(const IPC::Message
& message
) override
;
40 // IPC Message handlers.
41 void OnConnect(int thread_id
,
43 const NavigatorConnectClient
& client
);
45 // Callback called when the service worker finished handling the cross origin
47 void OnConnectResult(int thread_id
,
49 const TransferredMessagePort
& message_port
,
50 int message_port_route_id
,
51 bool accept_connection
);
53 scoped_refptr
<NavigatorConnectContextImpl
> navigator_connect_context_
;
54 MessagePortMessageFilter
* const message_port_message_filter_
;
56 DISALLOW_COPY_AND_ASSIGN(NavigatorConnectDispatcherHost
);
59 } // namespace content
61 #endif // CONTENT_BROWSER_NAVIGATOR_CONNECT_NAVIGATOR_CONNECT_DISPATCHER_HOST_H_