Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / navigator_connect / navigator_connect_dispatcher_host.cc
blobdaa46ba7f18b2b5b0cb284f6967c3e9478b53313
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 #include "content/browser/navigator_connect/navigator_connect_dispatcher_host.h"
7 #include "content/browser/message_port_service.h"
8 #include "content/browser/navigator_connect/navigator_connect_context_impl.h"
9 #include "content/browser/service_worker/service_worker_context_wrapper.h"
10 #include "content/common/navigator_connect_messages.h"
11 #include "content/public/common/navigator_connect_client.h"
13 namespace content {
15 NavigatorConnectDispatcherHost::NavigatorConnectDispatcherHost(
16 const scoped_refptr<NavigatorConnectContextImpl>& navigator_connect_context,
17 MessagePortMessageFilter* message_port_message_filter)
18 : BrowserMessageFilter(NavigatorConnectMsgStart),
19 navigator_connect_context_(navigator_connect_context),
20 message_port_message_filter_(message_port_message_filter) {
23 NavigatorConnectDispatcherHost::~NavigatorConnectDispatcherHost() {
26 bool NavigatorConnectDispatcherHost::OnMessageReceived(
27 const IPC::Message& message) {
28 bool handled = true;
29 IPC_BEGIN_MESSAGE_MAP(NavigatorConnectDispatcherHost, message)
30 IPC_MESSAGE_HANDLER(NavigatorConnectHostMsg_Connect, OnConnect)
31 IPC_MESSAGE_UNHANDLED(handled = false)
32 IPC_END_MESSAGE_MAP()
33 return handled;
36 void NavigatorConnectDispatcherHost::OnConnect(
37 int thread_id,
38 int request_id,
39 const NavigatorConnectClient& client) {
40 DCHECK_CURRENTLY_ON(BrowserThread::IO);
42 DCHECK(client.message_port_id == MSG_ROUTING_NONE)
43 << "Connect request should not include a message port";
45 navigator_connect_context_->Connect(
46 client, message_port_message_filter_,
47 base::Bind(&NavigatorConnectDispatcherHost::OnConnectResult, this,
48 thread_id, request_id));
51 void NavigatorConnectDispatcherHost::OnConnectResult(
52 int thread_id,
53 int request_id,
54 const TransferredMessagePort& message_port,
55 int message_port_route_id,
56 bool accept_connection) {
57 DCHECK_CURRENTLY_ON(BrowserThread::IO);
58 Send(new NavigatorConnectMsg_ConnectResult(
59 thread_id, request_id, message_port, message_port_route_id,
60 accept_connection));
63 } // namespace content